A database migration can fail even when application code is correct. This reusable deployment checklist explains how to plan backward-compatible schema changes, reduce locking risk, test migrations in CI/CD, protect backups, verify production results, and handle rollback limits during zero-downtime web app releases.
Overview
Safe database migration deployment is less about running a framework command and more about coordinating three independently changing components: the database schema, the application code, and the data already stored in production. A migration is ready when each component can tolerate the others during the transition.
For most web applications, the safest pattern is an expand-and-contract migration. First, expand the schema in a backward-compatible way. Then deploy code that can work with both the old and new shape. After the new path is confirmed, migrate or backfill data. Finally, remove obsolete columns, constraints, indexes, or code in a later release.
This approach supports zero-downtime database migrations because old application instances and new instances can overlap during a rolling deployment. It does not guarantee that every migration is risk-free: large backfills, table rewrites, exclusive locks, replication lag, and insufficient database capacity can still interrupt service. Treat zero downtime as a release objective that requires testing and observability, not as a property of a migration tool.
Before using this checklist, record the database engine and version, migration framework, deployment strategy, table sizes, traffic patterns, replica layout, backup and restore process, and the expected duration of each operation. The details vary between managed databases and self-managed systems, so confirm behavior in the documentation for the exact versions you operate.
For broader release sequencing, pair this runbook with The Complete CI/CD Pipeline Checklist for Web and Mobile App Releases and the Web App Database Migration Checklist.
Checklist by scenario
Scenario 1: Adding a nullable column or table
- Write down the intended schema change and its compatibility window.
- Add the new column as nullable, or provide a database-supported default that will not cause an expensive table rewrite.
- Create a new table with indexes and constraints that can be built safely for the database engine.
- Deploy the schema change separately from the application code that depends on it.
- Confirm that old application instances continue to read and write successfully.
- Only make the field required after all writers populate it reliably and existing rows have been checked.
A new column is usually the simplest migration, but the operational risk depends on how the database implements defaults, indexes, and locking. Review the generated SQL instead of relying only on the migration file name.
Scenario 2: Renaming or replacing a column
- Add the replacement column without removing the original.
- Update application reads to prefer the new column while retaining a fallback if needed.
- Write to both columns during the transition, preferably through one well-tested code path.
- Backfill historical rows in bounded batches, with pauses or rate limits where appropriate.
- Compare values in both columns and investigate mismatches.
- Stop dual writes only after all application versions and background workers use the replacement.
- Remove the old column in a later release after confirming that no queries, reports, jobs, or integrations depend on it.
This is a classic expand-and-contract sequence. A direct rename can break an older application instance, an unredeployed worker, or a reporting process that was not included in the main repository.
Scenario 3: Adding a non-null constraint or unique rule
- Measure how many existing rows violate the proposed rule.
- Deploy validation or cleanup code before enforcing the constraint.
- Backfill missing values using deterministic, auditable logic.
- Check for duplicates before creating a unique index.
- Where supported, create the index or constraint using an online or concurrent method appropriate to the database engine.
- Schedule enforcement only after application writes satisfy the rule.
Do not assume that a validation query is harmless on a busy production table. Test its query plan and resource use, and consider running it against a replica or a controlled production-like dataset before release.
Scenario 4: Large data backfill
- Separate the schema change from the backfill job.
- Process rows in bounded batches using a stable key or carefully selected range.
- Make the job resumable and idempotent so it can restart without corrupting data.
- Track progress, error counts, elapsed time, replication lag, lock waits, and database load.
- Set a stop condition and define who can pause or terminate the job.
- Run the backfill outside the most sensitive traffic window when practical.
A migration that starts quickly can still become an outage if it competes with application queries for I/O, CPU, locks, or connection capacity. Treat backfills as production workloads with their own rollout plan.
Scenario 5: Removing a column, index, or old table
- Search application code, background jobs, dashboards, analytics queries, scripts, and external consumers for references.
- Confirm that all deployed application versions no longer require the object.
- Disable or remove obsolete writes before dropping the object.
- Capture a final usage check and retain a recovery plan.
- Drop the object in a separate release, preferably after an observation period.
Destructive changes are often difficult to roll back because the removed data or structure may not be recoverable from application code alone. Prefer postponing destruction over trying to reverse it during an incident.
What to double-check
Migration SQL and locking behavior
Inspect the SQL generated by your migration tool. Look for operations that may acquire an exclusive lock, scan the entire table, rebuild an index, rewrite rows, or wait behind a long-running transaction. Verify whether the database supports online, concurrent, or metadata-only alternatives and what restrictions those alternatives impose.
Backups and restore readiness
Confirm that a recent backup exists, that it completed successfully, and that the retention window covers the release and investigation period. A backup is not a rollback plan until the team knows how to restore it, how long restoration may take, and whether the resulting data is consistent with application expectations. For higher-risk changes, perform a restore rehearsal in a non-production environment and record the steps.
Application compatibility
Test mixed-version operation: run the old application version against the expanded schema, then run the new version against the same schema. Include web processes, workers, scheduled jobs, admin tools, and services that share the database. If a mobile client or third-party integration can remain on an older version, account for that compatibility window as well. Changes to externally visible data contracts may also require an API versioning plan; see the API Versioning and Deprecation Guide.
CI/CD controls
- Lint or validate migration files before merge.
- Run migrations against an ephemeral or disposable database in CI.
- Test upgrade paths from a representative prior schema, not only from an empty database.
- Use production-like data volume for operations whose cost depends on table size.
- Require review for destructive changes, long-running backfills, and permission changes.
- Make the deployment pipeline report migration start, completion, failure, and duration.
- Keep application rollout and migration rollout separately observable.
Verification queries and health signals
Prepare verification before deployment. Examples include counting null values in a newly required column, comparing old and new fields, checking duplicate keys, confirming index or constraint presence, and measuring the number of rows processed by a backfill. Also monitor error rates, latency, connection saturation, lock waits, replication lag, queue depth, and background job failures. A green migration command does not prove that application behavior is correct.
Common mistakes
- Combining expansion and destruction in one release. Adding a replacement column and dropping the original together removes the compatibility window needed for rolling deployments.
- Running an unbounded backfill inside the migration transaction. A transaction that remains open for a long time can hold locks, increase bloat, and make failure recovery harder.
- Testing only with an empty database. Empty schemas do not reveal table-scan duration, duplicate data, lock contention, or storage growth.
- Assuming rollback reverses everything. Application rollback may be safe while schema rollback is unsafe, especially after data has been transformed or columns have been removed.
- Ignoring workers and scheduled jobs. A worker can keep writing the old shape after the web deployment appears complete.
- Creating indexes without checking operational impact. Index creation can consume resources or block writes depending on the engine and chosen method.
- Skipping an incident decision tree. Define in advance when to pause a migration, disable a feature flag, stop a backfill, scale database capacity, or halt the deployment.
For integrations that consume changed records or events, also check retry and replay behavior. The guidance in Reliable Webhook Integrations is relevant when a schema change affects event payloads or delivery workers.
When to revisit
Use this checklist before every schema change, release candidate, and failed migration review. Revisit it before seasonal planning cycles or any period when traffic, batch activity, or support capacity differs from normal. Update the runbook when your database engine, managed-database provider, migration framework, deployment strategy, backup process, or observability tools change.
After each significant migration, record the actual lock time, backfill rate, resource impact, verification results, and any manual intervention. Replace estimates with those observations in the next release plan. If a migration caused an incident or near miss, add the missing control to the checklist rather than relying on team memory.
Before approving the next deployment, ask five final questions: Is the schema change backward-compatible? Can the operation be paused? Is a tested recovery path available? Do monitoring and verification queries cover the main failure modes? Have all application versions, workers, and external consumers been considered? If any answer is unclear, reduce the change into smaller phases and test again.