Files
medreport_mrb2b/supabase/migrations/20250722110506_super_admin_fix.sql
Danel Kungla 86b86c6752 add health benefit form
fix super admin
2025-07-23 16:33:24 +03:00

32 lines
838 B
PL/PgSQL

grant
execute on function medreport.get_account_members (text) to authenticated,
service_role;
create or replace function medreport.is_company_admin(account_slug text)
returns boolean
set search_path = ''
language plpgsql
as $$
declare
is_owner boolean;
begin
select exists (
select 1
from medreport.accounts_memberships am
join medreport.accounts a on a.id = am.account_id
where am.user_id = auth.uid()
and am.account_role = 'owner'
and a.slug = account_slug
) into is_owner;
return is_owner;
end;
$$;
grant execute on function medreport.is_company_admin(text) to authenticated, service_role;
grant
execute on function medreport.team_account_workspace (text) to authenticated,
service_role;
grant execute on function medreport.get_account_invitations(text) to authenticated, service_role;