All rules Rule SL008 · LK
SQLite · alpha
note
LK · Locks & blocking
free in the CLI — --engine=sqlite

ADD COLUMN with a CHECK constraint scans the table

Note — this works, but it is a documented trap or a cost the author may not have meant.

What it catches

Adding a column is normally a schema-only change in SQLite. With a CHECK constraint (or NOT NULL on a generated column) the whole table is scanned to verify existing rows first — under the write lock, proportional to the table's size.

Fires on

ALTER TABLE orders ADD COLUMN priority INTEGER DEFAULT 0 CHECK (priority BETWEEN 0 AND 9);

Do this instead

Add the column without the CHECK when the table is large and the constraint is guaranteed by the default and the application; enforce it in a rebuild later, or accept the scan in a scheduled window.

ALTER TABLE orders ADD COLUMN priority INTEGER DEFAULT 0;
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