fix: migration runner continues on failure instead of aborting
All checks were successful
CI/CD / go-lint (push) Has been skipped
CI/CD / python-lint (push) Has been skipped
CI/CD / nodejs-lint (push) Has been skipped
CI/CD / test-go-ai-compliance (push) Successful in 32s
CI/CD / test-python-backend-compliance (push) Successful in 35s
CI/CD / test-python-document-crawler (push) Successful in 23s
CI/CD / test-python-dsms-gateway (push) Successful in 19s
CI/CD / validate-canonical-controls (push) Successful in 10s
CI/CD / Deploy (push) Successful in 2s

Previously, a single failed migration would abort all subsequent
migrations via raise RuntimeError. Now the runner logs the failure
and continues with remaining migrations, so independent schema
changes (e.g. 050-053) are not blocked by an unrelated failure
in an earlier migration (e.g. 048).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-03-14 21:54:08 +01:00
parent 5f8aebf5b1
commit d462141ccd

View File

@@ -79,6 +79,7 @@ def run_migrations():
logger.info("%d pending migrations (of %d total)", len(pending), len(migration_files))
failed = []
for migration_file in pending:
logger.info("Applying migration: %s", migration_file.name)
try:
@@ -96,11 +97,14 @@ def run_migrations():
except Exception as e:
raw_conn.rollback()
logger.error(" FAILED: %s%s", migration_file.name, e)
raise RuntimeError(
f"Migration {migration_file.name} failed: {e}"
) from e
failed.append((migration_file.name, str(e)))
# Continue with remaining migrations instead of aborting
logger.info("All migrations applied successfully")
if failed:
names = ", ".join(f[0] for f in failed)
logger.error("Some migrations failed: %s", names)
else:
logger.info("All migrations applied successfully")
finally:
raw_conn.close()