(d,f,g)=> 🥁
04/21/2022, 8:23 PMsql
create table comments (
comment_id int primary key generated always as identity,
user_id uuid references auth.users default auth.uid(),
blog_slug text not null,
parent_id int references comments,
body text not null check(length(body) between 1 and 2000),
created_at timestamptz not null default now()
);
create index on comments (blog_slug);
create index on comments (parent_id);
alter table comments enable row level security;
create policy select_all on comments for select using (true);
create policy insert_own on comments for insert with check (user_id = auth.uid());
create policy update_own on comments for update using (user_id = auth.uid());
create policy delete_own on comments for delete using (user_id = auth.uid());
this this is all typical stuff, but will these work as i expect? sql
grant select on comments to anon;
grant
insert (blog_slug, body, post_id, parent_id),
update (body),
delete
on comments to authenticated;
Steve
05/02/2022, 5:33 PMSteve
05/02/2022, 5:39 PM