Files
HealthLog/prisma/migrations/0192_v1210_date_format/migration.sql
T
Marc-André Bombeck d8ff18948f 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.
2026-06-26 12:05:49 +02:00

25 lines
1006 B
SQL

-- 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';