Stephen Gilmore

Decoupling database migrations from server startup: why and how

March 17, 2025 #Database #PostgreSQL

Zero-downtime schema migrations

The general process is:

  1. Migrate from schema S to schema S+1, with only additive changes.
  2. Over time upgrade some of your processes from application version V to V+1.
  3. Eventually everything is on V+1, and you don’t ever expect to rollback to V.
  4. Finally, migrate from schema S+1 to S+2, and now you can do destructive schema changes to anything that V+1 no longer uses