Group
  • Database

    Test migration rollbacks before you need them

    Verifies every migration has a working down path and that rollbacks actually run clean against realistic data.

    • Plan & validate
    • Improve quality
    • Advanced
    • General

Free Prompt

Audit my migrations for rollback safety. List every migration in the project and check whether each has a working down/rollback path. For each migration: write or fix the down migration so it reverses the up migration; flag the irreversible ones explicitly (dropped columns, destructive transforms) and document what manual recovery would require for those; and check ordering hazards, like a rollback that drops a table other migrations later depend on. Then actually run the full cycle against a scratch database seeded with realistic data: migrate all the way up, then roll back one step at a time, confirming each down migration runs without errors and leaves the schema in the expected state. Don't rewrite the history of migrations that have already run in any environment; if an old migration is broken, write the fix as documentation or a corrective migration, not an edit. Don't fake the rollback of destructive changes by restoring nothing; call them irreversible instead. Deliver: rollback status per migration (working, fixed, irreversible), the corrected down migrations, and verification: the up-then-down cycle output on the scratch database showing a clean result.

What This Does / How This Helps

Proves you can undo a migration, which is the difference between a bad deploy being a five-minute rollback and a bad deploy being a weekend of manual data repair. Almost nobody tests down migrations until they need one in an emergency, which is exactly when they discover the down path was never written, has a typo, or can't work because the migration destroyed data. Finding that out calmly, pre-launch, is the entire point. Irreversible migrations are fine as long as they're labeled. The deliverable tells you which deploys you can safely roll back and which ones need a real backup first.

Want to skip doing this by hand?

Fortivibe audits your app for all of the areas these prompts cover (and more).

See What We Check

Related Prompts