From 8b79ed89c857dfcd9830511959be94614bda073c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 14 May 2026 13:50:38 +0200 Subject: [PATCH] chore(schema): medication_schedules @map to snake_case (cosmetic + convention) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `windowStart` / `windowEnd` columns on `medication_schedules` were the last hold-outs using the camelCase identifier from 0001_init.sql; every other column on the table already follows the snake_case convention. Adding `@map("window_start")` / `@map("window_end")` aligns the SQL identifier without changing the Prisma client surface — every read/write site continues to use the TypeScript-side `windowStart` / `windowEnd` names verbatim. Migration 0047 renames the columns in place — no data movement, no index churn, no FK changes. Forward-only. --- .../migration.sql | 24 +++++++++++++++++++ prisma/schema.prisma | 11 +++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 prisma/migrations/0047_medication_schedule_window_snake_case/migration.sql diff --git a/prisma/migrations/0047_medication_schedule_window_snake_case/migration.sql b/prisma/migrations/0047_medication_schedule_window_snake_case/migration.sql new file mode 100644 index 000000000..0dfd81ac6 --- /dev/null +++ b/prisma/migrations/0047_medication_schedule_window_snake_case/migration.sql @@ -0,0 +1,24 @@ +-- v1.4.25 W4e — medication_schedules @map to snake_case (cosmetic + +-- convention). +-- +-- Prior to this migration `medication_schedules.windowStart` and +-- `medication_schedules.windowEnd` were the only columns on the model +-- that still used the camelCase identifier from the original +-- 0001_init.sql — every other column on the table (medication_id, +-- days_of_week) already follows the snake_case convention enforced +-- everywhere else in the schema. The drift was harmless (Prisma's +-- generated client uses the TypeScript-side `windowStart` / +-- `windowEnd` names regardless of the SQL identifier), but the +-- inconsistency tripped reviewers and made `grep window_start +-- prisma/migrations/` return zero rows. +-- +-- The rename is purely a rename — the data does not move, no indexes +-- change, no foreign keys are affected. We use IF EXISTS so a +-- replayed migration on a fresh-from-schema DB (Prisma's `db push` +-- against a brand-new local) doesn't blow up trying to rename a +-- column that the schema-pushed shape already named snake_case. +-- +-- Forward-only; no DOWN migration. + +ALTER TABLE "medication_schedules" RENAME COLUMN "windowStart" TO "window_start"; +ALTER TABLE "medication_schedules" RENAME COLUMN "windowEnd" TO "window_end"; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1665e010f..4920c0ca2 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -372,8 +372,15 @@ model Medication { model MedicationSchedule { id String @id @default(cuid()) medicationId String @map("medication_id") - windowStart String // HH:mm format, e.g. "08:00" - windowEnd String // HH:mm format, e.g. "10:00" + /// v1.4.25 W4e — schema-convention fix. Prior to this release the DB + /// columns were the camelCase identifiers `"windowStart"` / `"windowEnd"` + /// because the original 0001_init migration omitted `@map`. The + /// Prisma client surface stays unchanged (`windowStart` / + /// `windowEnd`); only the underlying SQL identifier is renamed to + /// match the snake_case convention every other column on this model + /// already follows. + windowStart String @map("window_start") // HH:mm format, e.g. "08:00" + windowEnd String @map("window_end") // HH:mm format, e.g. "10:00" label String? // e.g. "Morning", "Evening" dose String? // Per-schedule dose override; null = use Medication.dose daysOfWeek String? @map("days_of_week") // Comma-separated day numbers (0=Sun..6=Sat), null = daily