DO $excl$
BEGIN
  IF NOT EXISTS (
    SELECT 1 FROM pg_constraint WHERE conname = 'excl_booking_room_dates'
  ) THEN
    ALTER TABLE public.bookings
      ADD CONSTRAINT excl_booking_room_dates
      EXCLUDE USING gist (
        room_id WITH =,
        daterange(check_in, check_out) WITH &&
      ) WHERE (status NOT IN ('cancelled', 'no_show'));
  END IF;
END;
$excl$;
