----------------------------------------------------------------后端服务启动前执行-----------------------------------------------------------------------------------------
RENAME TABLE ec_e_exam_special_settings TO ec_e_exam_special_settings_bak;

CREATE TABLE `ec_e_exam_special_settings` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `root_org_id` bigint(20) NOT NULL,
  `exam_id` bigint(20) NOT NULL,
  `exam_type` varchar(255) NOT NULL,
  `org_id` bigint(20) DEFAULT NULL,
  `course_id` bigint(20) DEFAULT NULL,
  `student_id` bigint(20) DEFAULT NULL,
  `begin_time` datetime DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  `creation_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  `exam_enable` bit(1) NOT NULL,
  `exam_limit` bit(1) NOT NULL,
  `special_settings_enabled` bit(1) NOT NULL,
  `special_settings_type` varchar(255) DEFAULT NULL,
  `ext1` varchar(255) DEFAULT NULL,
  `ext2` varchar(255) DEFAULT NULL,
  `ext3` varchar(255) DEFAULT NULL,
  `ext4` varchar(255) DEFAULT NULL,
  `ext5` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `IDX_E_E_S_S_001001` (`exam_id`,`course_id`,`org_id`,`student_id`) USING BTREE,
  KEY `IDX_E_E_S_S_001002` (`exam_id`,`course_id`),
  KEY `IDX_E_E_S_S_001003` (`exam_id`,`org_id`),
  KEY `IDX_E_E_S_S_001004` (`exam_id`,`student_id`),
  KEY `IDX_E_E_S_S_001005` (`root_org_id`,`course_id`),
  KEY `IDX_E_E_S_S_001006` (`root_org_id`,`org_id`),
  KEY `IDX_E_E_S_S_001007` (`root_org_id`,`student_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


INSERT INTO ec_e_exam_special_settings (
	id,
	root_org_id,
	exam_id,
	exam_type,
	org_id,
	course_id,
	student_id,
	begin_time,
	end_time,
	creation_time,
	update_time,
	exam_enable,
	exam_limit,
	special_settings_enabled,
	special_settings_type 
) SELECT
id,
root_org_id,
exam_id,
exam_type,
org_id,
course_id,
student_id,
begin_time,
end_time,
creation_time,
update_time,
exam_enable,
exam_limit,
1,
'ORG_BASED' 
FROM
	ec_e_exam_special_settings_bak;
	
DROP TABLE ec_e_exam_special_settings_bak;

----------------------------------------------------------------后端服务启动后执行------------------------------------------------------------------------------------------


