Skip to content

Commit 1ccbb8b

Browse files
committed
eng-1837-add-public-status-in-db
1 parent 7084762 commit 1ccbb8b

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CREATE OR REPLACE FUNCTION public.my_user_accounts() RETURNS SETOF UUID
2+
STABLE SECURITY DEFINER
3+
SET search_path = ''
4+
LANGUAGE sql
5+
AS $$
6+
SELECT auth.uid() WHERE auth.uid() IS NOT NULL UNION
7+
SELECT '00000000-0000-0000-0000-000000000000'::uuid UNION
8+
SELECT group_id FROM public.group_membership
9+
WHERE member_id = auth.uid();
10+
$$;
11+
12+
13+
GRANT SELECT ON TABLE public."ResourceAccess" TO anon;
14+
GRANT SELECT ON TABLE public."Document" TO anon;
15+
GRANT SELECT ON TABLE public."Content" TO anon;
16+
GRANT SELECT ON TABLE public."Concept" TO anon;
17+
18+
INSERT INTO auth.users (instance_id, id, aud, role, created_at, updated_at, is_super_user, is_anonymous)
19+
VALUES ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', 'anon', 'anon', '', now(), now(), false, true);

packages/database/supabase/schemas/account.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
-- Anonymous pseudo-user
2+
INSERT INTO auth.users (instance_id, id, aud, role, created_at, updated_at, is_super_user, is_anonymous)
3+
VALUES ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000', 'anon', 'anon', '', now(), now(), false, true);
4+
15
CREATE TYPE public."AgentType" AS ENUM (
26
'person',
37
'organization',
@@ -219,6 +223,7 @@ SET search_path = ''
219223
LANGUAGE sql
220224
AS $$
221225
SELECT auth.uid() WHERE auth.uid() IS NOT NULL UNION
226+
SELECT '00000000-0000-0000-0000-000000000000'::uuid UNION
222227
SELECT group_id FROM public.group_membership
223228
WHERE member_id = auth.uid();
224229
$$;

packages/database/supabase/schemas/content.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,15 @@ CREATE INDEX resource_access_content_local_id_idx ON public."ResourceAccess" (so
183183
GRANT ALL ON TABLE public."ResourceAccess" TO authenticated;
184184
GRANT ALL ON TABLE public."ResourceAccess" TO service_role;
185185
REVOKE ALL ON TABLE public."ResourceAccess" FROM anon;
186+
GRANT SELECT ON TABLE public."ResourceAccess" TO anon;
186187

187188
REVOKE ALL ON TABLE public."Document" FROM anon;
189+
GRANT SELECT ON TABLE public."Document" TO anon;
188190
GRANT ALL ON TABLE public."Document" TO authenticated;
189191
GRANT ALL ON TABLE public."Document" TO service_role;
190192

191193
REVOKE ALL ON TABLE public."Content" FROM anon;
194+
GRANT SELECT ON TABLE public."Content" TO anon;
192195
GRANT ALL ON TABLE public."Content" TO authenticated;
193196
GRANT ALL ON TABLE public."Content" TO service_role;
194197

0 commit comments

Comments
 (0)