Squawk
A linter for Postgres migrations
Prevent Downtime
Lint your schema changes and prevent blocking reads / writes.
GitHub Integration
Use the Squawk GitHub App to lint your pull requests.
Open Source
squawk
is open source and written in Rust. Install it with npm install squawk-cli
.
Rules
Prevent schema mistakes
rule name | description |
---|---|
ban-char-field | Prevent mistaken use of character type in schema. |
prefer-big-int | Deprecated. See prefer-bigint-over-int and prefer-bigint-over-smallint instead. |
prefer-bigint-over-int | Prevent hitting the 32 bit max int limit. |
prefer-bigint-over-smallint | Prevent hitting the 16 bit max int limit. |
prefer-identity | Serial types have confusing behaviors. Use identity columns instead. |
prefer-timestamptz | Ensure consistent timezone handling for timestamps, regardless of your database session timezone. |
ban-concurrent-index-creation-in-transaction | Prevent forbidden use of transactions during concurrent index creation. |
Make backwards compatible schema changes
rule name | description |
---|---|
adding-required-field | Prevent adding a new required field to an existing table. |
ban-drop-database | Prevent breaking existing clients that depend on the database. |
ban-drop-not-null | Prevent breaking existing clients that don't expect NULL values. |
ban-drop-table | Prevent breaking existing clients that depend on the table. |
changing-column-type | Prevent breaking existing clients that depend on column type. Prevent blocking reads/writes to table while table is rewritten. |
renaming-column | Prevent breaking existing clients that depend on column. |
renaming-table | Prevent breaking existing clients that depend on table. |
Apply schema changes safely
rule name | description |
---|---|
adding-field-with-default | Prevent blocking reads/writes to table while table is rewritten on PG < 11. |
adding-foreign-key-constraint | Prevent blocking writes to tables while verifying foreign key constraint. |
adding-not-nullable-field | Prevent blocking reads/writes to table while table is scanned on PG < 11. |
adding-serial-primary-key-field | Prevent blocking reads/writes to table while index is built. |
changing-column-type | Prevent breaking existing clients that depend on column type. Prevent blocking reads/writes to table while table is rewritten. |
constraint-missing-not-valid | Prevent blocking writes to the table while the scan occurs. |
disallowed-unique-constraint | Prevent blocking reads/writes to table while index is built. |
prefer-robust-stmts | Ensure migrations are atomic or retriable. |
prefer-text-field | Prevent blocking reads and writes to table while table metadata is updated. |
require-concurrent-index-creation | Prevent blocking writes to table while index is created. |
require-concurrent-index-deletion | Prevent blocking reads/writes to table while index is dropped. |
transaction-nesting | Ensure migrations use transactions correctly. |