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
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:
@@ -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,10 +97,13 @@ 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
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user