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), }; } }