Files
HealthLog/prisma/migrations/0137_v11518_dose_windows/migration.sql
T
Marc-André Bombeck 9bb68ade8a feat(medications): persist a per-dose configurable intake window
Add `doseWindows` (Json?) to MedicationSchedule: a nullable array of
`{ timeOfDay, start, end }` HH:mm triples naming an explicit on-time
range for a dose time (e.g. 07:00–09:00). A time with no entry keeps the
symmetric ±1h default; a NULL column leaves every slot on the default
derivation, so the migration is additive and changes no existing
behaviour. Migration 0137 adds the column with no backfill.
2026-06-08 18:29:05 +02:00

19 lines
947 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- v1.15.18 — per-dose configurable intake WINDOW.
--
-- Marc's "07:00–09:00" lever: a dose time can carry an explicit on-time RANGE
-- instead of the symmetric ±1h default the band minter derives. The column is
-- a nullable JSON array of `{ timeOfDay, start, end }` HH:mm triples, one per
-- dose time the user gave an explicit window for, e.g.
-- [{ "timeOfDay": "07:00", "start": "07:00", "end": "09:00" }]
--
-- The band minter reads it to build the on-time band from `[start, end]` for
-- the matching `timeOfDay`; a time with no entry keeps the default ±1h
-- derivation, and a NULL column leaves every slot on the default (unchanged
-- behaviour). The late tail stays cadence-derived.
--
-- Additive + non-destructive: a new nullable column with no backfill. Existing
-- rows read NULL and behave exactly as before; the iOS contract gains an
-- optional field.
ALTER TABLE "medication_schedules"
ADD COLUMN "dose_windows" JSONB;