
DELIMITER ??
DROP PROCEDURE
	IF
        NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE () AND TABLE_NAME = 'core_safety_task' AND COLUMN_NAME = 'solid_id' ) THEN
        ALTER TABLE  `core_safety_task` 
			ADD COLUMN `solid_id` bigint NULL COMMENT '固定的id,用于识别多个副本是否属于同一个计划' AFTER `plan_id`;
    END IF;
	IF
       NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE () AND TABLE_NAME = 'core_safecheck_plan' AND COLUMN_NAME = 'publish_time' ) THEN
        	ALTER TABLE `core_safecheck_plan` 
				MODIFY COLUMN `parent_id` bigint NULL DEFAULT -1 COMMENT '下发父计划id' AFTER `id`,
				ADD COLUMN `solid_id` bigint NULL COMMENT '固定的id,用于识别多个副本是否属于同一个计划' AFTER `parent_id`,
				ADD COLUMN `parent_solid_id` bigint NULL COMMENT '固定的parentid,用于识别多个副本是否属于同一个计划' AFTER `solid_id`;
				ADD COLUMN `task_has_completed` int DEFAULT NULL COMMENT '1：表示有已完成的任务',
				ADD COLUMN `publish_time` datetime NULL COMMENT '最后一次下发时间' AFTER `task_has_completed`,
				ADD COLUMN `withdraw_time` datetime NULL COMMENT '最后一次撤回时间' AFTER `publish_time`,
				ADD COLUMN `effective_time` datetime NULL COMMENT '计划生效时间' AFTER `withdraw_time`;
				update core_safecheck_plan set publish_time =create_time WHERE publish_time is null and plan_status=1;
				update core_safecheck_plan set withdraw_time =create_time WHERE withdraw_time is null and plan_status=2;
				update core_safecheck_plan set effective_time =create_time WHERE effective_time is null and (plan_status=1 or plan_status=2);
    END IF;
END ??
DELIMITER;
CALL schema_change ();

update sys_menu set component='safetycheck/plan/index' WHERE menu_name='检查任务下发' and menu_type='C' and platform_type='1';