Five database migration mistakes that can quietly take production down
Migrations that pass review and staging often fail in production, where real data, live traffic, and rolling deploys expose their flaws. Renaming a column via generated DROP and ADD statements deletes existing data and breaks old code still running during deployment, so a staged expand-contract approach is recommended. Adding a NOT NULL column without a default errors on populated tables, and the safer path is nullable addition, batched backfill, and later enforcement. Plain index creation on Postgres blocks writes during the build, which concurrent indexing avoids at the cost of some operational caveats. Setting a column to NOT NULL can hold a long exclusive lock, which Postgres 12+ can avoid by first validating non-nullness with a check constraint.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in