-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #182 : add creation_date and last_modification_date to Petition…
… model
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 2.2.16 on 2020-09-02 16:53 | ||
|
||
from django.db import migrations, models | ||
from django.utils import timezone | ||
|
||
def populate_dates(apps, schema_editor): | ||
Petition = apps.get_model('petition', 'Petition') | ||
for petition in Petition.objects.all().iterator(): | ||
petition.creation_date = timezone.now() | ||
petition.last_modification_date = timezone.now() | ||
petition.save() | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('petition', '0009_auto_20200210_0948'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='petition', | ||
name='creation_date', | ||
field=models.DateTimeField(null=True, blank=True), | ||
), | ||
migrations.AddField( | ||
model_name='petition', | ||
name='last_modification_date', | ||
field=models.DateTimeField(null=True, blank=True), | ||
), | ||
migrations.RunPython(populate_dates), | ||
migrations.AlterField( | ||
model_name='petition', | ||
name='creation_date', | ||
field=models.DateTimeField(blank=True), | ||
), | ||
migrations.AlterField( | ||
model_name='petition', | ||
name='last_modification_date', | ||
field=models.DateTimeField(blank=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters