Database Migration Wartime Stories
This title could be clearer and more informative.Try out Clickbait Shieldfor free (5 uses left this month).
Database migrations can cause production outages when not handled properly at scale. The article covers three critical PostgreSQL migration scenarios: creating indexes using CONCURRENTLY to avoid write locks, adding foreign keys in two steps with NOT VALID followed by VALIDATE CONSTRAINT to minimize downtime, and avoiding enum types due to their inflexibility. Understanding database locks is essential - ACCESS EXCLUSIVE locks block all operations while less restrictive locks like SHARE ROW EXCLUSIVE allow reads to continue. Testing migrations on realistic-sized databases is crucial since operations that work fine on small datasets can cause outages in production.
Table of contents
How To Maintain OrderLong Queueing Is Indistinguishable from an OutageAdd Foreign Keys In 2 stepsDo Not Use Enum TypesLocks Knowledge Will Make You Look Like A Database GuruSort: