From 3a9568b4d4de969b1e2031e8d2d3cdd7bd56824f Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 15 Jan 2020 13:59:31 -0800 Subject: [PATCH] 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. --- zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py b/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py index 2734253173..148a37668c 100644 --- a/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py +++ b/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py @@ -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")