Postgres Migration Checker
Check PostgreSQL migrations for the lock each statement takes, what it blocks, and a safe rewrite.
Install
irm https://raw.githubusercontent.com/chayprabs/localtools/main/postgres-migration-checker/install.ps1 | iexlocaltools-postgres-migration-checker updatelocaltools-postgres-migration-checker uninstall
curl -fsSL https://raw.githubusercontent.com/chayprabs/localtools/main/postgres-migration-checker/install.sh | bashlocaltools-postgres-migration-checker updatelocaltools-postgres-migration-checker uninstall
pipx install localtools-postgres-migration-checkerpipx upgrade localtools-postgres-migration-checkerpipx uninstall localtools-postgres-migration-checker
Opens at http://127.0.0.1:47116 in your browser. Run localtools-postgres-migration-checker --help for the command line. Set LOCALTOOLS_NO_OPEN=1 to install without opening it.
Direct download
| Platform | File | Size |
|---|---|---|
| Windows x64 | postgres-migration-checker-1.0.4-windows-x64.zip | 14.7 MB |
| macOS Apple Silicon | postgres-migration-checker-1.0.4-macos-arm64.zip | 21.4 MB |
| macOS Intel | postgres-migration-checker-1.0.4-macos-x64.zip | 21.2 MB |
| Linux x64 | postgres-migration-checker-1.0.4-linux-x64.zip | 34.7 MB |
SHA-256 checksums are in the release notes; the install scripts verify them for you.
See it
How to use
- Install with the one-line script, or pipx install localtools-postgres-migration-checker, then run localtools-postgres-migration-checker.
- Paste UTF-8 SQL or choose .sql files in the order they run. A new paste or upload replaces the previous input, and each chosen file can be removed.
- Set the target PostgreSQL version (11–18, default 18) and the runner transaction: detect framework markers and explicit BEGIN, wrap each file, or never wrap.
- Click Check migration. Each statement shows its lock, what that lock blocks, whether it scans or rewrites the table, and a safer rewrite when the rule has one.
- Copy JSON or download JSON, Markdown or SARIF. The page shows 50 statements at a time; the download is the full report.
FAQ
Does it run the SQL against a database?
No. It parses the text with libpg_query and never opens a connection. The report stays on your machine.
Why does ADD COLUMN age int NOT NULL DEFAULT 0 still take ACCESS EXCLUSIVE?
On PostgreSQL 11 and later a constant default does not rewrite the table. ADD COLUMN still takes ACCESS EXCLUSIVE until the catalog change commits. That statement is flagged for a missing lock_timeout, not for a rewrite.
Can pipx install it on an Intel Mac?
Not from PyPI alone. Upstream publishes no Intel wheel, and its source archive lacks build headers. Use the Intel Mac ZIP, or Python 3.13 with pipx install localtools-postgres-migration-checker --python python3.13 --pip-args="--find-links https://github.com/chayprabs/localtools/releases/download/postgres-migration-checker-v1.0.0/postgast-0.2.0-cp313-cp313-macosx_10_13_x86_64.whl". That is the bundled MacIntel postgast 0.2.0 wheel, built unmodified from the upstream v0.2.0 Git tag.
Which migration runners does it understand?
goose Up/Down/NO TRANSACTION, dbmate up/down and transaction:false, Liquibase formatted SQL changesets and runInTransaction:false, and Flyway V…__…sql or R__…sql filenames. Down sections are omitted. Rails and Django need exported SQL plus the transaction mode you choose.
How large a migration can it check, and what does it skip?
100 files, 4 MiB of UTF-8 SQL, 5,000 statements, a 16 MiB report, 30 seconds, and two checks at a time. Larger input is rejected. Function bodies, DO blocks, dynamic SQL, views, triggers and the live schema are not modelled. Locks are static estimates, not measurements from a running database.