Skip to main content

Postgres Migration Checker

Offline static analysis of PostgreSQL migrations: estimated per-statement locks, conflicting traffic, scans/rewrites, transaction conflicts and concrete safer-step examples. SQL is never executed.

Install the portable app (no administrator or external runtime):

irm https://raw.githubusercontent.com/chayprabs/localtools/main/postgres-migration-checker/install.ps1 | iex
curl -fsSL https://raw.githubusercontent.com/chayprabs/localtools/main/postgres-migration-checker/install.sh | bash
# Or Python 3.10+: pipx install localtools-postgres-migration-checker

Run localtools-postgres-migration-checker for the UI. Paste UTF-8 SQL or choose files in execution order. Each chosen file can be removed. A new paste or upload replaces the previous input. Copy/download JSON, Markdown or SARIF. Views load 50 statements at a time.

localtools-postgres-migration-checker check migration.sql --format json
localtools-postgres-migration-checker check V1__users.sql V2__index.sql --pg 17 --transaction auto
localtools-postgres-migration-checker check - --transaction always --fail-on medium --format markdown -o report.md
curl -F 'sql=CREATE INDEX i ON users(email);' http://127.0.0.1:47116/api/check

CLI exit 1 means risk at/above --fail-on (default high), or an input/runtime error; --fail-on never retains findings and exits 0 for a completed report. API fields: sql (takes precedence over files), name, repeatable file, pg (11–18, default 18), transaction (auto/always/never), format (json/markdown/sarif/human). Parse failures are high-risk findings with line/column, so other statements remain visible. Invalid requests return JSON errors with 400/413/422/503.

All paths share limits: 100 files, 4 MiB aggregate UTF-8 SQL, 5,000 statements, 16 MiB report, 30 seconds per check, two concurrent checks. Workers have a 512 MiB memory budget (Windows job process memory / Unix address space). The API allows 256 KiB form overhead. Inputs over limits are rejected; deep nesting can be rejected earlier by the PostgreSQL parser. Reports write atomically. No input history is stored. Parent-owned job folders are deleted after completion/cancellation; folders left by a hard crash are swept after one hour at the next start.

Engine and scope

Pinned postgast 0.2.0 (BSD-2-Clause) calls the real libpg_query PostgreSQL 18.4 parser/deparser. Typed PostgreSQL AST nodes drive the rules; no regex statement splitting. PostgreSQL 11–18 selects known version-dependent rules, not version-specific grammar validation. The abandoned scaffold used GPL pglast: it is not bundled or imported. Squawk is a good general SQL linter, but its CLI does not supply this tool's per-statement lock model, so a separate linter sidecar is unnecessary.

The portable ZIP bundles CPython 3.13 and all dependencies. PyPI has postgast wheels for Windows x64, Linux x64 and macOS ARM64. A plain Intel macOS PyPI install is unavailable: upstream has no Intel wheel, and its published source archive lacks build headers. Use the self-contained Intel Mac ZIP/one-line installer, 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 BSD dependency wheel is built unmodified from the complete upstream v0.2.0 Git tag and submodules (the archive is not used).

Locks are static estimates, not live observations. Existing schema/data, relations reached through views/triggers/functions/rules, partitions/default partitions, inherited tables, dependencies, search_path resolution and actual durations are unknown. Schema-qualified and unqualified names remain distinct. Newly created tables and validated checks are inferred from the supplied ordered SQL; invalid/rolled-back statements can invalidate those assumptions. Review all examples before use: they can need app changes, synchronization triggers, backups and adaptation to partitioning or schema. No automatic SQL patching is offered.

Framework detection reads real SQL comments: goose Up/Down/NO TRANSACTION, dbmate up/down/transaction:false, Liquibase formatted SQL changesets/runInTransaction:false, and Flyway V…__…sql/R__…sql filenames. Down sections are omitted. Explicit BEGIN/COMMIT is tracked. Rails/Django source code is not SQL; export SQL first and choose the runner transaction mode. Resolve Flyway/Liquibase placeholders before checking. psql command lines/COPY data are skipped with notes. Bodies of functions/DO/dynamic SQL and unmodelled statement kinds are explicitly outside analysis. Runner configuration files, database execution, live schema inspection and lock-time predictions are cut.

Primary references: explicit locking / conflict matrix, ALTER TABLE lock exceptions and rewrite conditions, concurrent index caveats, postgast engine/license, libpg_query. These rules are exercised by the built-executable tests in tests/.

localtools-postgres-migration-checker update / uninstall use the portable installers; package-manager installations print their appropriate commands. MIT license; bundled dependency notices in THIRD_PARTY_NOTICES.md. Bug reports: the public localtools issue form.

Metadata

Release files for localtools-postgres-migration-checker 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for localtools-postgres-migration-checker 1.0.0
File Size Uploaded Provenance Actions
localtools_postgres_migration_checker-1.0.0.tar.gz 108.7 kB Without provenance Details for localtools_postgres_migration_checker-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for localtools-postgres-migration-checker 1.0.0
File Interpreter ABI Platform Actions
localtools_postgres_migration_checker-1.0.0-py3-none-any.whl Python 3 none any Details for localtools_postgres_migration_checker-1.0.0-py3-none-any.whl

Total release size: 215.9 kB

Release files / localtools_postgres_migration_checker-1.0.0.tar.gz

Download URL localtools_postgres_migration_checker-1.0.0.tar.gz
Size 108.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2ac3c974ee5b3e11c3f31c3783f4cddb384de26fc91416035bfadc643cc35a24
BLAKE2b-256 checksum
How to use checksums
712c294421969a244b2b04b20b7a8c320406fccfea3eaad5ec8472fbda61a3f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / localtools_postgres_migration_checker-1.0.0-py3-none-any.whl

Download URL localtools_postgres_migration_checker-1.0.0-py3-none-any.whl
Size 107.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bfb1f80e1ade1ed1511a95b00f6de2b154d2ea78dec5193290f4b61aa6faea0d
BLAKE2b-256 checksum
How to use checksums
997495909c7eab2c126cb6343a25f50a0e1459c88cea5563e743c661b68db177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for localtools-postgres-migration-checker 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page