diff options
| author | 2022-08-04 09:29:05 +0100 | |
|---|---|---|
| committer | 2022-08-04 09:29:05 +0100 | |
| commit | 1122f5abfccffb99c86673c0ed23ac6713dc3c99 (patch) | |
| tree | fed9ef2740c58f02d07aed10fe0c8c509a17d848 /pydis_site/apps/api/migrations | |
| parent | Run Migrations For Tests (diff) | |
| parent | Merge pull request #751 from python-discord/add-infraction-last-applied (diff) | |
Merge branch 'main' into speedup-tests
Diffstat (limited to 'pydis_site/apps/api/migrations')
| -rw-r--r-- | pydis_site/apps/api/migrations/0084_infraction_last_applied.py | 26 | 
1 files changed, 26 insertions, 0 deletions
diff --git a/pydis_site/apps/api/migrations/0084_infraction_last_applied.py b/pydis_site/apps/api/migrations/0084_infraction_last_applied.py new file mode 100644 index 00000000..7704ddb8 --- /dev/null +++ b/pydis_site/apps/api/migrations/0084_infraction_last_applied.py @@ -0,0 +1,26 @@ +# Generated by Django 4.0.6 on 2022-07-27 20:32 + +import django.utils.timezone +from django.db import migrations, models +from django.apps.registry import Apps + + +def set_last_applied_to_inserted_at(apps: Apps, schema_editor): +    Infractions = apps.get_model("api", "infraction") +    Infractions.objects.all().update(last_applied=models.F("inserted_at")) + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('api', '0083_remove_embed_validation'), +    ] + +    operations = [ +        migrations.AddField( +            model_name='infraction', +            name='last_applied', +            field=models.DateTimeField(default=django.utils.timezone.now, help_text='The date and time of when this infraction was last applied.'), +        ), +        migrations.RunPython(set_last_applied_to_inserted_at) +    ]  |