Know which migration will lock your biggest table, before you merge it.

Like a linter, Migration Guard finds the statements in a Postgres migration that take heavy locks. Unlike a linter, it reads your table sizes, so it can tell an index build on a 40 GB table from the same statement on a 200-row table, and puts the statements that need a fix before merge first. You'll get it as a check on your GitHub pull requests.

Status: Early access opens to the waitlist in signup order.

See it work Hold a founding spot

Input

6 statements · sizes for 3 tables

See the input
SQLmigration.sql
CREATE INDEX idx_orders_customer ON orders (customer_id);
ALTER TABLE orders ADD COLUMN gift_note text;
ALTER TABLE feature_flags ALTER COLUMN rollout TYPE numeric(5,2);
ALTER TABLE customers ADD CONSTRAINT customers_email_key UNIQUE (email);
CREATE TABLE refund_reasons (id bigint PRIMARY KEY, label text NOT NULL);
COMMENT ON TABLE refund_reasons IS 'reasons shown in the refund form';
OutputTable sizes (from pg_class)
  table_name   | estimated_rows | total_bytes
---------------+----------------+-------------
 orders        |       48213664 | 12240512000
 customers     |         310442 |   164626432
 feature_flags |            212 |       49152
(3 rows)

Output

1 to fix before merge

6 statements read. Without table sizes, these 4 findings look alike. With your sizes: 1 to fix before merge, 1 apply at any size, 2 low impact at current size.

  1. Fix before merge orders · 11.4 GB

    require-concurrent-index-creation, line 1

  2. Applies at any size orders · 11.4 GB

    require-lock-timeout, line 2

  3. Low impact at current size customers · 157.0 MB

    disallowed-unique-constraint, line 4

  4. Low impact at current size feature_flags · 48.0 KB

    changing-column-type, line 3

What Migration Guard did

  • Migration Guard: Matched each statement to the lock it takes and what that lock blocks

    By hand: look up every statement in the PostgreSQL lock docs

  • Migration Guard: Looked up the size of every table the migration touches

    By hand: query pg_class for each table

  • Migration Guard: Ranked the findings by how much data each one locks

    By hand: judge which ones matter, and hope you did not miss one

  • Migration Guard: Gives the same answer on every run

    By hand: an AI review can answer differently from one run to the next

See the full sample

Hold a founding spot

The first 100 on the waitlist get $9/repo/mo, locked for as long as you stay subscribed. Then it's $19/repo/mo.

We store your email, a source tag, your consent and the signup time in Cloudflare D1, to email you about Migration Guard. Privacy

BVL privacy policy

Why not a free linter or an AI reviewer?

A linter in CI (for example Squawk, free and open source)
Checks the SQL text against rules. It cannot see your tables, so a risky statement on a 200-row table and on a 40 GB table get the same warning.
An AI code reviewer
Can explain locks, but cannot see production table sizes from a pull request, and may answer differently from one run to the next. A merge check should give the same answer every time.
Migration Guard
Uses fixed rules that give the same answer every run, plus your table sizes, so statements that need a fix before merge come first and the rest are marked low impact at current size.

How it works

  1. You'll add the GitHub Action to your repo.
  2. You'll give it your table sizes: a database role with no access to your tables that reads table statistics from the Postgres catalog, never rows, or a nightly size snapshot from your own job.
  3. On a pull request that changes migration .sql files, it'll post one comment: statements that need a fix before merge come first, each with its lock, what that lock blocks, the table's size and a lower-risk rewrite.

Who it is for

Backend engineers and tech leads who review Postgres migration .sql files in GitHub pull requests.

See an example

Hand-written illustrations of the report format:

What it does not do

It never says a migration is "safe". Statements it does not recognise are marked for review. Row counts are estimates from Postgres statistics.

Price

$9/repo/mo for the first 100 on the waitlist, then $19/repo/mo. Nothing is charged when you join.

Free alternative

Squawk is a free open-source linter for Postgres migrations (github.com/sbdchd/squawk). Squawk is a separate project and is not affiliated with us.