From 0eda1de16f43819ad01a3ca57f9652b938385d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Mon, 11 May 2026 01:36:27 +0200 Subject: [PATCH] chore(schema): deploy medication_schedules.days_of_week column MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The schema declared `MedicationSchedule.daysOfWeek` (mapped to `days_of_week`) but no migration ever created the column. Code paths in src/components/medications/*, src/app/api/medications/*, src/app/api/admin/notifications/reminder-check/*, and the achievements route all reference it via the comma-separated "0,1,3,5" recurrence string. Pre-v1.4.23 deploys silently survived because the existing query sites only selected the column on SELECT — Postgres would have failed loudly the moment a user actually saved a non-default recurrence string via the medication form. Migration `0039_medication_schedule_days_of_week` adds the column nullable, default NULL. NULL means "daily" — `parseScheduleRecurrence(null)` already returns the all-7-days set, so existing rows get the correct semantics without backfill. H5 decision rationale: deploy (Option A) over drop (Option B). The field is referenced by 9 source files across 4 user-visible surfaces (medication form, card, intake list, reminder dispatcher). Removing it would force a UI rewrite of the recurrence picker and break existing test fixtures. Deploying matches the schema's stated intent and unblocks the v1.4.21 senior-dev review's MED-5 flag. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../migration.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 prisma/migrations/0039_medication_schedule_days_of_week/migration.sql diff --git a/prisma/migrations/0039_medication_schedule_days_of_week/migration.sql b/prisma/migrations/0039_medication_schedule_days_of_week/migration.sql new file mode 100644 index 000000000..ba95ae6dc --- /dev/null +++ b/prisma/migrations/0039_medication_schedule_days_of_week/migration.sql @@ -0,0 +1,17 @@ +-- v1.4.23 H5 — schema drift fix for medication_schedules.days_of_week. +-- +-- Up to v1.4.22 the column was declared in `schema.prisma` but never +-- migrated. Code paths in src/components/medications/*, +-- src/app/api/medications/*, src/app/api/admin/notifications/reminder-check/* +-- and src/app/api/gamification/achievements/route.ts all reference the +-- field. Pre-v1.4.23 deploys silently relied on Prisma's selecting +-- a non-existent column being tolerated by Postgres for SELECT * style +-- queries — but `prisma.medicationSchedule.create({ data: { daysOfWeek }})` +-- would fail loudly the moment a user supplied a non-default +-- recurrence string. +-- +-- Add the column nullable + default NULL so existing rows mean "daily" +-- (matches the in-code semantics: `parseScheduleRecurrence(null)` +-- returns the all-7-days set). +ALTER TABLE "medication_schedules" +ADD COLUMN IF NOT EXISTS "days_of_week" TEXT;