-- ========================================
-- 08-update-agreement-commercial-structure.sql
-- Actualizar commercial_structure_id en los 420 agreements
-- ========================================

UPDATE agreement a
INNER JOIN commercial_structure cs ON cs.agreement_id = a.id AND cs.general_agent_id = a.agent_id
SET a.commercial_structure_id = cs.id
WHERE a.id >= 968 AND a.id <= 1387;

