Safe migrations: locks & CONCURRENTLY
Your staging database has 40 rows. You run `create index on likes(user_id);`, it takes 4 milliseconds, the PR gets approved, and it ships. In production, `likes` has thirty million rows and real traffic — and for the ninety seconds your index takes to build, every single like, comment and post insert in the entire app queues up and waits. Nobody's query was slow. They were standing in line behind yours.
try to break it
you drive.
Every existing row is defined to read back the same literal default, so Postgres never has to touch them. The ACCESS EXCLUSIVE lock is still acquired, but for a few milliseconds — long enough to update the catalog, not to scan anything.
Watch the lock mode, not just the SQL. Two statements that look almost identical — step 4 and step 7 — take the same lock but for wildly different durations, because one of them can prove it doesn't need to scan.