From 59372a01d2178616796379f4fe1cb76d9083eced Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Mon, 13 Dec 2021 16:34:36 -0500 Subject: [PATCH] Add migration for `en` to `en-US` language setting Fixes #337 --- .../0020_update_language_en_to_en_us.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 babybuddy/migrations/0020_update_language_en_to_en_us.py diff --git a/babybuddy/migrations/0020_update_language_en_to_en_us.py b/babybuddy/migrations/0020_update_language_en_to_en_us.py new file mode 100644 index 00000000..f9fe34d7 --- /dev/null +++ b/babybuddy/migrations/0020_update_language_en_to_en_us.py @@ -0,0 +1,30 @@ +# Generated by Django 3.2.9 on 2021-12-13 21:25 + +from django.db import migrations + + +def update_language_en_to_en_us(apps, schema_editor): + Settings = apps.get_model('babybuddy', 'Settings') + for settings in Settings.objects.all(): + if settings.language == 'en': + settings.language = 'en-US' + settings.save() + + +def update_language_en_us_to_en(apps, schema_editor): + Settings = apps.get_model('babybuddy', 'Settings') + for settings in Settings.objects.all(): + if settings.language == 'en-US': + settings.language = 'en' + settings.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('babybuddy', '0019_alter_settings_timezone'), + ] + + operations = [ + migrations.RunPython(update_language_en_to_en_us, reverse_code=update_language_en_us_to_en), + ]