A migration is done when the last reader is gone
Nothing read the old column for a week, so you drop it. Then the quarterly job runs.
Contents4 sections
Every guide to changing a database schema without downtime ends by telling you to remove the old column once all clients have moved. But how would you know?
The pattern is called expand/contract, and it has 3 steps. You add the new column beside the old one (expand), move every reader and writer over, and then remove the old column (contract). Danilo Sato’s ParallelChange puts step 3 like this: “Once all usages have been migrated to the new version, you perform the contract phase.”
That “once” sounds like a date you can look up. But it is a claim about every reader of the column. Say the old column is legacy_email. Who still reads it? And what proves each one is gone?
Watching proves only what you watched long enough
The first thing you would try is to watch. Log every read of the old column for a week, and if nothing shows up, drop it. Apollo’s GraphOS schema checks do this for GraphQL fields, over 7 days of traffic by default. That is fine for a reader that runs every hour. But what about a job that runs once a quarter? Pick a window and see.
How many days of watching catch every reader?
Model: readers and schedules invented for this figurePick how many days to watch. Then drop the column.
legacy_email on a schedule. The shaded part is the days you watched. A job with no run there breaks at its next run after the drop. The percentage is how often a window that long would catch the job if its last run could have been any day.A 1-week window catches a quarterly job about 8% of the time! And a longer window only fixes half of the problem. A query log sees the readers that query the database while you watch. Many readers never do. They hold their own copy of the column, or of code that expects it.
The readers you forget you have
Start with your own servers. During a rolling deploy, servers that booted before the drop keep the old column list. Rails does this (Active Record caches the columns at boot), and that is why strong_migrations makes you ignore a column for one deploy before you drop it. You don’t even need a library to run into this. If a SELECT * was prepared before the drop, Postgres fails it with the error cached plan must not change result type. And that query never named the column.
Then there are open browser tabs. A tab that loaded yesterday’s code may still be running it. Tabs stay open for days or even weeks, or longer, like my own 450 tabs!
And then the warehouse. Change data capture (CDC) copies each row change out of the database’s write-ahead log. Schema changes like ALTER TABLE don’t reach that stream. Debezium’s Postgres connector says it can’t report “DDL change events” to consumers. Fivetran leaves a deleted column “untouched in your destination” and fills it with NULL. So every dbt model and dashboard on that table keeps reading the column, and the database can’t see them.
Each reader needs a proof
Every reader needs one of these 4 proofs. If none of them fits a reader, you can’t cross it off yet.
| Proof | What it is | How it fails |
|---|---|---|
| Wait | The reader has a known maximum lifetime, so you outwait it (pin max age, topic retention, rollback window) | The lifetime was a guess, or there wasn’t one |
| Watch | Telemetry shows no reads for long enough | The window was shorter than the rarest reader’s period |
| Evict | Force the reader off the old column (reload on version mismatch, mobile force-update, brownouts, hard errors on old reads, Deprecation and Sunset headers) |
Someone has to own the eviction and what it breaks |
| Keep | Keep serving the old column on purpose (Stripe’s API versions, dbt model versions) | New code starts to depend on the old column |
Evict is the only proof for readers with no known lifetime. GitHub ran brownouts, short planned outages of an old endpoint, before removing it. Stripe put a hard error on the old read path, so someone sees every leftover read.
For an eviction like that, you should aggressively let your consumers know what is being retired.
Keep is fine if you choose it on purpose. But then you have to keep writing to the old column too, or old readers get stale values with no error.
Fill in a reader ledger
Before the contract step, I want a ledger with one row per reader and its proof. For legacy_email it could look like this:
| Reader | Proof | What the proof rests on |
|---|---|---|
| API servers, workers | Wait | The rollout ends and every process restarts |
| Open tabs | Evict | Reload when the tab’s version doesn’t match the server’s |
| Mobile apps | Evict | A forced update, so no old build still runs |
| Kafka topics (message streams) | Wait | Retention removes the old messages |
| dbt models, dashboards, exports | Watch | Query history for at least the rarest job’s period |
| CDC copy in the warehouse | Evict | Drop the warehouse column once the row above is clear |
| External API clients | Keep | Serve the old field to clients on old versions |
The other half of the job is to stop new readers from showing up while you work through the ledger. When I moved the on-screen text of sales apps in 5 markets into a translation service, I added a CI check that fails on hardcoded copy. Then I made the service the only source and deleted about 20,000 lines of local scripts.
Two months later Cursor made a ton of changes in a local file of 479 English keys that were never registered in the service. I deleted the file and added a rule in our AGENTS.md, so the coding agents that other engineers run don’t create that file again.
For a column, the same check is a CI rule that fails on any new reference to legacy_email.
If a row has no proof, the migration is not done. It’s still at step 2, whatever the plan says about step 3.