PostgreSQL Migration Safety Checker
Paste a PostgreSQL migration. See each lock, rewrite and the online form.
How the check works
The file is split into statements and checked against 26 rules, with each statement's lock level on a timeline. An ALTER waiting for ACCESS EXCLUSIVE queues every new query behind it; set lock_timeout.
Version matters (PostgreSQL 11 and 12 removed several rewrites and scans). Tables created earlier in the same file skip lock rules.
All 26 rules
Migration safety FAQ
Why does a quick ALTER TABLE take the site down?
It waits for ACCESS EXCLUSIVE behind open transactions, and every new query queues behind it. Set lock_timeout so it fails and retries instead.
Does adding a column with a default rewrite the table?
From PostgreSQL 11, only for volatile defaults such as gen_random_uuid() or random(). Before 11, any default rewrites it.
How do I add NOT NULL to a big table without downtime?
Add CHECK (col IS NOT NULL) NOT VALID, validate it, then SET NOT NULL (12 and later skip the scan), then drop the check.
Is my migration sent anywhere?
No. The splitter and rules run in this tab.
Does this replace squawk or strong_migrations?
No. Those run in CI with a full SQL parser. This page explains each lock and shows the safe form, for review and learning.
Lock levels and rewrite behaviour follow the PostgreSQL documentation for versions 10 to 17, as of November 2026. Sample schemas on this page are fake.