-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfaces.sql
More file actions
34 lines (27 loc) · 990 Bytes
/
Copy pathfaces.sql
File metadata and controls
34 lines (27 loc) · 990 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
-- BioGlyph community faces table (run in Supabase SQL Editor, bairui-studio)
create table public.faces (
id uuid primary key default gen_random_uuid(),
path jsonb not null check (jsonb_array_length(path) >= 2),
browser_id text not null check (char_length(browser_id) >= 8),
created_at timestamptz not null default now()
);
create index faces_created_at_idx on public.faces (created_at desc);
alter table public.faces enable row level security;
create policy "faces_select_public"
on public.faces for select
to anon, authenticated
using (true);
create policy "faces_insert_public"
on public.faces for insert
to anon, authenticated
with check (jsonb_array_length(path) >= 2);
create policy "faces_delete_own"
on public.faces for delete
to anon, authenticated
using (
browser_id = coalesce(
(current_setting('request.headers', true)::json ->> 'x-browser-id'),
''
)
);
grant select, insert, delete on public.faces to anon, authenticated;