feat(db): add the v1.43 schema and drop the readable location columns

Migrations 0402 to 0410: AI usage levels, biomarker aliases and merges,
medication ingredients (with the supplement label run kind), life
circumstance fact kinds, AI sections and AUDIT-C, Dawarich context, the
pulse day-mean method, intraday hour buckets, the readable location drop
and five relation link tables. Every new column carries its reader or a
pending-consumer marker.

0409 refuses to run while any home, location period or stored day still
holds a readable location, and names the counts. Locations are read from
the sealed copy only; the encryption backfill no longer handles them, and
the demo seed writes sealed locations only.

The new tables are backed up and wiped, the new sealed columns are in the
rotation registry with labels of their own, the AI usage level and the
life-circumstance confirmations travel with the backup, and the wellbeing
score reads the mental-health screeners only.
This commit is contained in:
Marc-André Bombeck committed 2026-10-15 21:48:57 +02:00
1 parent 0b64b80343
commit 6e72de1c35
45 files changed
+1386 -917

No files matched your search

+3 -2
View File
@@ -30,6 +30,7 @@ import {
type AiRunParams,
type AiRunResult,
type DocumentAiRunKindValue,
servedRunKind,
} from "./types";
/** The longest a client is told to wait between polls. */
@@ -113,7 +114,7 @@ export async function claimAiRun(
return {
id: row.id,
userId: row.userId,
kind: row.kind,
kind: servedRunKind(row.kind),
documentId: row.documentId,
params: row.paramsJson as unknown as AiRunParams,
input,
@@ -252,7 +253,7 @@ export async function readAiRunForUser(
: 0;
return {
id: row.id,
kind: row.kind,
kind: servedRunKind(row.kind),
documentId: row.documentId,
status: unreadable ? "FAILED" : row.status,
result,
+13
View File
@@ -25,6 +25,19 @@ export const DOCUMENT_AI_RUN_KINDS = [
] as const;
export type DocumentAiRunKindValue = (typeof DOCUMENT_AI_RUN_KINDS)[number];
/**
* A stored run's kind as one this build can serve. The database enum may
* carry a kind ahead of its worker (a value added with its migration before
* the run that uses it lands); such a row is refused here rather than handed
* to a dispatcher that has no entry for it.
*/
export function servedRunKind(kind: string): DocumentAiRunKindValue {
if ((DOCUMENT_AI_RUN_KINDS as readonly string[]).includes(kind)) {
return kind as DocumentAiRunKindValue;
}
throw new Error(`document AI run kind not served by this build: ${kind}`);
}
/**
* The capability each kind of run answers to: the one its queuing route asks,
* asked again by the worker for the record before anything leaves.