Skip to content

Add pytest-mrt under Testing > Database Migration Testing#3187

Open
croc100 wants to merge 1 commit into
vinta:masterfrom
croc100:add-pytest-mrt
Open

Add pytest-mrt under Testing > Database Migration Testing#3187
croc100 wants to merge 1 commit into
vinta:masterfrom
croc100:add-pytest-mrt

Conversation

@croc100
Copy link
Copy Markdown

@croc100 croc100 commented Jun 6, 2026

What is pytest-mrt?

pytest-mrt is a pytest plugin and CLI tool that verifies Alembic and Django database migrations are safely reversible.

It catches rollback failures before they reach production:

  • Detects missing or no-op `downgrade()` implementations
  • Verifies schema is fully restored after rollback
  • Seeds real rows and confirms data survives the round-trip
  • Static analysis for 44 patterns across Alembic and Django (`DROP TABLE`, `RemoveField`, `RunSQL` without reverse, and more)
  • `# noqa: MRTxxx` per-line suppression (ruff/flake8 convention)
  • 6 built-in default tests auto-injected with zero config

Why a new "Database Migration Testing" subsection?

There is no existing category for database migration testing tools. Migration rollback safety is a real, common pain point — many teams have been burned by `downgrade()` functions that look correct but silently fail. This is a distinct niche from general testing frameworks or database drivers.

Requirements met

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant