-- 修改iot_device_data表的delivery_id字段，关联到delivery表的主键
-- 将delivery_id改为整数类型，关联delivery表的id字段

ALTER TABLE `iot_device_data` 
MODIFY COLUMN `delivery_id` int(11) DEFAULT NULL COMMENT '装车订单ID，关联delivery表主键';

-- 添加外键约束（可选）
-- ALTER TABLE `iot_device_data` 
-- ADD CONSTRAINT `fk_iot_device_delivery` 
-- FOREIGN KEY (`delivery_id`) REFERENCES `delivery`(`id`) ON DELETE SET NULL;
