Product / free, for PostgreSQL

Postgres Migration Guard.

pg-migration-guard

Catch the Postgres migration that locks or rewrites your table, right in CI, before it reaches production. A static checker with 12 rules covering the common ways a schema change takes a live database down. Free and MIT-licensed, run as a CLI or a GitHub Action.

The migration
CREATE INDEX idx_orders_customer ON orders (customer_id);
ALTER TABLE users ALTER COLUMN email SET NOT NULL;
pg-migration-guard
WARN  IDX01  CREATE INDEX without CONCURRENTLY
  Safe: CREATE INDEX CONCURRENTLY idx ON tbl (col);  -- outside a transaction
WARN  NN01  SET NOT NULL scans the whole table under ACCESS EXCLUSIVE
  Safe: ADD CONSTRAINT c CHECK (col IS NOT NULL) NOT VALID; VALIDATE CONSTRAINT c; then SET NOT NULL;
What it catches

The schema changes most likely to take a live PostgreSQL database down. A migration is dangerous when it holds a strong lock while it scans or rewrites a big table: on a hot production table that is an outage. Each finding prints the reason, an official Postgres citation, and the safe rewrite.

Install

Python 3.8+, no dependencies, with the parser bundled for Linux, macOS, and Windows.

pip install pg-migration-guard

Or run it in CI as a GitHub Action. Findings show as inline PR annotations, and a blocker fails the build.

- uses: technical-turtle/pg-migration-guard@v1
  with:
    path: db/migration
    fail-on: blocker
Full coverage

Postgres Migration Guard is the free version of the Postgres Migration Safety Auditor. The auditor checks 36 rules (not 12), each linked to an official source, and adds: