>_ free tool

Postgres Migration Safety Checker

Paste a migration. See which statements will lock or rewrite a live table, fail on a table that has data, or break the app while it deploys, with a safe rewrite for each one.

Runs entirely in your browser. Your SQL is never uploaded; we only count anonymous page visits and button clicks (GoatCounter, no cookies). Rules target PostgreSQL 11+ and were verified against PostgreSQL 16.

Catch this on every pull request, automatically

The same rules as a free GitHub Action. It checks only the migrations a pull request changes, marks the risky lines in the diff and leaves one comment with the safe version. No account, no signup, works on private repos, adds about a second to the job.


    
Save it as .github/workflows/migrations.yml.

Want Claude Code to write migrations like this in the first place? The free postgres-safe-migrations skill teaches it these rules.

What it checks

StatementWhat goes wrongSafe version
CREATE INDEXBlocks every write to the table until the index is builtCREATE INDEX CONCURRENTLY, outside a transaction
ADD COLUMN … DEFAULT gen_random_uuid()Volatile default rewrites the whole table under the strongest lockAdd the column, set the default, backfill in batches
ADD COLUMN … NOT NULL with no defaultFails outright on any table that has rowsConstant default, or nullable then backfill
ALTER COLUMN … TYPERewrites the table and every indexNew column, backfill, switch reads
SET NOT NULLFull-table scan while reads and writes are blockedCHECK … NOT VALID, VALIDATE, then SET NOT NULL
ADD FOREIGN KEY / CHECKValidates every row while blocking writesNOT VALID, then VALIDATE CONSTRAINT later
REFERENCES with no index on the columnEvery delete on the parent scans the whole child table (100 deletes: 7.87 s vs 3.66 ms on 2M rows)Index the foreign key column
ADD UNIQUE / PRIMARY KEYBuilds an index while the table is unusableUnique index CONCURRENTLY, then USING INDEX
RENAME, DROP COLUMN, DROP TABLEOld app instances fail during a rolling deployExpand and contract; drop after code stops using it
CONCURRENTLY in a transactionPostgres rejects it; the migration failsOwn migration with the transaction turned off
VACUUM FULL, CLUSTER, REINDEX, REFRESHRewrites or blocks the table or viewpg_repack, CONCURRENTLY variants
UPDATE / DELETE backfillsLocks every touched row until the migration commitsBatches of a few thousand rows, from a script
No lock_timeoutA quick ALTER waits behind a slow query and every request queues behind itSET lock_timeout = '3s' at the top

Why "it worked in dev" isn't enough

Most dangerous migrations run in milliseconds on a development database with ten rows. In production, the same statement can hold an ACCESS EXCLUSIVE lock for minutes, or wait behind one long query while every request piles up behind it. The checker reads your SQL statically, so it catches these before they run against real data.

It doesn't know your table sizes or traffic, so treat a finding as "check this", not "this will definitely cause an outage". Statements on a table created earlier in the same migration are treated as safe, since that table is empty.