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

+9
View File
@@ -811,6 +811,13 @@ const healthProfileBackupSchema = z
aiIncludedSections: z
.array(healthProfileAiSectionSchema)
.default([...DEFAULT_HEALTH_PROFILE_AI_SECTIONS]),
// v1.43 (#614) — section confirmations, section key to ISO instant.
// Carried as stored; the read route judges each stamp, so an unreadable
// one costs a "still true?" prompt rather than the whole restore.
lifeConfirmedJson: z
.record(z.string().max(64), z.string().max(64))
.nullable()
.optional(),
// Emergency profile: three plaintext enums (carried by value in both
// purposes), three free-text columns following the ciphertext-or-plaintext
// split of the self-context fields above.
@@ -2031,6 +2038,8 @@ const accountSettingsBackupSchema = z
insightsPrivacyMode: z.string().optional(),
insightsExcludeMetrics: z.array(z.string()).optional(),
disableCoach: z.boolean().optional(),
// v1.43 (#1217) — the account's AI usage level; the codec checks the value.
aiUsageLevel: z.string().nullable().optional(),
coachPrefsJson: z.unknown().optional(),
documentsAutoAiRead: z.boolean().optional(),
labsLocalOcrEnabled: z.boolean().optional(),
+15
View File
@@ -16,6 +16,21 @@ import { isValidTimezone } from "@/lib/tz/format";
export const assessmentInstrumentEnum = z.enum(["PHQ9", "GAD7", "WHO5", "SCI"]);
/**
* The mental-health screeners, as opposed to every `AssessmentInstrument`.
* Since v1.43 the table also stores AUDIT-C (the alcohol section of the life
* circumstances), which no mental-health surface may list or score: older app
* builds decode `instrument` against exactly these four values.
*/
export const SCREENER_INSTRUMENTS = assessmentInstrumentEnum.options;
export type ScreenerInstrument = (typeof SCREENER_INSTRUMENTS)[number];
export function isScreenerInstrument(
instrument: string,
): instrument is ScreenerInstrument {
return (SCREENER_INSTRUMENTS as readonly string[]).includes(instrument);
}
/**
* Client provenance for an administration. Closed enum so the column can never
* carry a free-form label. `WEB` is the in-app questionnaire (the DB default);