# The Database Is Where Continuous Delivery Goes to Die

- Published: 2026-10-16
- Updated: 2026-11-26
- Tags: Continuous Delivery, Books
- URL: https://devtrillo.com/writing/continuous-delivery-5-data-and-migrations/

> Part 5 of a series reading _Continuous Delivery_, by Jez Humble and David Farley. Part 1: [Continuous Delivery Is a State, Not a Pipeline](/writing/continuous-delivery-1-a-state-not-a-pipeline/).

Everything so far has a quiet assumption baked into it. The pipeline promotes an artifact. A bad release rolls back. Deploy is cheap because you can always undo it.

Then someone points at the database and the whole thing gets nervous.

Because code is easy to take back and data is not. You can redeploy last week's binary in seconds. You cannot redeploy last week's _schema_ once this week's code has been writing into it, and you certainly cannot un-drop a column that a migration deleted at 2am. So teams that ship code ten times a day still batch every schema change into a dreaded quarterly "migration window," take the site down, and pray.

That is the reputation: **the database is where Continuous Delivery goes to die.** The most common reason people say zero-downtime releases are impossible for a "real" app is the one sitting behind the API.

The book's answer is that it isn't a database problem. It's the same problem you already solved.

> Incremental change: rather than a big-bang migration, you make a series of small, reversible changes, each of which keeps the system working.[^evodb]

**You decouple schema change from deploy the same way you decoupled deploy from release.** In [Part 1](/writing/continuous-delivery-1-a-state-not-a-pipeline/), a feature flag let a deploy happen without a release — code shipped dark, turned on later. Here, a compatibility window lets a schema change happen without a coordinated deploy — the database changes shape while every running version of the app keeps working.

## The database breaks the illusion

The reason a schema change feels dangerous is that people do it as one atomic move: change the code and the schema together, in lockstep, and hope they land at the same instant.

They never do. During any real deploy there is a window — seconds to minutes — where old app instances and new app instances are both running against the _same_ database. If the new schema breaks the old code, every request that hits an old instance during that window fails. So you take the site down to shrink the window to zero.

**Old and new app versions sharing one database mid-deploy.** During a rolling deploy, incoming requests are split between instances still running app v1 (the old code) and instances already running app v2 (the new code). Both versions read and write the same database, with one schema, at the same time. If that schema only works for v2, every request that lands on a v1 instance fails.

That maintenance window is not a fact of databases. It is the cost of coupling two changes that did not need to be coupled.

> **Note:** The trap is thinking "the deploy" and "the migration" are one event. They are
> two. The instant you let them be separate — schema first, code later, or code
> first with the schema tolerant of both — the window where things can break
> disappears, and with it the reason to take anything offline.

## Expand, migrate, contract

So how do you rename a column — the simplest schema change there is, and a classic downtime excuse — without ever taking the app down?

You never change it in place. You add the new shape alongside the old, move everything across in small reversible steps while both work, and only remove the old shape once nothing uses it. Expand, migrate, contract.[^parallelchange]

Walk through it. Watch the badge.

**An expand/contract migration renaming a column with zero downtime**

Phases: expand → migrate → contract. A "zero downtime" badge holds at every step: each running app version works.

1. **expand: Add the new column, nullable.** Table `users`: `zip` (read + write); `postal_code` (unused, null). v1: reads & writes zip — never sees the new column. An additive change. The new column is nullable, so the running app doesn't know or care it exists. Nothing to deploy in lockstep, nothing to break.
2. **expand: Backfill existing rows.** Table `users`: `zip` (read + write); `postal_code` (backfilled from zip). v1: still reads & writes zip — undisturbed. Copy zip → postal_code for every existing row, in the background. The app keeps serving from zip throughout; the backfill is invisible to it.
3. **migrate: Deploy v2 — dual-write.** Table `users`: `zip` (kept in sync); `postal_code` (written too). v1: still running mid-rollout — reads & writes zip. v2: writes BOTH columns, still reads zip. Now the interesting moment: v1 and v2 run side by side during the rollout. v2 writes both columns, so whichever version serves a request, both columns stay correct. Both work.
4. **migrate: Switch reads to the new column.** Table `users`: `zip` (still written); `postal_code` (read + write). v2: reads postal_code, still writes zip too. Once every instance is v2, flip reads to postal_code. zip is still written, so a rollback to a zip-reading version is instant and safe. The change is reversible right up to the last step.
5. **contract: Drop the old column.** Table `users`: `zip` (removed); `postal_code` (read + write). v2: reads & writes postal_code — the migration is done. Only now, when nothing reads or writes zip, do you drop it. Removing an unused column is itself a safe, additive-in-reverse change. The rename is complete, and the site never went down.

