update inspection_plans
set trigger_type = 'MANUAL',
    schedule_rule = null,
    schedule_config = case
        when schedule_config = '{}'::jsonb then '{"timing":"NOW","migrated_from":"legacy_manual_rule"}'::jsonb
        else schedule_config
    end,
    updated_at = now()
where upper(btrim(coalesce(schedule_rule, ''))) in ('MANUAL', 'ON_DEMAND');
