Files
acmcc/supabase/migrations/20260417215751_4dea6a93-d8cb-4008-8a26-92e73f2ef50b.sql
2026-06-01 20:19:26 -04:00

15 lines
611 B
PL/PgSQL

CREATE OR REPLACE FUNCTION public.get_cross_association_blocked_dates(_association_ids uuid[])
RETURNS TABLE(id uuid, start_date timestamptz, end_date timestamptz, all_day boolean)
LANGUAGE sql
STABLE
SECURITY DEFINER
SET search_path = public
AS $$
SELECT ce.id, ce.start_date, ce.end_date, ce.all_day
FROM public.calendar_events ce
WHERE ce.association_id IS NOT NULL
AND NOT (ce.association_id = ANY(COALESCE(_association_ids, ARRAY[]::uuid[])))
AND ce.start_date >= (now() - interval '60 days')
$$;
GRANT EXECUTE ON FUNCTION public.get_cross_association_blocked_dates(uuid[]) TO authenticated;