Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
custom-profile-fields: Fix subtype of old twitter fields.
Sahil Batrad4a6c78424cb
diff --git a/zerver/migrations/0795_rename_old_twitter_profile_fields.py b/zerver/migrations/0795_rename_old_twitter_profile_fields.pynew file mode 100644index 00000000000..4f288ae66e9--- /dev/null+++ b/zerver/migrations/0795_rename_old_twitter_profile_fields.py@@ -0,0 +1,30 @@+import orjson+from django.db import migrations+from django.db.backends.base.schema import BaseDatabaseSchemaEditor+from django.db.migrations.state import StateApps+++def update_twitter_to_x(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:+ CustomProfileField = apps.get_model("zerver", "CustomProfileField")+ EXTERNAL_ACCOUNT = 7++ old_value = orjson.dumps({"subtype": "twitter"}).decode()+ new_value = orjson.dumps({"subtype": "x"}).decode()++ CustomProfileField.objects.filter(+ name="Twitter", field_type=EXTERNAL_ACCOUNT, field_data=old_value+ ).update(name="X username", field_data=new_value, hint="")+++class Migration(migrations.Migration):+ dependencies = [+ ("zerver", "0794_alter_directmessagegroup_recipient_and_more"),+ ]++ operations = [+ migrations.RunPython(+ update_twitter_to_x,+ reverse_code=migrations.RunPython.noop,+ elidable=True,+ ),+ ]