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

+35 -2
View File
@@ -68,6 +68,16 @@ export const DOCUMENT_AI_RUN_RESULT_AAD = "healthlog/document-ai-run-result/v1";
*/
export const ENVIRONMENT_LOCATION_AAD = "healthlog/environment-location/v1";
/**
* The associated-data labels for the Dawarich context (v1.43): the sealed
* connection preferences on the user row (home place id, home country,
* dismissed travel suggestions) and each stored day's country code. Labelled
* like the environment locations, each with its own label so a country code
* never opens as a location or as the preferences.
*/
export const DAWARICH_PREFS_AAD = "healthlog/dawarich-prefs/v1";
export const DAWARICH_DAY_COUNTRY_AAD = "healthlog/dawarich-day-country/v1";
export interface EncryptedColumn {
/** Prisma model name (PascalCase, as declared in schema.prisma). */
readonly model: string;
@@ -149,6 +159,9 @@ export const ENCRYPTED_COLUMNS: readonly EncryptedColumn[] = [
{ model: "User", field: "googleHealthClientSecretEncrypted", kind: "string" },
{ model: "User", field: "nightscoutUrlEncrypted", kind: "string" },
{ model: "User", field: "nightscoutTokenEncrypted", kind: "string" },
// v1.43 — Dawarich connection (URL and API key, like the Nightscout pair).
{ model: "User", field: "dawarichUrlEncrypted", kind: "string" },
{ model: "User", field: "dawarichApiKeyEncrypted", kind: "string" },
{ model: "User", field: "polarAccessTokenEncrypted", kind: "string" },
{ model: "User", field: "polarUserIdEncrypted", kind: "string" },
{ model: "User", field: "polarClientIdEncrypted", kind: "string" },
@@ -408,8 +421,8 @@ export const ENCRYPTED_COLUMNS: readonly EncryptedColumn[] = [
// ───── v1.42 environment locations (Bytes, binary2) ─────
// The coarse home, each dated location period, and each day's resolved
// location, sealed as (lat, lon, label) under one label. The plaintext
// columns beside them empty as the encryption backfill runs.
// location, sealed as (lat, lon, label) under one label. The only copy since
// v1.43 (migration 0409 dropped the plaintext columns).
{
model: "User",
field: "homeLocationEncrypted",
@@ -432,6 +445,25 @@ export const ENCRYPTED_COLUMNS: readonly EncryptedColumn[] = [
aad: ENVIRONMENT_LOCATION_AAD,
},
// ───── v1.43 Dawarich context (Bytes, binary2) ─────
// The connection preferences (a place id on the Dawarich instance, the home
// country, dismissed travel suggestions) and each day's country code. Daily
// values only; no coordinate or place name is ever stored.
{
model: "User",
field: "dawarichPrefsEncrypted",
kind: "bytes",
codec: "binary2",
aad: DAWARICH_PREFS_AAD,
},
{
model: "DawarichDay",
field: "countryCodeEncrypted",
kind: "bytes",
codec: "binary2",
aad: DAWARICH_DAY_COUNTRY_AAD,
},
// ───── v1.38.0 dose free text (Bytes column) ─────
// What the person wrote about the dose — a reaction, a sore arm, why the
// schedule went the way it did. The Pass's own structured fields stay
@@ -583,6 +615,7 @@ export const UPDATED_AT_MODELS: ReadonlySet<string> = new Set([
"CoachPlan",
"CoachReminder",
"CycleDayLog",
"DawarichDay",
"DocumentContentIndex",
"DocumentSourceConnection",
"DocumentThumbnail",