pg-migration-guard flags risky Postgres migrations before they hit production
A free open-source tool called pg-migration-guard scans PostgreSQL migration files and warns developers about SQL statements that can lock tables and cause downtime. Common hazards it detects include CREATE INDEX without CONCURRENTLY, SET NOT NULL on large tables, and unbatched UPDATE or DELETE operations. The tool integrates with GitHub Actions to fail pull request builds automatically when a risky migration is detected, surfacing inline annotations on the diff. It uses libpg_query — the same SQL parser PostgreSQL itself uses — ensuring accurate analysis without connecting to any database or network. Available via pip for Python 3.8 and above, pg-migration-guard is MIT-licensed and supports JSON output alongside configurable failure thresholds.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in