Files
cattleTransportation/tradeCattle/fix_delivery_id_relation.sql
2025-10-23 17:28:06 +08:00

11 lines
472 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 修改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;