Learning center

Decide when to stop writing the old column

Stop writing the old column only when no release you might roll back to still reads it. The day the writes stop, the old column starts going stale, and a rollback to a release that reads it shows the stale value without an error. In our lab, a rollback after two orders had shipped showed both as paid. Before stopping, collect the evidence below. After stopping, the rollback target has to be a release that reads the new column.

What a rollback reads once the writes stop#

Release 2026.11.3 reads and writes status. Release 2026.11.4 reads state and writes both. Release 2026.11.5 stops writing status and drops the sync trigger. We ran 2026.11.5's writes on PostgreSQL 16.15, then read the table the way 2026.11.3 would:

-- 2026.11.5
UPDATE orders SET state = 'SHIPPED' WHERE id IN (1, 2);
INSERT INTO orders (id, state) VALUES (6, 'PAID');

-- rolled back to 2026.11.3
SELECT id, status AS what_2026_11_3_shows, state AS what_happened FROM orders ORDER BY id;
idwhat 2026.11.3 showswhat happened
1paidSHIPPED
2paidSHIPPED
3paidPAID
4paidPAID
5paidPAID
6(null)PAID

The old release shows two shipped orders as paid and an order with no status. Its own writes would then make it worse: shipping order 1 again, or failing on order 6 if it requires a status. Rolling back to 2026.11.4 instead works, because that release reads state.

SELECT count(*) AS rows_the_old_release_misreads
FROM orders WHERE status IS DISTINCT FROM lower(state);
-- 3

That count grows with every write after the stop. It is the size of the problem a rollback to 2026.11.3 would create, so it is worth reading before deciding whether a rollback past 2026.11.4 is acceptable.

The evidence to collect before stopping#

Each line names a check another guide in this collection shows.

  1. No release that reads status serves or is the rollback target. The deploy record says which release is the rollback target. Tag PostgreSQL connections with the release that opened them shows which releases are connected.
  2. No other reader depends on status. Reports, exports and other services read it too. Find every query that still reads the old column shows how to find them in the database's statement statistics and with column privileges in staging.
  3. No writer of status alone remains. A job or another service that writes only status keeps the columns in agreement only while the sync trigger exists, so agreement alone says nothing about it. Over a full cycle of every scheduled job, the legacy_writes trigger in the connections guide must have recorded writes only from releases that also write state, or each other writer it found must have moved to state.
  4. The two columns agree. Find every backfill mismatch with IS DISTINCT FROM finds no persistent mismatch, and rows it saw for the first time match when checked again.
  5. Nothing still in flight carries the old shape. Jobs started before the deploy, queued messages and cached objects built from status can outlive the release that made them. Wait out the longest of their lifetimes.

The order of the last steps#

  1. Ship 2026.11.4 and let it become the rollback target.
  2. Check the five items above.
  3. Ship 2026.11.5, which stops writing status and drops the sync trigger in the same deploy.
  4. Keep the status column, unwritten, for one more release. Dropping it is the contract step, and it removes the only copy of the old values.

Step 4 is the rollback limit: after it, no release that reads status can run at all. The rest of the sequence is in moving data while two application releases share one database.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading