Here's a migration that would sail through most code reviews:
ALTER TABLE users ADD COLUMN plan text NOT NULL; ALTER TABLE users ADD COLUMN api_token uuid DEFAULT gen_random_uuid(); CREATE INDEX users_plan_idx ON users (plan); ALTER TABLE orders ADD CONSTRAINT orders_total_positive CHECK (total > 0); On an empty dev database it runs in milliseconds. On a table with real data:
- Line 1 fails outright. Every existing row would get
NULLin aNOT NULLcolumn, so Postgres rejects it ("column contains null values"). Your deploy stops halfway. - Line 2 rewrites the whole table under the strongest lock, because
gen_random_uuid()needs a different value in every row. On a 2M-row table I measured 9.2 s with reads and writes blocked. The same column withDEFAULT now()took 1.3 ms. - Line 3 blocks every write to
usersuntil the index is built. On 2M rows, a singleINSERTwaited 2.26 s. WithCREATE INDEX CONCURRENTLY, it took 2.4 ms. - Line 4 scans every order while every read and write on
orderswaits, because adding aCHECKconstraint takes the strongest lock. (NOT VALIDfirst, thenVALIDATE CONSTRAINT, avoids it.)
(Timings measured on PostgreSQL 16, 2M-row table, local server.)
None of this shows up in tests, because tests run on small tables. That's why I built a check that reads the SQL itself.
A GitHub Action that reads your migrations
Postgres Migration Safety Check runs on every pull request that changes a migration. It marks the risky lines in the diff and leaves one comment with a safe version of each. Here it is on the migration above: demo pull request (3 dangers, 2 warnings, each with the fix).
Setup is one workflow file:
# .github/workflows/migrations.yml name: migration safety on: pull_request: paths: ['**/*.sql'] jobs: check: runs-on: ubuntu-latest permissions: contents: read pull-requests: write steps: - uses: actions/checkout@v4 - uses: adnan909/postgres-migration-checker@v1 - Free, no account, works on private repos.
- It only reads the SQL files the pull request changes. Nothing is sent anywhere; it runs inside your own CI job and comments with the job's own token.
- Works with any tool that keeps migrations as SQL files: Prisma, Supabase, Flyway, golang-migrate, dbmate and more (set
files:to your path). - Want to try it without touching a real repo? Use the demo as a template, add a
CREATE INDEXand open a pull request. It takes about 30 seconds. - Or paste one migration into the browser version.
What I'm asking
I'm looking for 5 teams running Postgres in production to add it to a real repo for a couple of weeks and tell me:
- False alarms: anything it flagged that was actually fine for you (a small table, a migration tool that handles it, a pattern it doesn't understand).
- Misses: a migration that hurt you in production that it didn't flag.
- Noise: whether the comment is useful or just in the way.
In return, I'll fix false alarms and add the rules you need, fast. Reply in the comments with your stack (ORM or migration tool, Postgres version) or just tell me what it found.
Making Claude Code write safe migrations in the first place
The check catches problems after the code is written. If you use Claude Code, the free postgres-safe-migrations skill teaches it these rules so it writes the safe version from the start.
- Two skills are free (safe Postgres migrations and GraphQL N+1 fixes): github.com/adnan909/free-sample
- The full pack, with 7 more skills for TypeScript + GraphQL + Postgres backends and a tested starter backend: Backend Skills Pack on Gumroad

