All articles

DevOps

Automating Zero-Downtime Database Migrations in CI/CD

Nov 17, 2026 migrations · cicd · zero-downtime · devops · schema

Running database migrations as an entrypoint step inside application deployment pipelines is one of the most common causes of high-severity production incidents. When a deployment script holds exclusive metadata locks on a table receiving thousands of active queries per second, connection pools back up immediately, leading to cascading HTTP 504 timeouts across upstream services.

Achieving true zero-downtime schema evolution requires decoupling structural database changes from binary code deploys, enforcing automated linting in CI pipelines, and orchestrating non-blocking online schema change tools.

The Expand and Contract Migration Pattern

Never introduce breaking schema changes—such as renaming a column or changing a data type—in a single release. Under the expand/contract architecture, every schema modification spans three isolated releases: first, expand the schema by adding the new column as nullable alongside the legacy one; second, deploy application code that writes to both columns while reading from the new one; third, backfill historical rows asynchronously and safely contract by dropping the obsolete column.

Automated Pre-Merge Schema Linting in CI

Engineers should catch dangerous migration operations during pull request reviews before any code reaches a staging or production environment. Incorporating automated migration linters into CI detects hidden hazards: unindexed foreign key constraints that trigger table-wide share locks, adding columns with non-constant default values on older engines, and operations that necessitate full table rewrites.

Executing Non-Blocking Online DDL at Scale

For multi-million-row production tables, standard ALTER TABLE statements can stall queries for hours. Teams must leverage native MySQL 8 INSTANT DDL algorithms where supported, or orchestrate asynchronous tooling such as gh-ost or pt-online-schema-change. These tools copy data into shadow tables using binary log streaming, automatically throttle when replication lag exceeds conservative thresholds, and execute atomic cutovers in milliseconds.

Tags

migrations cicd zero-downtime devops schema

Work with Burj

Your database deserves engineering, not guesswork.

Tell us what is slow — CPU, queries, migrations, or cost — and we will scope the smallest safe fix.

Plan an engagement