Reliability

How do you run a schema migration without taking production down?

Run a schema change as small steps that work with both app versions, keep DDL off the deploy, and prove the way back before you start.

2 min readDEV Group

Split the change

Make it boring: split the change into small steps that each work with both app versions, run the DDL apart from the deploy, bound every lock, and prove the way back before you start. A public postmortem from October 2026 shows the alternative. A planned upgrade of an internal job scheduler, one that builds and deploys depended on, ran a schema migration that locked a large table and pinned database CPU at 100%. Builds and deploys stopped for over two hours. The rollback clone taken before the upgrade had failed, so there was no fast way back. Stopping the client and reverting the upgrade did not stop the migration; it kept running on the database. Emergency capacity adds failed too. None of that is bad luck. Each step is a design gap.

Expand, then contract

Use expand and contract: add the new column, table, or index first, backfill, move reads and writes, and remove the old shape in a later release. Add before you remove, and make every phase safe with the old and new app versions running side by side. Run DDL as its own step, separate from the app rollout, so a slow migration never holds a deploy hostage and reverting code is not mistaken for reverting schema.

Bound the lock, prove the way back

Set lock and statement timeouts on the migration session, so it fails fast instead of queuing every query behind it. Verify the rollback path exists before you start: if the snapshot or clone step fails, stop. Know how to find and kill the migration on the database server, not just the client; ending the process that started it rarely ends the query. Keep hot state, such as job queues, locks, and run status, apart from search and reporting data, so heavy work on one cannot starve the other. Backfill in small, resumable batches that record progress and throttle on load. Reconcile row counts and checksums between the old and new shape before cutover, not after. A good migration is a sequence of dull steps, each with a known way back.

Sources

  • Public postmortem of a schema migration that locked production. Public postmortem. October 2026.

Was this useful?

Get in touch

Seeing one of these in your system?

Describe what exists today and where it breaks. We will come back with a technical point of view and a scoped first step.