CREATE UNIQUE INDEX IF NOT EXISTS idx_portal_function_visibility_unique_scope
ON public.portal_function_visibility (portal, function_key, COALESCE(owner_user_id, '00000000-0000-0000-0000-000000000000'::uuid));