create table notes (
id uuid primary key default gen_random_uuid(),
user_id uuid not null references auth.users on delete cascade default auth.uid(),
title text not null,
body text not null default '',
created_at timestamptz not null default now()
);
alter table notes enable row level security;
create policy "只能看自己的筆記" on notes for select using (user_id = auth.uid());
create policy "只能新增自己的筆記" on notes for insert with check (user_id = auth.uid());
create policy "只能改自己的筆記" on notes for update using (user_id = auth.uid());
create policy "只能刪自己的筆記" on notes for delete using (user_id = auth.uid());