squawk

linter for Postgres migrations that prevents downtime for migrations and backwards incompatible changes.

Why?

Prevent unexpected downtime caused by database migrations.

Also it seemed like a nice project to spend more time with Rust.

prior art

related tools

related blog posts / SE Posts / PG Docs

dev

shell cargo install cargo test cargo run cargo clippy -- -W clippy::nursery cargo fmt

how it works

squawk wraps calls to libpgquery-sys in a safe interface and parses the JSON into eaiser to work with structures. libpgquery-sys in turn uses bindgen to bind to libpg_query, which itself wraps Postgres' SQL parser in a bit of C code that outputs the parsed AST into a JSON string.

Squawk then runs the rule functions over the parsed AST, gathers and pretty prints the rule violations.