docs(db): correct the drift test's own stale references (#305)

The #217 doc comment above the describe block still named db-drizzle/schema.ts, drizzle-kit pull, and "Drizzle infers row types" — a file, a command, and a library this same commit had already removed. A comment pointing at deleted paths is worse than no comment at all on a test whose whole job is proving trust in a generated mirror, so it is corrected to name npm run db:types and src/db-kysely/schema.ts while keeping every sentence of the history intact: #217, #222, item_drafts and upload_links, the week nobody noticed. A closing note was added recording that the generator changed in #305 and the test did not, because the drift it guards is a property of generating a mirror at all rather than of any particular library.

mirroredTables' regex also gets the same digit fix the column check already had. Both regexes parse the same generated file for the same kind of identifier, and a table name with a digit would otherwise be read out of the DB interface but reported missing by mirroredTables, sending someone to regenerate a file that was never wrong.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-04 16:08:47 -05:00
co-authored by Claude Opus 5
parent c71b11e05e
commit 731716f760
@@ -24,7 +24,7 @@ const SCHEMA = readFileSync(
*/
function mirroredTables(): string[] {
const block = /export interface DB \{([^}]*)\}/.exec(SCHEMA)?.[1] ?? '';
return [...block.matchAll(/^\s*([a-z_]+):/gm)].map((m) => m[1]!).sort();
return [...block.matchAll(/^\s*([a-z0-9_]+):/gm)].map((m) => m[1]!).sort();
}
async function liveTables(): Promise<string[]> {
@@ -40,17 +40,21 @@ async function liveTables(): Promise<string[]> {
/**
* The guard for #217.
*
* `src/db-drizzle/schema.ts` is generated by `drizzle-kit pull` and is a
* `src/db-kysely/schema.ts` is generated by `npm run db:types` and is a
* read-only mirror of the real schema, which `backend/migrations` owns. Nothing
* makes anyone re-pull after writing a migration, and that is not hypothetical:
* the mirror sat missing `item_drafts` and `upload_links` from the moment #222
* landed until #217, because it had been copied into src/ by hand and nobody
* had reason to look at it.
* makes anyone regenerate after writing a migration, and that is not
* hypothetical: the mirror sat missing `item_drafts` and `upload_links` from
* the moment #222 landed until #217, because it had been copied into src/ by
* hand and nobody had reason to look at it.
*
* A stale mirror is worse than no mirror. Drizzle infers row types from it, so
* a converted query would type-check against a schema the database does not
* have and fail at run time with a column that does not exist — the exact class
* of drift the adoption was meant to close.
* A stale mirror is worse than no mirror. Row types are inferred from it, so a
* converted query would type-check against a schema the database does not have
* and fail at run time with a column that does not exist — the exact class of
* drift the adoption was meant to close.
*
* The generator changed in #305 and this test did not, because the drift it
* guards is a property of generating a mirror at all rather than of any
* library.
*/
describe('the generated schema mirror', () => {
it('declares every table the migrations create', async () => {