ALTER TABLE client_data_structure_nodes
  ADD COLUMN ai_instructions TEXT NULL AFTER description,
  ADD COLUMN document_type_code VARCHAR(50) NULL AFTER data_type;

ALTER TABLE document_records
  ADD COLUMN client_structure_node_id CHAR(36) NULL AFTER document_type_code,
  ADD COLUMN validation_status VARCHAR(30) NULL AFTER document_status,
  ADD COLUMN validation_confidence DECIMAL(5,4) NULL AFTER validation_status,
  ADD COLUMN validation_reason TEXT NULL AFTER validation_confidence,
  ADD KEY idx_document_records_client_structure_node (client_structure_node_id),
  ADD CONSTRAINT fk_document_records_client_structure_node
    FOREIGN KEY (client_structure_node_id) REFERENCES client_data_structure_nodes (id)
    ON DELETE SET NULL;
