Database Operations
Database Migration Rollback Guide
Plan database migration rollback with expand-contract changes, compatibility windows, data backfills, evidence gates and forward-fix options. This reference is written for developers who need practical validation behavior, reviewable rules and safe examples rather than copied snippets with no explanation.
Recommended workflow
| Step | Why it matters |
|---|---|
| Classify reversibility | Separate additive schema changes from destructive data transformations and one-way backfills. |
| Create a compatibility window | Keep old and new application versions functional during rollout and rollback. |
| Define evidence gates | Use row counts, constraints, latency and error rates before advancing phases. |
| Choose rollback or forward fix | Document when restoring code is safer than reversing data changes. |
Starter snippet
expand -> dual-compatible deploy -> backfill -> verify -> contractReview checks
- Back up affected data before destructive steps.
- Test lock duration on production-like volume.
- Make backfills resumable and observable.
- Assign an explicit stop decision owner.
Common mistakes
- Combining column removal with the first code deploy.
- Assuming down migrations restore deleted data.
- Running an unbounded update in one transaction.
Validation should help users correct input while protecting systems from bad data. Keep syntax checks, product policy, security review and deliverability checks separate.
Related Formalint references
Continue with Deployment Rollback Checklist, Release Checklist For Developers, Database Backup Restore Verification.