-- Keep raw profile rows private. Public profiles are served through server-side
-- reads that remove hidden/private columns before rendering.

alter table public.profiles enable row level security;

drop policy if exists "profiles_public_read" on public.profiles;
drop policy if exists "profiles_owner_read" on public.profiles;
create policy "profiles_owner_read" on public.profiles
  for select to authenticated using (auth.uid() = id);

revoke all privileges on table public.profiles from public, anon, authenticated;
grant select on table public.profiles to authenticated;
grant all privileges on table public.profiles to service_role;