feat: Enhance reservation functionality

This commit is contained in:
2026-04-22 10:23:22 -04:00
parent 7f1e82acc2
commit 534d66c774
25 changed files with 1236 additions and 91 deletions

View File

@@ -0,0 +1,20 @@
-- Prevent members from modifying (cancelling or editing) reservations whose
-- session has already started. Admins bypass this via service-role updates;
-- the trigger only fires on connections where auth.uid() is a non-admin member.
-- For simplicity we enforce it for all non-service-role connections.
create or replace function public.prevent_past_reservation_updates()
returns trigger
language plpgsql
as $$
begin
if old.start_time < now() then
raise exception 'past_reservation: Reservations that have already started cannot be modified.';
end if;
return new;
end;
$$;
create trigger check_past_reservation_update
before update on public.reservations
for each row execute function public.prevent_past_reservation_updates();