diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-11-28 13:59:50 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-11-28 13:59:50 +0100 | 
| commit | 959e8ac458a0379636df15ff851e30f0096f8bff (patch) | |
| tree | 57a7939b44912642cca59f3c9a157e9fd98ac57f /ishtar_common/migrations | |
| parent | 81be8409742e3a3939b3c90311550d208bcf42e1 (diff) | |
| download | Ishtar-959e8ac458a0379636df15ff851e30f0096f8bff.tar.bz2 Ishtar-959e8ac458a0379636df15ff851e30f0096f8bff.zip | |
🐛 Instance Profile - fix migration: provide default for complete id and cached label (refs #5674)
Diffstat (limited to 'ishtar_common/migrations')
| -rw-r--r-- | ishtar_common/migrations/0231_set_default_profile_value.py | 30 | 
1 files changed, 30 insertions, 0 deletions
| 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) +    ] | 
