Zero-Downtime Database Migrations for Cloud Apps: Expand-and-Contract Workflow and Rollback Checklist
database migrationszero downtimecloud databasesproduction releasesschema changes

Zero-Downtime Database Migrations for Cloud Apps: Expand-and-Contract Workflow and Rollback Checklist

RRealworld Cloud Editorial Team
2026-11-17
7 min read

Use this expand-and-contract checklist to plan, monitor, validate, and roll back zero-downtime database migrations for cloud apps.

Production schema changes do not have to mean downtime. This reusable checklist explains how to plan a zero-downtime database migration for a cloud app using the expand-and-contract workflow, compatibility testing, controlled backfills, observability, and a rollback plan that accounts for both code and data.

Overview

A safe cloud database schema migration is more than a migration file that runs successfully. The application, database, deployment pipeline, background workers, and rollback process must remain compatible while the change is in progress.

The most dependable general pattern is expand and contract:

  1. Expand: Add the new schema elements without removing or invalidating the old ones.
  2. Migrate: Deploy code that can work with both representations, then copy or transform existing data in controlled batches.
  3. Contract: After all readers, writers, workers, and rollback versions no longer depend on the old structure, remove it in a later release.

This separation reduces the risk of coupling a database operation to one application deployment. It also gives the team time to observe the change and stop before an irreversible step. The exact locking behavior, online index capabilities, transaction limits, and command syntax depend on the database engine, version, ORM, and managed cloud service, so verify those details in the environment where the migration will run.

Before starting, document the affected tables, expected row counts, write volume, traffic patterns, dependencies, maintenance constraints, and recovery objectives. If the application uses a managed database, review provider-specific limits and backup or restore procedures rather than assuming local development behavior will apply in production. For broader platform decisions, see the guide to cloud database options for web apps.

Checklist by scenario

Additive changes: new tables, columns, or nullable fields

Additive changes are often the simplest, but they still require compatibility planning.

  • Confirm the new table or column can be added without blocking important traffic for an unacceptable period.
  • Prefer a nullable column or a safe database default during the expand phase when existing rows are not yet populated.
  • Deploy schema changes before application code that reads or writes the new structure.
  • Release code that tolerates the field being absent, null, or not yet backfilled.
  • Measure write and read errors after deployment before enabling the feature broadly.

Column renames and type changes

A direct rename is risky because old and new application versions may use different names. Treat a rename as two fields or two representations until the transition is complete.

  • Add the replacement column without removing the original.
  • Update application writes so both columns are maintained, or use a carefully tested compatibility layer.
  • Backfill the replacement column in resumable batches.
  • Compare values, counts, null rates, and representative records between the old and new fields.
  • Switch reads to the replacement only after its completeness and correctness are measurable.
  • Keep dual writes long enough for the normal rollback window, then remove the old field in a separate release.

Backfills and data transformations

Do not treat a large backfill as an ordinary deployment step. Run it as an observable workload with a pause, resume, and stop mechanism.

  • Define the selection criteria and make the operation idempotent, so retries do not corrupt data.
  • Process bounded batches using a stable key or other predictable cursor.
  • Throttle concurrency and watch database CPU, memory, storage, locks, replication or failover health, query latency, and application error rates.
  • Record progress, including the last safe position and the number of successful and failed records.
  • Handle rows created or updated while the backfill is running through dual writes, a change queue, a second reconciliation pass, or another explicit strategy.
  • Validate totals and samples before switching production reads.

Index creation and constraint changes

Index operations can affect latency and locking even when the final result is read-only. Check whether the engine and service support an online or concurrent form, what restrictions apply, and how cancellation behaves.

  • Review the query plan and confirm the index addresses a real access pattern.
  • Test the operation against production-like data volume and write activity.
  • Use a migration mode that matches the database engine and version, not a generic ORM default.
  • Set an operational timeout or cancellation procedure where supported.
  • Verify the index is valid and being considered by the optimizer before removing an older index.

Destructive changes

