Skip to content

Migrations: Squawk on each new migration's SQL (sc-9611) - #268

Open
ndbroadbent wants to merge 4 commits into
ci-provenancefrom
ci-squawk
Open

ndbroadbent wants to merge 4 commits into
ci-provenancefrom
ci-squawk

Conversation

@ndbroadbent

@ndbroadbent ndbroadbent commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Eleventh PR for sc-9611: Squawk 2.74.0 (pinned in mise.toml) on new migrations. It's stacked on #267.

The migrations' SQL lives in Rust strings: raw-string consts, or literals passed straight to tx.query(...), \ line continuations included. scripts/ci/squawk_migrations.sh copies each new migration's SQL into a .sql file and runs Squawk on those. A migration whose SQL it can't find, such as a format! string, fails, so nothing passes unchecked. It runs in CI's migrations job, against the PR's or push's base, and in the pre-commit hook on staged migrations. Old migrations aren't checked: production ran them long ago.

.squawk.toml: Postgres 17, with assume_in_transaction because laravel-rust runs each migration in a transaction. Every rule applies except these four, each with its reason in the file:

  • ban-drop-column: migration_safety.py already owns dropped columns, and knows which ones main's code still reads.
  • prefer-identity and prefer-bigint-over-int: BIGSERIAL keys and INT counters are the schema's convention.
  • require-statement-timeout: a backfill may run long. The required lock_timeout is what keeps traffic unblocked.

What it catches, run against the existing migrations: 7 had no lock_timeout (every migration since 8 Dec sets one), 2 added foreign keys to existing tables without NOT VALID, and 1 dropped a constraint. AGENTS.md now says how to write these.

require-concurrent-index-creation stays on: CONCURRENTLY can't run in a transaction, so an index on an existing table blocks its writes while it builds. On a small table, a listed -- squawk-ignore with the table's size is the way through.

It starts green: there are no new migrations. Of the five newest, four pass; diff_comment_images (a plain-string migration) has no lock_timeout. A planted older migration fails. -- squawk-ignore <rule> silences a single finding; the suppression check from #264 learns that form, so each one is listed with its reason.

…VALID foreign keys), in the hook and the migrations job (sc-9611)
…th no readable SQL fails, and require-concurrent-index-creation is back on (review)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant