Files
HealthLog/prisma/migrations/0406_dawarich_context/migration.sql
T
Marc-André Bombeck 6e72de1c35 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.
2026-10-15 21:48:57 +02:00

39 lines
1.4 KiB
SQL

-- Dawarich movement context.
--
-- Per-account sealed connection (URL, API key, preferences) and one row per
-- local day with daily values only: distances in metres, places visited,
-- minutes away from home, and the sealed country code of the day. No
-- coordinate, place name or visit is stored anywhere.
-- AlterTable
ALTER TABLE "users"
ADD COLUMN "dawarich_url_encrypted" TEXT,
ADD COLUMN "dawarich_api_key_encrypted" TEXT,
ADD COLUMN "dawarich_prefs_encrypted" BYTEA,
ADD COLUMN "dawarich_allow_private_host" BOOLEAN NOT NULL DEFAULT false;
-- CreateTable
CREATE TABLE "dawarich_days" (
"id" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"date" VARCHAR(10) NOT NULL,
"total_distance_m" INTEGER,
"driving_distance_m" INTEGER,
"train_distance_m" INTEGER,
"places_visited" INTEGER,
"away_from_home_minutes" INTEGER,
"country_code_encrypted" BYTEA,
"is_travel_day" BOOLEAN,
"fetched_at" TIMESTAMP(3) NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "dawarich_days_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "dawarich_days_user_id_date_key" ON "dawarich_days"("user_id", "date");
-- AddForeignKey
ALTER TABLE "dawarich_days" ADD CONSTRAINT "dawarich_days_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;