Files
Cibello-app/infrastructure/migrations/0017_cooking_sessions_meal_date.sql
T
Sven (AAMOS AI) fadd7692b2 docs(3d): restore FAS3 audit doc from cb49301 + add 3d semantics
- Restore full docs/FAS3-COOKING-SESSIONS-AUDIT.md from cb49301
  (hermetic test rules, REUSE/GAP matrix, anti-duplication rationale,
  step plans 3a-3d). Append section 7 with 3d merge/undo semantics.
- Update 7.6 wrapper reference to c1ab2c8 behaviour.
- Fix migration 0017: cast completed_at/started_at/created_at to UTC
  before extracting DATE. Idempotent (WHERE meal_date IS NULL); already
  backfilled rows unaffected. Runner does not checksum files.
- Clarify meal_date purpose: future UTC statistics/queries; undo uses
  stored mealBoxMutations.

Refs: cb49301, c1ab2c8
2026-08-07 17:24:15 +07:00

8 lines
648 B
SQL

-- Fas 3d: spara måltidsdatum på cooking session (UTC) för framtida
-- statistik, gruppering och analys; undo använder lagrade mealBoxMutations.
ALTER TABLE cooking_sessions ADD COLUMN IF NOT EXISTS meal_date DATE;
-- Bakåtfyll: använd UTC-datumet för befintliga sessioner.
UPDATE cooking_sessions SET meal_date = (completed_at AT TIME ZONE 'UTC')::DATE WHERE meal_date IS NULL AND completed_at IS NOT NULL;
UPDATE cooking_sessions SET meal_date = (started_at AT TIME ZONE 'UTC')::DATE WHERE meal_date IS NULL AND started_at IS NOT NULL;
UPDATE cooking_sessions SET meal_date = (created_at AT TIME ZONE 'UTC')::DATE WHERE meal_date IS NULL;