mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +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):
|
def fix_realm_string_ids(apps, schema_editor):
|
||||||
# type: (StateApps, DatabaseSchemaEditor) -> None
|
# type: (StateApps, DatabaseSchemaEditor) -> None
|
||||||
Realm = apps.get_model('zerver', 'Realm')
|
Realm = apps.get_model('zerver', 'Realm')
|
||||||
if Realm.objects.count() != 2:
|
if Realm.objects.filter(deactivated=False).count() != 2:
|
||||||
return
|
return
|
||||||
|
|
||||||
zulip_realm = Realm.objects.get(string_id="zulip")
|
zulip_realm = Realm.objects.get(string_id="zulip")
|
||||||
try:
|
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:
|
except Realm.DoesNotExist:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user