delete from public.company_members cm
using public.profiles p
where p.id = cm.profile_id
  and p.role = 'external';

update public.profiles
set company_id = null
where role = 'external'
  and company_id is not null;
