-- Adjuntar la foto del reporte Fitdays (que llega por WhatsApp una vez al mes) a cada evaluacion.
-- Bucket privado: solo el dueno puede ver/subir/borrar sus propias fotos (carpeta = su user id).

alter table public.body_evaluations add column report_image_path text;

insert into storage.buckets (id, name, public)
values ('evaluation-reports', 'evaluation-reports', false)
on conflict (id) do nothing;

create policy "evaluation-reports: owner select" on storage.objects
  for select using (bucket_id = 'evaluation-reports' and (storage.foldername(name))[1] = auth.uid()::text);

create policy "evaluation-reports: owner insert" on storage.objects
  for insert with check (bucket_id = 'evaluation-reports' and (storage.foldername(name))[1] = auth.uid()::text);

create policy "evaluation-reports: owner delete" on storage.objects
  for delete using (bucket_id = 'evaluation-reports' and (storage.foldername(name))[1] = auth.uid()::text);
