migrations: Fix zulipinternal migration corner case.

It's theoretically possible to have configured a Zulip server where
the system bots live in the same realm as normal users (and may have
in fact been the default in early Zulip releases?  Unclear.).  We
should handle these without the migration intended to clean up naming
for the system bot realm crashing.

Fixes #13660.
This commit is contained in:
Tim Abbott
2020-01-15 13:59:31 -08:00
parent aea369f878
commit 3a9568b4d4

View File

@@ -18,6 +18,10 @@ def rename_zulip_realm_to_zulipinternal(apps: StateApps, schema_editor: Database
if Realm.objects.filter(string_id="zulipinternal").exists():
return
if not Realm.objects.filter(string_id="zulip").exists():
# If the user renamed the `zulip` system bot realm (or deleted
# it), there's nothing for us to do.
return
internal_realm = Realm.objects.get(string_id="zulip")