Update migration
- Use les `bd_alias` de Django - N'ajoute le 'before <date> """<ancien_token>"""' dans la liste des tokens si le champ token était précédement vide.
This commit is contained in:
parent
3aa9667eb9
commit
fd5b22169f
1 changed files with 8 additions and 5 deletions
|
@ -4,14 +4,17 @@ from __future__ import unicode_literals
|
|||
from django.db import migrations, models
|
||||
from django.utils import timezone
|
||||
|
||||
|
||||
def forwards_func(apps, schema_editor):
|
||||
Tirage = apps.get_model("bda", "Tirage")
|
||||
db_alias = schema_editor.connection.alias
|
||||
for tirage in Tirage.objects.all():
|
||||
tirage.tokens = "Before %s\n\"\"\"%s\"\"\"\n" % (
|
||||
timezone.now().strftime("%y-%m-%d %H:%M:%S"),
|
||||
tirage.tokens)
|
||||
tirage.save()
|
||||
for tirage in Tirage.objects.using(db_alias).all():
|
||||
if tirage.tokens:
|
||||
tirage.tokens = "Before %s\n\"\"\"%s\"\"\"\n" % (
|
||||
timezone.now().strftime("%y-%m-%d %H:%M:%S"),
|
||||
tirage.tokens)
|
||||
tirage.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
|
Loading…
Reference in a new issue