Skip to main content

Squawk

A linter and language server for Postgres migrations & SQL

Prevent Downtime

Lint your schema changes and prevent blocking reads / writes.

GitHub Integration

Use the Squawk GitHub App to lint your pull requests.

VSCode Support

Squawk's language server and VSCode extension provides linting in your editor.

Rules

Prevent schema mistakes

rule namedescription
ban-char-fieldPrevent mistaken use of character type in schema.
prefer-bigint-over-intPrevent hitting the 32 bit max int limit.
prefer-bigint-over-smallintPrevent hitting the 16 bit max int limit.
prefer-identitySerial types have confusing behaviors. Use identity columns instead.
prefer-timestamptzEnsure consistent timezone handling for timestamps, regardless of your database session timezone.
ban-concurrent-index-creation-in-transactionPrevent forbidden use of transactions during concurrent index creation.
ban-create-domain-with-constraintDomains with constraints have poor support for online migrations
ban-alter-domain-with-add-constraintDomains with constraints have poor support for online migrations
ban-uncommitted-transactionEnsure all transactions are committed

Make backwards compatible schema changes

rule namedescription
adding-required-fieldPrevent adding a new required field to an existing table.
ban-drop-databasePrevent breaking existing clients that depend on the database.
ban-drop-not-nullPrevent breaking existing clients that don't expect NULL values.
ban-drop-tablePrevent breaking existing clients that depend on the table.
changing-column-typePrevent breaking existing clients that depend on column type. Prevent blocking reads/writes to table while table is rewritten.
renaming-columnPrevent breaking existing clients that depend on column.
renaming-tablePrevent breaking existing clients that depend on table.
ban-truncate-cascadeTruncate cascade will recursively truncate all related tables!

Apply schema changes safely

rule namedescription
adding-field-with-defaultPrevent blocking reads/writes to table while table is rewritten on PG < 11.
adding-foreign-key-constraintPrevent blocking writes to tables while verifying foreign key constraint.
adding-not-nullable-fieldPrevent blocking reads/writes to table while table is scanned on PG < 11.
adding-serial-primary-key-fieldPrevent blocking reads/writes to table while index is built.
changing-column-typePrevent breaking existing clients that depend on column type. Prevent blocking reads/writes to table while table is rewritten.
constraint-missing-not-validPrevent blocking writes to the table while the scan occurs.
disallowed-unique-constraintPrevent blocking reads/writes to table while index is built.
prefer-robust-stmtsEnsure migrations are atomic or retriable.
prefer-text-fieldPrevent blocking reads and writes to table while table metadata is updated.
require-concurrent-index-creationPrevent blocking writes to table while index is created.
require-concurrent-index-deletionPrevent blocking reads/writes to table while index is dropped.
transaction-nestingEnsure migrations use transactions correctly.
ban-create-domain-with-constraintDomains with constraints have poor support for online migrations
ban-alter-domain-with-add-constraintDomains with constraints have poor support for online migrations
require-timeout-settingsRequire lock and statement timeouts