diff --git a/apps/hq/src/series.ts b/apps/hq/src/series.ts index 3effca5..28572d0 100644 --- a/apps/hq/src/series.ts +++ b/apps/hq/src/series.ts @@ -8,6 +8,7 @@ export const TYPE_PREFIX: Record = { export function nextDocNo(db: DB, docType: string, fy: string): string { const prefix = `${TYPE_PREFIX[docType]}/${fy.slice(2)}` db.prepare( + // Portability quirk: ON CONFLICT upsert is SQLite/Postgres dialect (standard SQL has MERGE). `INSERT INTO doc_series (doc_type, fy, prefix, next_seq) VALUES (?, ?, ?, 1) ON CONFLICT (doc_type, fy) DO NOTHING`, ).run(docType, fy, prefix) @@ -21,6 +22,7 @@ export function nextDocNo(db: DB, docType: string, fy: string): string { export function seedSeries(db: DB, docType: string, fy: string, lastUsedSeq: number): void { const prefix = `${TYPE_PREFIX[docType]}/${fy.slice(2)}` db.prepare( + // Portability quirk: ON CONFLICT upsert is SQLite/Postgres dialect (standard SQL has MERGE). `INSERT INTO doc_series (doc_type, fy, prefix, next_seq) VALUES (?, ?, ?, ?) ON CONFLICT (doc_type, fy) DO UPDATE SET next_seq = excluded.next_seq`, ).run(docType, fy, prefix, lastUsedSeq + 1)