From 446437c7bc65f54e904d7c943e134ac62859d12d Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Tue, 26 Sep 2023 10:25:17 +0200 Subject: [PATCH] Init command in migration --- .../migrations/0057_alter_tender_siae_transactioned.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lemarche/tenders/migrations/0057_alter_tender_siae_transactioned.py b/lemarche/tenders/migrations/0057_alter_tender_siae_transactioned.py index 2399f9200..d53d06f1c 100644 --- a/lemarche/tenders/migrations/0057_alter_tender_siae_transactioned.py +++ b/lemarche/tenders/migrations/0057_alter_tender_siae_transactioned.py @@ -3,6 +3,13 @@ from django.db import migrations, models +def set_siae_transactioned_false_to_null(apps, schema_editor): + Tender = apps.get_model("tenders", "Tender") + for tender in Tender.objects.filter(siae_transactioned=False, survey_transactioned_answer=None): + tender.siae_transactioned = None + tender.save(update_fields=["siae_transactioned"]) + + class Migration(migrations.Migration): dependencies = [ ("tenders", "0056_alter_tender_scale_marche_useless"), @@ -19,4 +26,5 @@ class Migration(migrations.Migration): verbose_name="Abouti à une transaction avec une structure", ), ), + migrations.RunPython(code=set_siae_transactioned_false_to_null), ]