Dropping a column, table, index, or constraint is the contract phase and should be delayed. A successful application deployment does not prove that an old field is unused; ad hoc scripts, reporting jobs, workers, and older running instances may still depend on it.

  • Search application code, jobs, dashboards, integrations, and operational scripts for references.
  • Confirm all deployed versions and rollback candidates are compatible with removal.
  • Take or verify a recoverable backup according to the application’s recovery plan.
  • Perform the removal as a separate, explicitly approved change.
  • Keep evidence of validation and the responsible operator’s approval.
ChangeTypical compatibilitySafer approach
Add nullable columnUsually additiveExpand first; deploy tolerant code; populate later
Rename columnIncompatible if directDual fields or compatibility layer, backfill, then remove old field
Backfill dataOperationally variableIdempotent batches with throttling and progress tracking
Create indexDepends on engine and methodUse tested online or concurrent operation where supported
Drop column or tableDestructiveDelay until dependencies and rollback versions are cleared

What to double-check

Before the migration

  • Write down the intended end state, intermediate states, and the condition for moving between them.
  • Test the migration against a representative copy of production data, including large and unusual records.
  • Test old code with the expanded schema and new code with the pre-migration schema where that combination could occur during rollout.
  • Confirm the deployment system orders schema, application, worker, and feature-flag changes correctly.
  • Verify credentials, secrets, connection limits, maintenance windows, and database storage capacity.
  • Confirm backups exist and that a restore has been tested in an environment appropriate to the risk.

During the migration

  • Watch migration duration, lock waits, blocked sessions, query latency, error rates, connection pool saturation, and replication or failover indicators.
  • Use a feature flag to separate deployment from user exposure when the change supports it.
  • Keep the migration operator and application owner aligned on stop conditions.
  • Pause or reduce the batch size if normal application traffic shows degradation.

Centralize these signals in the same operational view used for application health. The cloud application monitoring checklist provides a useful framework for connecting metrics, logs, traces, and alert thresholds. Your rollback plan should also distinguish between reversing code, stopping a backfill, restoring a field’s previous behavior, and restoring the database itself. A database restore may lose newer writes or require application coordination, so it is not automatically the first response to a failed migration.

Common mistakes

  • Combining expand and contract in one release: This removes the compatibility window needed for rolling deployments and rollback.
  • Assuming a migration tool guarantees safety: ORM-generated SQL still needs review for locks, transactions, defaults, and engine-specific behavior.
  • Running an unthrottled backfill: A logically correct script can compete with customer traffic for resources.
  • Forgetting non-application consumers: Reports, exports, scheduled jobs, data pipelines, and support scripts may use the old schema.
  • Testing only on an empty database: Lock duration and scan cost can change materially with realistic volume and indexes.
  • Calling rollback a single command: Some schema changes are reversible in code but not safely reversible in data.
  • Removing dual writes too early: A delayed worker or older application instance may still need the old representation.

For deployment sequencing and release gates, compare the migration plan with your CI/CD pipeline design. If the release fails for reasons outside the schema change, the cloud deployment troubleshooting guide can help separate application rollback from database recovery.

When to revisit

Revisit this checklist before every production schema release, especially before seasonal planning cycles, traffic changes, large backfills, database engine upgrades, ORM upgrades, or a move to a different managed cloud database. Recheck it when deployment workflows, worker architecture, connection pooling, backup configuration, or provider capabilities change.

After each migration, record what happened: actual lock duration, backfill throughput, resource impact, alerts triggered, validation results, and whether the rollback rehearsal matched reality. Turn those observations into updated stop conditions and runbooks.

Action checklist: identify the compatibility window, expand first, test with realistic data, deploy tolerant code, run backfills in controlled batches, monitor the database and application together, rehearse rollback, delay destructive cleanup, and document the evidence before closing the change. That process makes a zero-downtime database migration a repeatable cloud operations practice rather than a one-time gamble.

Related Topics

#database migrations#zero downtime#cloud databases#production releases#schema changes
R

Realworld Cloud Editorial Team

Cloud Infrastructure Editor

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.