postgres-impl-zero-downtime-migrations
Installation
SKILL.md
postgres-impl-zero-downtime-migrations
Quick Reference :
A schema change on a live database is safe only when it never holds a strong lock long enough to block production traffic. Two distinct dangers :
- The operation itself is slow : a full table rewrite (
ALTER COLUMN TYPE,ADD COLUMNwith a volatile default) or a plainCREATE INDEXholds a strong lock for the whole duration. - The lock queue : even a fast, metadata-only
ALTER TABLErequestsACCESS EXCLUSIVE. If a long-running query holds the table, theALTERwaits behind it, and every query arriving after theALTERwaits behind theALTER. One slowSELECTplus one fastALTERcan freeze the table.
Core rules :