Learning center

How can we catch database migrations that might break a running service?

Test the schema transition against every application version that can serve during rollout or rollback. The final schema working with the final application is only one of those combinations.

Write down who still reads the old column#

Suppose a migration moves a value from status to state. Inspect the previous worker's read and write queries, then run them against the proposed schema. If an old process still writes only status, backfilling once can leave new rows without a usable state. A successful migration command won't reveal that gap.

A staged change can add the new column, keep both versions compatible while data moves, switch readers, and retire the old column when old readers and rollback paths no longer need it. Use the deployment record to decide when the last step is justified. The linked rollback exercise gives a concrete two-version example. Try the PostgreSQL rollback exercise ยท Review a database migration

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