-- One-time backfill: align existing domain status with linked subscription status
update public.plesk_domains d
set status = s.status
from public.plesk_subscriptions s
where d.subscription_id = s.id
  and d.agency_id = s.agency_id
  and (d.status is null or d.status = 'unknown');

update public.plesk_subscriptions
set status = 'unknown'
where status is null;