Postgres migration lock checker

Drop your migrations folder or paste a migration to find statements that block reads or writes on tables that already hold data.

Run the check

Drop a project folder or files here

node_modules, .git, virtualenvs and build folders are skipped. Limit 25 MB / 5,000 files.

The Python engine (Pyodide, a few MB, cached by your browser) loads when you start.

The mistake

On a table that existed before the migration: CREATE INDEX without CONCURRENTLY; adding a CHECK or FOREIGN KEY constraint with a full check; column type changes and volatile defaults that rewrite the table; NOT NULL added to an existing table; and no lock_timeout.

Why it is dangerous

A plain CREATE INDEX holds a SHARE lock for the whole build: every INSERT, UPDATE and DELETE waits, which on a large table means minutes of failed or stuck writes. Adding a CHECK constraint scans every row under an ACCESS EXCLUSIVE lock. ADD COLUMN ... NOT NULL without a default fails on any table that has rows. Without a lock_timeout, a migration that waits behind a long transaction makes every new query on that table queue behind it, stalling all traffic to the table.

How to fix it

Build indexes with CREATE INDEX CONCURRENTLY (outside a transaction block). Add constraints as NOT VALID and VALIDATE CONSTRAINT separately. Set a lock_timeout at the top of migrations that touch existing tables so they give up quickly and can be retried:

SET lock_timeout = '5s';
CREATE INDEX CONCURRENTLY IF NOT EXISTS orders_user_id_idx ON orders (user_id);
ALTER TABLE orders ADD CONSTRAINT orders_user_fk
  FOREIGN KEY (user_id) REFERENCES users (id) NOT VALID;
ALTER TABLE orders VALIDATE CONSTRAINT orders_user_fk;

What this checker looks for

This page runs pg-launch-check, which reads SQL migrations, schema.prisma and app code (Prisma, Drizzle, pg, SQLAlchemy, Django). The rules most relevant to this page:

RuleWhat it finds
PGL002CREATE INDEX without CONCURRENTLY on an existing table
PGL003Constraint added with a full check while holding a lock
PGL004Table rewrite while holding an ACCESS EXCLUSIVE lock
PGL005NOT NULL added to an existing table
PGL006Migration without lock_timeout

Every finding has a rule id, a severity, file:line, the offending line (secrets masked), why it matters and how to fix it. Run pg-launch-check rules for the full list.

FAQ

Which migration tools are understood?

Plain .sql migrations (a migrations/ folder, numbered names, Flyway V1__init.sql, *.up.sql), Supabase, Prisma Migrate and Drizzle Kit.

How does it know a table already exists?

It replays your migrations in order, in memory. A table created earlier than the migration being checked (or not created in the files you scanned) is treated as existing.

Are my files uploaded anywhere?

No. The checker is Python running inside your browser tab (Pyodide, WebAssembly). Your files are read with the browser's File API and written into an in-memory file system that exists only in this tab. Your files are never sent anywhere. The only network requests load the Python runtime and the checker code, plus Google Analytics page-view counting, which never sees your files. You can disconnect from the internet after the engine has loaded and the scan still works.

Is a clean report a guarantee?

No. It is a static check for known patterns, not a penetration test. A clean report means none of these patterns were found, nothing more.

Can I run the same check on my machine or in CI?

Yes. Every checker on this site is an open-source command-line tool (MIT licence, Python 3.10+ standard library only). The results here are the same as `scan --json` on the command line, except for checks that need git (whether a file is committed or ignored), which cannot run in a browser.