create policy "Allow admins and team members to delete tables"
on "public"."tables"
as permissive
for delete
to authenticated
using ((EXISTS ( SELECT 1
FROM user_roles
WHERE ((user_roles.user_id = ( SELECT auth.uid() AS uid)) AND (user_roles.role = ANY (ARRAY['admin'::text, 'team'::text]))))));
create policy "Allow admins and team members to insert tables"
on "public"."tables"
as permissive
for insert
to authenticated
with check ((EXISTS ( SELECT 1
FROM user_roles
WHERE ((user_roles.user_id = ( SELECT auth.uid() AS uid)) AND (user_roles.role = ANY (ARRAY['admin'::text, 'team'::text]))))));
create policy "Allow admins and team members to select tables"
on "public"."tables"
as permissive
for select
to authenticated
using ((EXISTS ( SELECT 1
FROM user_roles
WHERE ((user_roles.user_id = ( SELECT auth.uid() AS uid)) AND (user_roles.role = ANY (ARRAY['admin'::text, 'team'::text]))))));
create policy "Allow admins and team members to update tables"
on "public"."tables"
as permissive
for update
to authenticated
using ((EXISTS ( SELECT 1
FROM user_roles
WHERE ((user_roles.user_id = ( SELECT auth.uid() AS uid)) AND (user_roles.role = ANY (ARRAY['admin'::text, 'team'::text]))))))
with check ((EXISTS ( SELECT 1
FROM user_roles
WHERE ((user_roles.user_id = ( SELECT auth.uid() AS uid)) AND (user_roles.role = ANY (ARRAY['admin'::text, 'team'::text]))))));