mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
chore(schema): deploy medication_schedules.days_of_week column
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) <noreply@anthropic.com>
This commit is contained in:
1 parent
3f60c81b9e
commit
0eda1de16f
1 file changed
+17
@@ -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;
|
||||
Reference in new issue
Block a user