74f95daab2
- Merge leftovers into existing meal_box when same recipeId + cookedAt date + frozen + available. - Store mealBoxMutations JSONB on cooking_sessions for deterministic undo. - Undo decrements portions/remaining, discards box at zero, appends correction ledger rows. - Mobile: undo button in cooking/[id].tsx after-flow and meal-boxes.tsx within 24h window. - i18n undo strings across all 12 locales; parity test green. - 6 new integration tests: merge, no cross-date merge, frozen split, undo restore, undo discard, ledger invariant. - Update FAS3 audit doc with 3d semantics. Closes Fas 3d
8 lines
593 B
SQL
8 lines
593 B
SQL
-- Fas 3d: spara måltidsdatum på cooking session för att kunna hitta
|
|
-- matlådor som skapades/utökades vid samma tillfälle vid undo.
|
|
ALTER TABLE cooking_sessions ADD COLUMN IF NOT EXISTS meal_date DATE;
|
|
-- Bakåtfyll: använd completedAt-datumet för befintliga completed-sessioner.
|
|
UPDATE cooking_sessions SET meal_date = completed_at::DATE WHERE meal_date IS NULL AND completed_at IS NOT NULL;
|
|
UPDATE cooking_sessions SET meal_date = started_at::DATE WHERE meal_date IS NULL AND started_at IS NOT NULL;
|
|
UPDATE cooking_sessions SET meal_date = created_at::DATE WHERE meal_date IS NULL;
|