A safe database migration is less about running one command and more about controlling compatibility, locks, data movement, observability, and recovery. This reusable database migration checklist helps you plan, test, deploy, and review schema changes while reducing the risk of downtime or data loss.
Overview
Schema changes affect more than the database. They can change application queries, API responses, background jobs, reports, backups, replicas, and operational dashboards. Before approving a migration, identify every component that reads or writes the affected tables and decide how the old and new versions will coexist during deployment.
The safest default is usually a backward-compatible change: add the new structure first, deploy application code that can work with both versions, migrate or backfill data, and remove the old structure only after it is no longer used. This pattern is often called an expand-and-contract migration.
Database engines and migration frameworks differ significantly. Transaction behavior, metadata locks, online index operations, statement timeouts, replication, and DDL rollback support vary by engine and configuration. Treat examples as planning guidance, then confirm the behavior for your exact database version, hosting environment, and migration tool.
For related operational checks, pair this guide with a SQL query debugging checklist before and after a migration. If the change affects an API payload, review it alongside an OpenAPI specification review so database compatibility and client compatibility are considered together.
Checklist by scenario
For additive, backward-compatible changes
Adding a nullable column, a new table, or a non-enforced structure is often lower risk than changing or removing an existing object, but it still requires verification.
- Write down the intended schema change and the application versions that will use it.
- Confirm that the new column, table, or index has suitable defaults, nullability, and naming.
- Check whether the database will scan, rewrite, or lock existing data while applying the change.
- Deploy the schema before deploying code that depends on it.
- Verify that older application instances continue to function during a rolling deployment.
- Measure migration duration and lock behavior on a production-sized dataset, not only a local database.
For expand-and-contract migrations
Use this approach when a column, data type, relationship, or representation must change while the application remains available.
- Expand: add the new column, table, index, or relationship without removing the old path.
- Deploy compatible code: make reads and writes work with both structures. Dual writes should have clear error handling and monitoring.
- Backfill: copy existing data in controlled batches, using a stable key or other deterministic range.
- Validate: compare counts, null rates, checksums, samples, or business-level invariants between old and new data.
- Switch reads: move traffic to the new representation gradually where practical.
- Stop legacy writes: confirm that all application versions and jobs no longer depend on the old structure.
- Contract: remove the old column, table, index, or compatibility code in a separate, monitored change.
Do not combine every step into one deployment unless the dataset, workload, and rollback plan make that genuinely safe. Separating expansion, backfill, cutover, and cleanup gives you more points at which to pause or investigate.
For indexes and performance-related changes
- Inspect the query patterns the index is intended to support and confirm that the column order is appropriate.
- Check index size, write overhead, storage capacity, and replication impact.
- Determine whether the engine supports an online or concurrent index operation and what locks it may still take.
- Use an appropriate statement timeout or cancellation strategy where supported.
- Monitor query latency, lock waits, CPU, memory, storage, replication lag, and error rates during creation.
- Remove redundant indexes only after observing workload behavior and confirming that no less-obvious query depends on them.
An index that improves one query can increase write cost or compete for resources with application traffic. Treat it as a production workload change, not merely a metadata edit.
For destructive or incompatible changes
Renaming or dropping a column, tightening a constraint, changing a data type, or altering a relationship requires stronger coordination.
- Search application code, scheduled jobs, reporting queries, integrations, and administrative scripts for references.
- Confirm that old binaries, workers, and replicas cannot still issue incompatible queries.
- Capture a backup or other verified recovery point appropriate to the data and recovery objectives.
- Prefer a staged replacement over an in-place rewrite when the operation could lock or rewrite a large table.
- Define whether failure should result in rollback, a paused deployment, or a forward fix.
- Remove obsolete structures only after a documented observation period.
| Change type | Typical risk | Preferred approach |
|---|---|---|
| Add nullable column or table | Low to medium | Apply first, then deploy compatible code |
| Create large index | Medium to high | Test lock behavior and use an online option where suitable |
| Backfill existing rows | Medium to high | Batch, throttle, resume, and monitor |
| Change type or constraint | High | Validate data and stage the transition |
| Drop column or table | High | Prove no consumers remain, then remove separately |
What to double-check before deployment
Locks and transaction behavior
Find out which locks the migration requests, how long they can be held, and what happens when another transaction blocks it. A migration that is fast on an idle database may wait behind a long-running query and then block application traffic. Check idle transactions, connection pool behavior, lock timeouts, and whether the migration framework wraps multiple statements in one transaction.
Some DDL operations can be rolled back; others may commit implicitly or leave partial effects depending on the engine and command. Never assume that a failed migration automatically returns the database to its previous state.
Backups and recovery
- Confirm that the latest backup completed successfully.
- Verify that restoration procedures are documented and tested, rather than relying on the existence of a backup file.
- Record the recovery point and the expected recovery time for this change.
- Know whether point-in-time recovery, replicas, snapshots, or logical exports are available in the deployment environment.
- Separate database recovery from application rollback; restoring data can discard valid writes made after the recovery point.
Backfills and data quality
Run backfills in small, resumable batches. Choose a stable ordering key, commit regularly, and make the job safe to retry. Throttle it when it competes with interactive traffic, and pause it if lock waits, replication lag, or error rates exceed agreed limits.
Before starting, define validation rules: row counts, required fields, permitted values, referential integrity, or business totals. After the backfill, compare old and new representations and investigate discrepancies instead of treating completion as proof of correctness.
Application compatibility and observability
Test the migration with the versions that may coexist during rollout. Include web processes, workers, cron jobs, reporting tools, admin commands, and external integrations. Add or confirm dashboards for migration progress, database errors, latency, lock waits, connection usage, storage, and replication health.
Keep the migration output, start and finish times, code revision, database version, and operator decisions in the deployment record. If the change affects user-facing behavior, define a concrete success signal before release.
Common mistakes
- Testing only on a small dataset: table size, row distribution, indexes, and concurrent traffic can change execution behavior.
- Assuming a migration is atomic: confirm transaction and DDL semantics for the actual engine and commands.
- Deploying code before the schema: rolling deployments can leave older instances unable to understand the new code path.
- Running an unthrottled backfill: a logically correct job can still exhaust I/O, CPU, connections, or replication capacity.
- Using a backup as the only rollback plan: restore operations may be slow and can overwrite legitimate writes.
- Dropping old structures immediately: delayed jobs, forgotten scripts, and older application instances may still use them.
- Ignoring migration observability: without lock, latency, and progress signals, operators discover trouble too late.
- Confusing rollback with roll-forward: a failed schema change may be safer to correct with a new compatible migration than to reverse in place.
For deployments that also change containers or build artifacts, review the Dockerfile optimization and troubleshooting guide. Keeping application packaging and database compatibility visible in the same release plan reduces surprises during rollout.
When to revisit
Use this checklist before every production schema change, not only before large releases. Revisit the plan when the database engine, hosting provider, migration framework, ORM, connection proxy, replication topology, or deployment strategy changes. Engine upgrades can alter DDL locking, index behavior, transaction support, and available online operations, so revalidate assumptions rather than copying an older runbook unchanged.
Schedule a review before seasonal traffic increases, major data imports, dependency upgrades, or planned infrastructure changes. After an incident, update the checklist with the observed failure mode, missing alert, unsafe command, or unclear ownership. Also review it after a successful migration if the team learned a more efficient batching, validation, or rollback procedure.
For the next migration, complete these actions:
- Describe the schema and application compatibility window.
- Classify the change as additive, backfill, index-related, incompatible, or destructive.
- Test it against production-like data and concurrency.
- Record lock, timeout, backup, monitoring, and recovery decisions.
- Choose rollback or roll-forward criteria before deployment begins.
- Deploy in observable stages, pause when signals deteriorate, and document the result.