Files
HealthLog/prisma/migrations/0058_user_research_mode/migration.sql
T
Marc-André Bombeck 5eeedd7202 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.
2026-05-14 19:50:35 +02:00

36 lines
2.0 KiB
SQL

-- 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;