All rules Rule SL028 · IX
SQLite · alpha
critical
IX · Index hygiene
free in the CLI — --engine=sqlite

Index on a non-deterministic expression

Critical — SQLite refuses the statement, so the migration fails here.

What it catches

An index expression must give the same answer for the same row every time, so SQLite refuses random(), changes(), last_insert_rowid() and their kin in CREATE INDEX: "non-deterministic functions prohibited in index expressions". The statement fails and the migration stops.

Fires on

CREATE INDEX orders_shuffle ON orders (id + random());

Do this instead

Index a deterministic expression — lower(), a column arithmetic, a JSON path — or store the value in a column and index that.

CREATE INDEX orders_email_ci ON orders (lower(email));
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