diff --git a/prisma/migrations/0192_v1210_date_format/migration.sql b/prisma/migrations/0192_v1210_date_format/migration.sql new file mode 100644 index 000000000..4cdf65164 --- /dev/null +++ b/prisma/migrations/0192_v1210_date_format/migration.sql @@ -0,0 +1,24 @@ +-- v1.21.0 — per-user date display preference. +-- +-- The UI locale alone decided whether dates rendered as dd.MM.yyyy or +-- MM/dd/yyyy, and the native date input fell back to the browser locale, +-- which left non-US self-hosters on MM/DD/YYYY with no way out. The new +-- column carries an explicit preference: AUTO follows the locale +-- convention, DMY pins day-month-year, MDY pins month-day-year, YMD pins +-- ISO yyyy-MM-dd. Display-time only — stored instants stay UTC. +-- +-- Additive + non-destructive: a new NOT NULL column with a default, no +-- backfill needed. Existing rows read AUTO. Guarded so a re-run is a +-- no-op (the enum create + the column add both skip when present). +DO $$ +BEGIN + IF NOT EXISTS ( + SELECT 1 FROM pg_type WHERE typname = 'date_format_preference' + ) THEN + CREATE TYPE "date_format_preference" AS ENUM ('AUTO', 'DMY', 'MDY', 'YMD'); + END IF; +END +$$; + +ALTER TABLE "users" + ADD COLUMN IF NOT EXISTS "date_format" "date_format_preference" NOT NULL DEFAULT 'AUTO'; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e41c0f57f..18eacb45d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -228,6 +228,11 @@ model User { // (en → AM/PM, de → 24h), H12 forces AM/PM, H24 forces 24-hour. // Display-time only — canonical storage stays UTC instants. timeFormat TimeFormatPreference @default(AUTO) @map("time_format") + // Date display preference. AUTO follows the active locale convention + // (de → dd.MM.yyyy, en → MM/dd/yyyy); DMY pins day-month-year, + // MDY pins month-day-year, YMD pins ISO yyyy-MM-dd. Display-time only — + // canonical storage stays UTC instants. + dateFormat DateFormatPreference @default(AUTO) @map("date_format") // AI provider selection for insights. Null = OPENAI fallback. aiProvider String? @map("ai_provider") // "OPENAI" | "ANTHROPIC" | "LOCAL" | "CHATGPT_OAUTH" aiModel String? @map("ai_model") @@ -973,6 +978,17 @@ enum TimeFormatPreference { @@map("time_format_preference") } +// Date display preference for rendered dates. AUTO defers to the active +// locale's convention; DMY/MDY/YMD pin the field order regardless of locale. +enum DateFormatPreference { + AUTO + DMY + MDY + YMD + + @@map("date_format_preference") +} + enum MeasurementSource { MANUAL WITHINGS