From 728121b1bbd549076943f75eda13ab276a75ccfb Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Mon, 6 Jun 2016 04:54:05 -0400 Subject: [PATCH] Add help message when initialsetup migration phase fails. GitLab issue #296. --- mayan/apps/common/management/commands/initialsetup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mayan/apps/common/management/commands/initialsetup.py b/mayan/apps/common/management/commands/initialsetup.py index f2e3a92084..13ddb77745 100644 --- a/mayan/apps/common/management/commands/initialsetup.py +++ b/mayan/apps/common/management/commands/initialsetup.py @@ -1,15 +1,20 @@ from __future__ import unicode_literals from django.core import management +from django.db.utils import OperationalError from ...signals import post_initial_setup class Command(management.BaseCommand): - help = 'Gets Mayan EDMS ready to be used.' + help = 'Initializes an install and gets it ready to be used.' def handle(self, *args, **options): management.call_command('createsettings', interactive=False) - management.call_command('migrate', interactive=False) + try: + result = management.call_command('migrate', interactive=False) + except OperationalError as exception: + self.stderr.write(self.style.NOTICE('Unable to migrate the database. The initialsetup command is to be used only on new installations. To upgrade existing installations use the performupgrade command.')) + raise management.call_command('createautoadmin', interactive=False) post_initial_setup.send(sender=self)