-- =============================================
-- 2026-07-15 表字段变更增量脚本
-- 执行: mysql -u<user> -p<db> < todo.sql
-- =============================================

SET NAMES utf8mb4;

-- =============================================
-- org_equipment 表
-- =============================================

-- 1. instrument_type_code → industry_code 行业code
ALTER TABLE `org_equipment` CHANGE COLUMN `instrument_type_code` `industry_code` varchar(32) DEFAULT NULL COMMENT '行业code';

-- =============================================
-- org_business_scope_device_ref 表
-- =============================================

-- 2. device_code → device_type_code 设备类型code
ALTER TABLE `org_business_scope_device_ref` CHANGE COLUMN `device_code` `device_type_code` varchar(32) DEFAULT NULL COMMENT '设备类型code';

-- 3. device_name → device_type_name 设备类型名称
ALTER TABLE `org_business_scope_device_ref` CHANGE COLUMN `device_name` `device_type_name` varchar(200) DEFAULT NULL COMMENT '设备类型名称';


-- org_personnel_cert 表添加 business_scope 字段
ALTER TABLE `org_personnel_cert`
    ADD COLUMN `business_scope` varchar(500) DEFAULT NULL COMMENT '备案安全评价业务范围' AFTER `cert_attachment_url`;

-- qual_filing_personnel_cert 表添加 business_scope 字段
ALTER TABLE `qual_filing_personnel_cert`
    ADD COLUMN `business_scope` varchar(500) DEFAULT NULL COMMENT '备案安全评价业务范围' AFTER `source_cert_id`;

-- qual_filing_personnel_cert_change 表添加 business_scope 字段
ALTER TABLE `qual_filing_personnel_cert_change`
    ADD COLUMN `business_scope` varchar(500) DEFAULT NULL COMMENT '备案安全评价业务范围' AFTER `source_cert_id`;


-- org_personnel_cert 表添加 专业能力编码 字段
ALTER TABLE `org_personnel_cert`
    ADD COLUMN `professional_capability_code` VARCHAR(64) DEFAULT NULL COMMENT '专业能力编码' AFTER `business_scope`;

-- qual_filing_personnel_cert 表添加 专业能力编码 字段
ALTER TABLE `qual_filing_personnel_cert`
    ADD COLUMN `professional_capability_code` VARCHAR(64) DEFAULT NULL COMMENT '专业能力编码' AFTER `business_scope`;

-- qual_filing_personnel_cert_change 表添加 专业能力编码 字段
ALTER TABLE `qual_filing_personnel_cert_change`
    ADD COLUMN `professional_capability_code` VARCHAR(64) DEFAULT NULL COMMENT '专业能力编码' AFTER `business_scope`;

-- 1. org_personnel_cert 表添加行业专业标准ID字段
ALTER TABLE `org_personnel_cert`
    ADD COLUMN `industry_professional_standards_id` BIGINT DEFAULT NULL COMMENT '行业专业标准ID'
    AFTER `professional_capability_code`;

-- =============================================
-- eval_process_control 表添加归档交接单字段
-- =============================================
ALTER TABLE `eval_process_control`
    ADD COLUMN `handover_form_url` varchar(500) DEFAULT NULL COMMENT '归档交接单URL' AFTER `archive_flag`;

ALTER TABLE `eval_process_control`
    ADD COLUMN `handover_form_status` varchar(32) DEFAULT 'not_create' COMMENT '归档交接单状态(not_create未生成,created已生成)' AFTER `handover_form_url`;

-- 2. qual_filing_personnel_cert 表添加行业专业标准ID字段
ALTER TABLE `qual_filing_personnel_cert`
    ADD COLUMN `industry_professional_standards_id` BIGINT DEFAULT NULL COMMENT '行业专业标准ID'
    AFTER `professional_capability_code`;

-- 3. qual_filing_personnel_cert_change 表添加行业专业标准ID字段
ALTER TABLE `qual_filing_personnel_cert_change`
    ADD COLUMN `industry_professional_standards_id` BIGINT DEFAULT NULL COMMENT '行业专业标准ID'
    AFTER `professional_capability_code`;