Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
migrations: Add migration to migrate pronouns custom profile fields.
Sahil Batrab2737b0878aa
diff --git a/zerver/migrations/0421_migrate_pronouns_custom_profile_fields.py b/zerver/migrations/0421_migrate_pronouns_custom_profile_fields.pynew file mode 100644index 00000000000..9475f9468af--- /dev/null+++ b/zerver/migrations/0421_migrate_pronouns_custom_profile_fields.py@@ -0,0 +1,42 @@+# Generated by Django 4.1.2 on 2022-10-21 06:31++from django.db import migrations+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor+from django.db.migrations.state import StateApps+++def migrate_pronouns_custom_profile_fields(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:+ CustomProfileField = apps.get_model("zerver", "CustomProfileField")+ SHORT_TEXT = 1+ PRONOUNS = 8++ CustomProfileField.objects.filter(field_type=SHORT_TEXT, name__icontains="pronoun").update(+ field_type=PRONOUNS+ )+++def reverse_migrate_pronouns_custom_profile_fields(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:+ CustomProfileField = apps.get_model("zerver", "CustomProfileField")+ SHORT_TEXT = 1+ PRONOUNS = 8++ CustomProfileField.objects.filter(field_type=PRONOUNS).update(field_type=SHORT_TEXT)+++class Migration(migrations.Migration):++ dependencies = [+ ("zerver", "0420_alter_archivedmessage_realm_alter_message_realm"),+ ]++ operations = [+ migrations.RunPython(+ migrate_pronouns_custom_profile_fields,+ reverse_code=reverse_migrate_pronouns_custom_profile_fields,+ elidable=True,+ ),+ ]