diff --git a/lemarche/users/migrations/0037_rename_extra_data_last_year_key.py b/lemarche/users/migrations/0037_rename_extra_data_last_year_key.py new file mode 100644 index 000000000..ff07f7c9b --- /dev/null +++ b/lemarche/users/migrations/0037_rename_extra_data_last_year_key.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.13 on 2024-06-26 14:03 + +from django.db import migrations + + +def rename_extra_data_key_last_year(apps, schema_editor): + User = apps.get_model("users", "User") + for user in User.objects.all(): + if "nb_of_inclusive_provider_2022" in user.extra_data: + user.extra_data["nb_of_inclusive_provider_last_year"] = user.extra_data.pop( + "nb_of_inclusive_provider_2022" + ) + if "nb_of_handicap_provider_2022" in user.extra_data: + user.extra_data["nb_of_handicap_provider_last_year"] = user.extra_data.pop("nb_of_handicap_provider_2022") + + user.save() + + +class Migration(migrations.Migration): + dependencies = [ + ("users", "0036_remove_user_user_email_ci_uniqueness_and_more"), + ] + + operations = [ + migrations.RunPython(rename_extra_data_key_last_year, migrations.RunPython.noop), + ]