diff --git a/src/agenda_culturel/migrations/0107_strip_aliases.py b/src/agenda_culturel/migrations/0107_strip_aliases.py new file mode 100644 index 0000000..8724346 --- /dev/null +++ b/src/agenda_culturel/migrations/0107_strip_aliases.py @@ -0,0 +1,30 @@ +# Generated by Django 4.2.9 on 2024-11-10 21:25 + +from django.db import migrations + + +def strip_place_aliases(apps, schema_editor): + Place = apps.get_model("agenda_culturel", "Place") + + places = Place.objects.all() + + for p in places: + if not p.aliases is None: + p.aliases = [a.strip() for a in p.aliases] + + Place.objects.bulk_update(places, fields=["aliases"]) + + + +def do_nothing(apps, schema_editor): + pass + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0106_alter_event_other_versions'), + ] + + operations = [ + migrations.RunPython(strip_place_aliases, reverse_code=do_nothing) + ]