-- Correction du trigger : ON CONFLICT DO NOTHING pour éviter l'échec si le profil existe déjà
create or replace function handle_new_user()
returns trigger as $$
begin
  insert into profiles (id, email, role, statut)
  values (new.id, new.email, 'client', 'actif')
  on conflict (id) do nothing;
  return new;
end;
$$ language plpgsql security definer set search_path = public;
