aidmt-ms/sql/pc_risk_project_rename_prim...

20 lines
783 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.

-- 将 pc_camera_risk 表的主键从 project_id 重命名为 application_id
-- 同时更新相关外键引用表pc_camera_alloc 和 pc_camera_return
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- 1. 重命名 pc_camera_risk 表的主键
ALTER TABLE `pc_camera_risk`
CHANGE COLUMN `project_id` `application_id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '球机申领单ID';
-- 2. 更新 pc_camera_alloc 表的外键字段
ALTER TABLE `pc_camera_alloc`
CHANGE COLUMN `project_id` `application_id` bigint(0) DEFAULT NULL COMMENT '球机申领单ID关联 pc_camera_risk.application_id';
-- 3. 更新 pc_camera_return 表的外键字段
ALTER TABLE `pc_camera_return`
CHANGE COLUMN `project_id` `application_id` bigint(0) DEFAULT NULL COMMENT '球机申领单ID关联 pc_camera_risk.application_id';
SET FOREIGN_KEY_CHECKS = 1;