Skip to content

CICD-314 · Migration rollback validation ​

Encyclopedia · Database delivery and migration · All snippets

Previous · CICD-313 · Next · CICD-315

1. Where it fits ​

  • Placement CI disposable migration job.
  • Prerequisites disposable database, migration tools and a scoped database role.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
alembic upgrade head
alembic downgrade -1
alembic upgrade head
pytest -q tests/migrations

3. How it works ​

The migration CLI compares the configured revision graph with the target database and applies or checks the selected revisions. Pytest discovers the selected test files or markers and returns a process exit status reflecting the test outcome.

4. Verify the result ​

Use a fixture with realistic data and explicit downgrade boundaries. A destructive downgrade can be unacceptable even if it succeeds syntactically.

Validation syntax-validated (Bash parse). Status definitions.