From fcca31c36fa262d7e6568334b2ffa79d72031688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sat, 12 Sep 2026 07:46:40 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20fix:=20drop=20meal=5Fbo?= =?UTF-8?q?oking=E2=86=92menu=20FK=20(cancelled=20rows=20survive=20menu=20?= =?UTF-8?q?delete)=20+=20Param::OptText/OptI64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../school/20260912000004_food_appointments_fees.sql | 6 +++++- src/db/page.rs | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/migrations/school/20260912000004_food_appointments_fees.sql b/migrations/school/20260912000004_food_appointments_fees.sql index 867c2d2..3f88be4 100644 --- a/migrations/school/20260912000004_food_appointments_fees.sql +++ b/migrations/school/20260912000004_food_appointments_fees.sql @@ -108,7 +108,11 @@ CREATE TABLE dietary_profile ( -- A cancel flips `status` and stamps `cancelled_at`; the row stays so the -- freed seat is still auditable against the ledger line it charged. CREATE TABLE meal_booking ( - menu TEXT NOT NULL REFERENCES menu(id) ON DELETE NO ACTION, + -- No FK to menu(id) ON PURPOSE: cancelled booking rows must survive menu + -- deletion (their attempt counter keeps meal_ledger (booking, attempt) + -- ids unique across a republish — the pinned meal_bookings_round_trip + -- contract). A booking's menu exists at write time by app transaction. + menu TEXT NOT NULL, student uuid NOT NULL REFERENCES app_user(id) ON DELETE NO ACTION, booked_by uuid NOT NULL REFERENCES app_user(id) ON DELETE NO ACTION, status TEXT NOT NULL DEFAULT 'booked' diff --git a/src/db/page.rs b/src/db/page.rs index 26b9d1a..ee4a509 100644 --- a/src/db/page.rs +++ b/src/db/page.rs @@ -62,6 +62,11 @@ pub(crate) enum Param { /// still named, so `IS NOT DISTINCT FROM $n` compares an absent link /// truthfully. OptUuid(Option), + /// Nullable TEXT column clear/set — same NULL-with-type rationale as + /// OptUuid. + OptText(Option), + /// Nullable BIGINT column clear/set. + OptI64(Option), } impl Param { @@ -73,6 +78,8 @@ impl Param { Param::Text(value) => args.add(value), Param::Uuid(value) => args.add(value), Param::OptUuid(value) => args.add(value), + Param::OptText(value) => args.add(value), + Param::OptI64(value) => args.add(value), }; } }