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
+18 -7
+18 -7
View File
@@ -199,13 +199,24 @@ 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")
sql_statement = call_command( try:
"sqlmigrate", sql_statement = call_command(
app_label, "sqlmigrate",
migration_name, app_label,
database=self.database, migration_name,
stdout=dev_null, database=self.database,
) 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):