Files
oysqn.app/supabase/migrations/20260421000001_overlap_constraint_exclude_cancelled.sql

13 lines
428 B
SQL

-- The overlap exclusion constraint must not apply to cancelled reservations,
-- so that a cancelled slot can be re-booked by another member.
alter table public.reservations
drop constraint no_overlapping_reservations;
alter table public.reservations
add constraint no_overlapping_reservations
exclude using gist (
boat_id with =,
tstzrange(start_time, end_time, '[)') with &&
) where (status <> 'cancelled');