UPDATE platform_models m
SET model_type = b.model_type,
    updated_at = now()
FROM base_model_catalog b
WHERE m.base_model_id = b.id
  AND jsonb_typeof(b.model_type) = 'array'
  AND jsonb_array_length(b.model_type) > 0
  AND m.model_type <> b.model_type
  AND COALESCE(m.capabilities, '{}'::jsonb) = COALESCE(b.capabilities, '{}'::jsonb);
