Ship Postgres migrations without fear.
pgsafe is a static linter that flags PostgreSQL schema migrations likely to lock or break production — no database connection required.
$ pgsafe migration.sql
error add-index-non-concurrent CREATE INDEX without CONCURRENTLY blocks writes for the whole build.
warning require-timeout Lock-taking statement with no lock_timeout can pile up the lock queue.
What it does
No database needed
Parses SQL with PostgreSQL's real parser. No connection, no network, no credentials.
Catches lock & break hazards
Flags rewrites, blocking index builds, unvalidated constraints, and changes that break running app code.
Safe-rewrite guidance
Every finding explains the hazard and the safe way to make the same change.
CI-ready
Machine-readable JSON, exit codes, and a GitHub Action so a PR fails on an unsafe migration.
Install
Run it in CI with the GitHub Action:
- uses: fixed-width/pgsafe@v0.8.5
with:
files: "db/migrate/*.sql"Or grab a prebuilt binary from the latest release (static Linux and macOS builds).