2017-08-24 04:49:28 +02:00
|
|
|
# Generated by Django 1.11.4 on 2017-08-24 02:39
|
|
|
|
from django.db import migrations
|
2022-05-27 23:33:51 +02:00
|
|
|
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
|
2017-09-25 15:45:52 +02:00
|
|
|
from django.db.migrations.state import StateApps
|
2017-08-24 04:49:28 +02:00
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2022-05-27 23:33:51 +02:00
|
|
|
def fix_realm_string_ids(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
Realm = apps.get_model("zerver", "Realm")
|
2017-10-20 18:22:35 +02:00
|
|
|
if Realm.objects.filter(deactivated=False).count() != 2:
|
2017-08-24 04:49:28 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
zulip_realm = Realm.objects.get(string_id="zulip")
|
|
|
|
try:
|
2017-10-20 18:22:35 +02:00
|
|
|
user_realm = Realm.objects.filter(deactivated=False).exclude(id=zulip_realm.id)[0]
|
2017-08-24 04:49:28 +02:00
|
|
|
except Realm.DoesNotExist:
|
|
|
|
return
|
|
|
|
|
|
|
|
user_realm.string_id = ""
|
|
|
|
user_realm.save()
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2017-08-24 04:49:28 +02:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-02-12 08:20:45 +01:00
|
|
|
("zerver", "0107_multiuseinvite"),
|
2017-08-24 04:49:28 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
2021-02-12 08:19:30 +01:00
|
|
|
migrations.RunPython(
|
|
|
|
fix_realm_string_ids, reverse_code=migrations.RunPython.noop, elidable=True
|
|
|
|
),
|
2017-08-24 04:49:28 +02:00
|
|
|
]
|