Back to the lesson

Original working file

schema.sql

Code and working example pages keep their original identifiers and sample text. The lesson and file guidance explain them in your language.

create table public.profiles (
 id uuid primary key references auth.users(id) on delete cascade,
 display_name text not null check (char_length(display_name) between 1 and 80)
);
alter table public.profiles enable row level security;
revoke all on public.profiles from anon;
grant select,insert,update on public.profiles to authenticated;
create policy "read own" on public.profiles for select to authenticated using (auth.uid()=id);
create policy "insert own" on public.profiles for insert to authenticated with check (auth.uid()=id);
create policy "update own" on public.profiles for update to authenticated using (auth.uid()=id) with check (auth.uid()=id);