The green badge is the whole point, and it is not decoration — it is the invariant. At every single step, both the old app version and the new one can serve a request correctly. That is what makes each step safe to deploy on its own schedule, and safe to roll back. There is no instant where the schema and the code have to be in sync, so there is no window to take offline.

Notice that nothing in there was clever. Add a nullable column. Backfill it. Write both for a while. Switch reads. Drop the old one. Five boring, individually-reversible steps replace one terrifying atomic one — the same small-steps move [refactoring](/writing/refactoring-is-a-discipline/) makes with code, applied to data.

## Backward compatibility is the contract

The property holding all of this together has a name: **backward compatibility**. Every migration must leave the database usable by the app version that came before it.

That single rule is what lets deploy and migrate stop being simultaneous. Because the old code still works against the new schema, you can migrate first and deploy later. Because the new code still writes what the old code needs (the dual-write step), you can roll the deploy back mid-flight and nothing is stranded. The compatibility window is the safety net that makes the trapeze act boring.

Break that rule — ship a migration that only the new code can tolerate — and you are back to a coordinated, all-at-once, take-it-offline release. Every downtime migration you have ever suffered was, underneath, a backward-incompatible change someone tried to do in one step.

**Deep dive: Why not just take a two-minute maintenance window? It's simpler.**

Because "simpler" is borrowing against the future at a bad rate. A two-minute window sounds harmless until you count what it actually costs: you can now only migrate during a scheduled downtime, so migrations get batched up to "make the window worth it," so each one is bigger and riskier — which is exactly the large-batch trap from Part 1, wearing a database hat. And a global business that never sleeps has no good two minutes. The expand/contract dance is a few more steps up front, but each step is trivial and reversible, and it buys you the ability to change the schema any day, mid-afternoon, with users online and nobody holding their breath. You are trading a recurring, compounding tax for a one-time bit of care.

## Migrations are versioned, tested, reversible code

The last piece is a mindset shift the book insists on: a migration is not a one-off script someone runs by hand. It is code, and it earns the same standards as the rest of your code.[^evodb]

It lives in version control, next to the change that needs it. It runs in the pipeline — applied automatically to every environment, so a migration that fails does so in the commit stage, not in production. It is ordered and repeatable, so any database can be brought to any version deterministically. And, wherever possible, it is reversible — a down-migration that has itself been run, not a hopeful comment.

> **Tip:** If a migration only exists as a command in someone's shell history, it isn't
> done. A schema change you can't reproduce from version control is the database
> equivalent of the snowflake server from Part 4 — and you can't diff a database
> you changed by hand.

The database stops being the place CD goes to die the moment you stop treating schema changes as special. They're just more changes: small, backward-compatible, versioned, tested, and reversible — flowing through the same pipeline as everything else.

## So, how do you ship a database?

Not in a window. Not in a lockstep deploy. Not by hand at 2am.

You expand before you contract. You keep every step backward-compatible, so the old and new code both work and deploy and migration never have to be the same event. You put migrations in version control and run them through the pipeline like any other code. Do that, and "we have a real database" stops being the reason you can't practice Continuous Delivery.

Next in the series: the finale — how you measure whether any of this is actually working, and the one idea I'm taking with me from the whole book.

[^evodb]: Martin Fowler and Pramod Sadalage, [Evolutionary Database Design](https://martinfowler.com/articles/evodb.html) — treating the schema as something that changes continuously and safely, with migrations kept in version control and applied through automation. The idea runs throughout Humble & Farley's [_Continuous Delivery_](https://continuousdelivery.com/).

[^parallelchange]: Danilo Sato, [ParallelChange (expand/contract)](https://martinfowler.com/bliki/ParallelChange.html) — make a breaking change safe by expanding to support both old and new, migrating over, then contracting to remove the old, so consumers never see a broken state.
