Introduction
Linter for dangerous Postgres migration patterns in Diesel and SQLx. Prevents downtime caused by unsafe schema changes.
✓ Detects operations that lock tables or cause downtime
✓ Provides safe alternatives for each blocking operation
✓ Supports safety-assured blocks for verified operations
✓ Extensible with custom checks
✓ Works standalone or with any AI agent (Claude, Codex, Copilot, Gemini)
⭐ If this looks useful, a star on GitHub helps more developers find it.
How It Works
diesel-guard analyzes your migration SQL using Postgres’s own parser (pg_query via libpg_query) and checks each statement against a set of safety rules. When it finds a potentially dangerous operation, it reports:
- The operation — what SQL was detected
- The problem — what lock it acquires, why it’s dangerous, and under what conditions
- A safe alternative — a step-by-step approach that achieves the same goal without the risk