mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-07 04:12:04 +00:00
feat(profile): add date-format preference column
Mirror the time-format preference with a per-user date display choice. AUTO follows the locale convention, DMY/MDY/YMD pin the field order. Additive, rerun-safe migration; existing rows read AUTO.
This commit is contained in:
1 parent
7f2059bee6
commit
d8ff18948f
2 files changed
+40
No files matched your search
@@ -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';
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user