mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 04:32:42 +00:00
feat(db): add user.researchMode acknowledgment fields for GLP-1 PK chart
Three columns gate the opt-in GLP-1 PK research-view chart behind an undismissable MDR-disclaimer dialog (research §2.3, §11): research_mode_enabled — master switch, default false. research_mode_acknowledged_at — timestamp of the latest ack. research_mode_acknowledged_version — copy version the user read. Versioning the acknowledgment lets the Settings UI re-prompt when the disclaimer copy drifts ahead of the persisted value, so a copy update cannot quietly keep the chart visible to a user who has not read the new wording. Migration 0058 uses ADD COLUMN IF NOT EXISTS to mirror 0057's idempotent posture.
This commit is contained in:
1 parent
64089e56da
commit
5eeedd7202
2 files changed
+57
No files matched your search
@@ -0,0 +1,35 @@
|
||||
-- v1.4.25 W19c — Research Mode acknowledgment fields.
|
||||
--
|
||||
-- Adds three columns to the `users` table that together gate the
|
||||
-- opt-in GLP-1 PK research-view chart behind an undismissable
|
||||
-- MDR-disclaimer dialog (research §2.3 + §11). The chart never
|
||||
-- renders unless `research_mode_enabled = true`, and the dialog
|
||||
-- only flips that flag after the user explicitly acknowledges the
|
||||
-- disclaimer copy at a specific version.
|
||||
--
|
||||
-- research_mode_enabled — master on/off switch.
|
||||
-- Default `false` keeps the
|
||||
-- chart hidden for every
|
||||
-- existing user.
|
||||
-- research_mode_acknowledged_at — timestamp of the most
|
||||
-- recent acknowledgment.
|
||||
-- NULL when the user has
|
||||
-- never acknowledged.
|
||||
-- research_mode_acknowledged_version — string identifier of the
|
||||
-- disclaimer copy version
|
||||
-- the user acknowledged
|
||||
-- (e.g. "2026-05-14.1"). The
|
||||
-- Settings UI re-prompts when
|
||||
-- the version drifts ahead
|
||||
-- of the persisted value, so
|
||||
-- copy updates cannot quietly
|
||||
-- keep the chart visible.
|
||||
--
|
||||
-- The `IF NOT EXISTS` guards make the migration idempotent — if any
|
||||
-- column landed via a prior dev-DB hand-edit, the migration still
|
||||
-- runs cleanly to completion (mirrors the 0057 onboarding-step
|
||||
-- migration's posture).
|
||||
ALTER TABLE "users"
|
||||
ADD COLUMN IF NOT EXISTS "research_mode_enabled" BOOLEAN NOT NULL DEFAULT false,
|
||||
ADD COLUMN IF NOT EXISTS "research_mode_acknowledged_at" TIMESTAMP(3),
|
||||
ADD COLUMN IF NOT EXISTS "research_mode_acknowledged_version" TEXT;
|
||||
@@ -159,6 +159,28 @@ model User {
|
||||
// work.
|
||||
sourcePriorityJson Json? @map("source_priority_json")
|
||||
|
||||
// v1.4.25 W19c — Research Mode acknowledgment for the opt-in GLP-1
|
||||
// PK research-view chart. The chart is hidden behind a per-user
|
||||
// flag that is set to `true` only after the user has dismissed an
|
||||
// undismissable MDR-disclaimer dialog. The `researchModeAcknowledged*`
|
||||
// pair records exactly *which version* of the disclaimer copy the
|
||||
// user has read; when the disclaimer copy changes (e.g. EMA guidance
|
||||
// update, new drug added), the Settings surface re-prompts the user
|
||||
// and refuses to surface the chart until the new version is
|
||||
// acknowledged. Keeping the version on the user row (instead of an
|
||||
// append-only audit table) is intentional — the Coach refusal layer
|
||||
// and the chart-render guard both need a cheap synchronous read.
|
||||
//
|
||||
// `researchModeEnabled = false` is the safe default — the chart
|
||||
// never renders without an explicit opt-in. The DELETE branch of
|
||||
// the API endpoint sets all three columns back to NULL/false so a
|
||||
// user who turns Research Mode off must re-acknowledge the
|
||||
// disclaimer if they ever turn it back on, even if the version
|
||||
// hasn't changed in the interim.
|
||||
researchModeEnabled Boolean @default(false) @map("research_mode_enabled")
|
||||
researchModeAcknowledgedAt DateTime? @map("research_mode_acknowledged_at")
|
||||
researchModeAcknowledgedVersion String? @map("research_mode_acknowledged_version")
|
||||
|
||||
// v1.4.25 W6c — Doctor-report section toggles.
|
||||
// Shape:
|
||||
// { "bp": boolean,
|
||||
|
||||
Reference in new issue
Block a user