Catch exception if sqlmigrate fails

Because of missing constraint that Django cannot find and therefore drop.
This commit is contained in:
David Wobrock committed 2019-07-30 10:47:20 +02:00
1 parent e408cd2c5e
commit a74a7497ad
1 file changed
+11
@@ -199,6 +199,7 @@ class MigrationLinter(object):
"Calling sqlmigrate command {} {}".format(app_label, migration_name) "Calling sqlmigrate command {} {}".format(app_label, migration_name)
) )
dev_null = open(os.devnull, "w") dev_null = open(os.devnull, "w")
try:
sql_statement = call_command( sql_statement = call_command(
"sqlmigrate", "sqlmigrate",
app_label, app_label,
@@ -206,6 +207,16 @@ class MigrationLinter(object):
database=self.database, database=self.database,
stdout=dev_null, stdout=dev_null,
) )
except ValueError:
logger.warning(
(
"Error while executing sqlmigrate on (%s, %s). "
"Continuing execution with empty SQL."
),
app_label,
migration_name,
)
sql_statement = ""
return sql_statement.splitlines() return sql_statement.splitlines()
def _gather_migrations_git(self, git_commit_id): def _gather_migrations_git(self, git_commit_id):