From 959e8ac458a0379636df15ff851e30f0096f8bff Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 28 Nov 2023 13:59:50 +0100 Subject: 🐛 Instance Profile - fix migration: provide default for complete id and cached label (refs #5674) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0231_set_default_profile_value.py | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ishtar_common/migrations/0231_set_default_profile_value.py (limited to 'ishtar_common') diff --git a/ishtar_common/migrations/0231_set_default_profile_value.py b/ishtar_common/migrations/0231_set_default_profile_value.py new file mode 100644 index 000000000..2e77e5c7f --- /dev/null +++ b/ishtar_common/migrations/0231_set_default_profile_value.py @@ -0,0 +1,30 @@ +# Generated by Django 2.2.24 on 2023-11-28 13:21 + +from django.db import migrations + + +def set_default_profile_value(apps, __): + model = apps.get_model("ishtar_common", "ishtarsiteprofile") + attrs = ["operation_complete_identifier", "operation_cached_label", + "contextrecord_cached_label", "parcel_cached_label", + "find_cached_label"] + for profile in model.objects.all(): + changed = False + for attr in attrs: + if not getattr(profile, attr): + field = model._meta.get_field(attr) + setattr(profile, attr, field.get_default()) + changed = True + if changed: + profile.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('ishtar_common', '0230_auto_20231114_1334'), + ] + + operations = [ + migrations.RunPython(set_default_profile_value) + ] -- cgit v1.2.3