Database Migration Code Review: Ensuring Zero-Downtime Deployments

Schema changes are among the riskiest deploys. A review process tuned for zero downtime ensures migrations land safely even on billion row tables. Use this checklist to evaluate database changes before they ship.
Establish the Migration Plan
Every migration PR should include a multi-step rollout plan detailing pre-deploy checks, the main change, and post-deploy cleanup. Ask the author:
- Is the migration online or does it require maintenance windows?
- How will we roll back if the change fails mid-flight?
- What metrics signal success or failure immediately after release?
Safe Change Patterns
- Add columns as nullable with defaults, then backfill asynchronously.
- Use expand-contract patterns: deploy new schema, dual write, migrate, then drop old.
- When removing columns, deploy code that stops reading them before dropping.
- Batch large data migrations to avoid long running transactions.
Backfill Strategy Review
Backfills should run in controllable chunks. Confirm:
- Backfill scripts throttle writes and include checkpoints.
- Jobs are idempotent and resume safely after failure.
- Impact on replicas and read replicas is understood.
Many teams use background jobs queued through event driven systems (see event architecture review guide) to control load.
Concurrency and Locking
During review, inspect whether the migration acquires heavy locks. For PostgreSQL, adding default values or altering column types can trigger table rewrites. Ask for explicit mention of lock type and expected duration. Tools like pt-online-schema-change or gh-ost may be needed for MySQL.
Testing the Migration
Require more than unit tests:
- Run migrations on staging with production-sized data snapshots.
- Automate smoke tests that verify read/write paths during migration.
- Include canary deployments to a subset of traffic before global rollout.
Observability Requirements
Reviewers should ensure dashboards cover:
- Replication lag, deadlocks, slow queries during migration.
- Application error rates and latency for queries hitting modified tables.
- Backfill progress metrics (rows migrated per minute, remaining rows).
Documentation and Runbooks
Require updated runbooks describing rollback and forward-fix steps. Capture links to feature flags or toggles controlling dual writes. Document how long the expanded schema must remain before cleanup to avoid surprises in future sprints.
Database migrations succeed when planned like product launches. By asking for explicit rollout steps, safe patterns, and monitoring, reviewers keep downtime near zero and protect data integrity. Pair this guide with our feature flag checklist to manage the application toggles that often accompany schema evolution.
Transform Your Code Review Process
Experience the power of AI-driven code review with Propel. Catch more bugs, ship faster, and build better software.


