All rules Rule SL011 · OP
SQLite · alpha
warning
OP · Operational safety
free in the CLI — --engine=sqlite

Foreign keys switched off and not back on

Warning — it works, but holds the single write lock or breaks the previous release.

What it catches

PRAGMA foreign_keys=OFF is per connection and does not reset at COMMIT. A migration that turns enforcement off for a rebuild and never turns it on leaves the runner's connection accepting orphans for as long as it lives — every later statement in the run, and any backfill sharing the connection, goes unchecked.

Fires on

PRAGMA foreign_keys = OFF;
DROP TABLE orders;

Do this instead

End the file with PRAGMA foreign_keys=ON, after the transaction that needed it off.

PRAGMA foreign_keys = OFF;
BEGIN;
DROP TABLE orders;
COMMIT;
PRAGMA foreign_keys = ON;
Catch this before it ships

SQLite support is in alpha: this rule runs locally in the free CLI, static only, and not in the hosted service yet: npx bolvrk check migration.sql --engine=sqlite