mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 18:43:52 +00:00
migrations: Fix deactivated realm corner cases with 0108.
Previously the default-string-id migration would not correctly handle ignoring deactivated realms.
This commit is contained in:
@@ -8,12 +8,12 @@ from django.db.migrations.state import StateApps
|
||||
def fix_realm_string_ids(apps, schema_editor):
|
||||
# type: (StateApps, DatabaseSchemaEditor) -> None
|
||||
Realm = apps.get_model('zerver', 'Realm')
|
||||
if Realm.objects.count() != 2:
|
||||
if Realm.objects.filter(deactivated=False).count() != 2:
|
||||
return
|
||||
|
||||
zulip_realm = Realm.objects.get(string_id="zulip")
|
||||
try:
|
||||
user_realm = Realm.objects.exclude(id=zulip_realm.id)[0]
|
||||
user_realm = Realm.objects.filter(deactivated=False).exclude(id=zulip_realm.id)[0]
|
||||
except Realm.DoesNotExist:
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user