initialize_voyager_db: Do nothing if a realm already exists.

This should help avoid confusing error messages for anyone
accidentally running this twice.

In particular, this also makes it easier to run Zulip inside
Kubernetes, since one doesn't need to worry about duplicate calls.
This commit is contained in:
Tim Abbott 2018-05-17 11:35:17 -07:00
parent 104fdd8bf9
commit d4119d0198
1 changed files with 3 additions and 0 deletions

View File

@ -30,6 +30,9 @@ class Command(BaseCommand):
help='The number of extra users to create')
def handle(self, *args: Any, **options: Any) -> None:
if Realm.objects.count() > 0:
print("Database already initialized; doing nothing.")
return
realm = Realm.objects.create(string_id=settings.INTERNAL_BOT_DOMAIN.split('.')[0])
names = [(settings.FEEDBACK_BOT_NAME, settings.FEEDBACK_BOT)]