Skip to main content
supaschema and pgfence both analyze PostgreSQL migration safety with libpg_query, PostgreSQL’s own parser. pgfence is a migration-safety CLI that analyzes migration SQL (including ORM-generated migration files) for lock mode and risk. supaschema generates the migration from declarative SQL and then checks it.

Short answer

Use pgfence when you want lock-mode analysis, risk scoring, and safe-rewrite recipes over migrations you already have, including ORM migration files. Use supaschema when you want the migration generated from declarative SQL and checked in the same tool, with schema modeling and generated types.

Comparison

Capabilitysupaschemapgfence
Generates migrationsYes, from declarative SQLNo, analyzes migrations you provide
Parserlibpg_query (PostgreSQL’s parser)libpg_query (PostgreSQL’s parser)
Lock-mode analysisLock-hazard checks in supaschema checkYes, per-statement lock mode and risk scoring
ORM migration file analysisNo, works from declarative SQLYes, parses ORM-generated migration files
RLS policy body changesCompared structurallyNot its primary focus
Generated typesTypeScript and Zod from the SQL treeNone
LicenseFree core (open)Source-available
Database or Docker requiredNoNo

Why the workflow differs

pgfence reads migration SQL (or ORM migration files) and reports each statement’s lock mode, blocked operations, and a risk level, with suggested safe rewrites. It is an analysis-and-scoring layer over migrations that already exist. supaschema generates the migration first by diffing declarative SQL into PostgreSQL parse trees, then supaschema check reports replay-safety and lock hazards on the rendered SQL, and it models the schema so it can diff RLS policy bodies and emit TypeScript and Zod types. If your migrations come out of an ORM and you want lock scoring over those files, pgfence fits directly. If declarative SQL is your source of truth and you want generation plus checking in one tool, supaschema covers that lane.
Last verified 2026-06-17 against the pgfence documentation. Confirm current behavior and licensing before relying on it.

Atlas lint is paid: free alternatives

Free Postgres migration-safety options, including pgfence and supaschema.

The check command

The replay-safety and lock-hazard diagnostics supaschema runs on each migration.

Sources

Last modified on June 18, 2026