How a missing DEFAULT column locked my production DB for 20 minutes (and why your CI won't catch it)
Description and use
Adding a NOT NULL column without a DEFAULT to a large PostgreSQL table caused a 20‑minute outage due to a table lock. migra‑guard, a context‑aware linter, automatically blocks such migrations in CI, preventing future downtime.
Problem
Adding a NOT NULL column without a DEFAULT to a large production table caused a 20‑minute outage due to an Access Exclusive lock, and existing CI checks failed to catch the issue.
Outcome
The migration pipeline now automatically blocks dangerous schema changes, eliminating the risk of production downtime caused by missing DEFAULT values on NOT NULL columns.
Workflow
- 1. Add migra‑guard to the GitHub Actions CI workflow.
- 2. Commit migration scripts to a PR.
- 3. migra‑guard parses all migration files in the PR using an AST engine.
- 4. It tracks the chronological state of tables across the PR.
- 5. If a NOT NULL is added to an existing table without a DEFAULT, or an existing production table is dropped, the CI fails and the PR is blocked.
- 6. Safe changes (new tables, temporary tables, NOT NULL on new tables) pass silently.
Evidence
I decided we needed an automated check in our CI/CD pipeline to catch this.
migra‑guard uses an AST engine and tracks the chronological state of your migrations across your Pull Request.
- Record date: 2026-09-05T18:45:37.554Z