A comprehensive guide to running Postgres schema migrations without downtime. Covers the ACCESS EXCLUSIVE lock trap, the expand-and-contract (parallel change) pattern broken into five deploy steps, and safe variants for common operations: adding columns, renaming columns, creating indexes with CONCURRENTLY, changing column types, and adding constraints with NOT VALID. Also covers safe backfill scripting in small batches, lock_timeout and statement_timeout settings, rollback strategies, and tooling recommendations (pgroll by Xata, Atlas by Ariga). Includes a personal production checklist and guidance on which operations to avoid during business hours.
Table of contents
The Mental Model You Need FirstThe Five-Step Migration That Made Me Stop Breaking ThingsAdding A Column SafelyRenaming A Column Without DowntimeAdding An Index Without Locking The TableChanging A Column Type Without Rewriting The TableConstraints Without Lock StormsThe Backfill Script That Will Not Crash Your DatabaseThe Tools That Make Expand-And-Contract Less PainfulWhat I Refuse To Run During Business HoursConnection Pools And Migration CoordinationRollback Plans That Actually WorkWhat I Run In ProductionWhat I Would Tell You If You Asked239 Impressions
1 Award