Zero-Downtime Schema Migrations — Adding Columns, Constraints, and Indexes
Zero-Downtime Schema Migrations — Adding Columns, Constraints, and Indexes
A naive schema migration on a production table with millions of rows acquires an AccessExclusiveLock, blocking all reads and writes for minutes or hours. PostgreSQL provides tools to perform most migrations without downtime, but they require a different sequence than the obvious DDL statements.