fix(db): hold SQLite-only functions, LIKE and the sqlite member of a post-cut migration in lint:dialect

lint:dialect missed several classes of SQL that SQLite reads and Postgres does
not, or reads differently:

- group_concat, ifnull, instr, iif, printf, typeof, total(), changes() and
  json_object/json_array/json_valid/json_type/json_quote, as calls in SQL text
  and as the bare name handed to eb.fn.
- LIKE in SQL text, Kysely's 'like' operator and MikroORM's $like, which ignore
  case on SQLite only. A LIKE that is exact on purpose now says so in a
  like-exact comment; the six existing ones (setting keys, storage paths, the
  lowercased reference search, sqlite_master) carry it.
- The sqlite member of engineDdl was not read at all, so a trigger or a data
  backfill put there never reached Postgres. It may now hold only the schema
  change and a rebuild's copy and sqlite_sequence bookkeeping, and SQLite
  statements with an empty postgres member need a sqlite-only reason.
- execBestEffort, bestEffort and execUnlessTableMissing in a post-cut
  migration: on Postgres a swallowed failure aborts the migration transaction.
- The post-cut rules follow POSTGRES_FIRST_CUT as well as the manifest, so
  regenerating the baseline over a new migration no longer releases it.

src/db/engine/sqlite/ is SQLite's own code and is no longer scanned.
This commit is contained in:
Maurice
2026-11-17 21:36:21 +01:00
parent 9eeb59997e
commit 8c8cfb5d5d
8 changed files with 393 additions and 57 deletions
@@ -129,7 +129,8 @@ export function likeAny<T>(
const terms =
containing === null
? fields.map((field) => ({ [field]: { $ne: null } }))
: fields.flatMap((field) => containing.map((run) => ({ [lower(platform, field)]: { $like: `%${run}%` } })));
: // like-exact: the column is lowercased and the runs are lowercase, so the match ignores case on both engines.
fields.flatMap((field) => containing.map((run) => ({ [lower(platform, field)]: { $like: `%${run}%` } })));
if (terms.length > MAX_LIKE_TERMS) {
logWarn(`[storage] a reference lookup asked for ${terms.length} LIKE terms, more than ${MAX_LIKE_TERMS}`);
throw new Error(`a reference lookup may hold at most ${MAX_LIKE_TERMS} LIKE terms`);