USE teachcloud_db;

ALTER TABLE `exam_print_plan`
    CHANGE COLUMN `exam_start_time` `exam_start_time` BIGINT NULL COMMENT '考试开始时间' ,
    CHANGE COLUMN `exam_end_time` `exam_end_time` BIGINT NULL COMMENT '考试结束时间' ;

ALTER TABLE `exam_detail`
    CHANGE COLUMN `exam_start_time` `exam_start_time` BIGINT NULL COMMENT '考试开始日期' ,
    CHANGE COLUMN `exam_end_time` `exam_end_time` BIGINT NULL COMMENT '考试结束日期' ;

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('545', '成绩下载', 'DownloadScore', 'BUTTON', '487', '2', 'AUTH', '546', '1', '0', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('546', '成绩下载', '/api/admin/mark/archive/score/download', 'URL', '487', '2', 'AUTH', '1', '1', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('306', '从题库选择试卷', 'SelectTikuPaper', 'BUTTON', '40', '13', 'AUTH', '1', '0', '1');

ALTER TABLE `basic_operation_log`
DROP COLUMN `user_name`,
DROP COLUMN `return_value`,
DROP COLUMN `run_time`,
DROP COLUMN `method`,
DROP COLUMN `clazz_name`,
DROP COLUMN `system_type`,
DROP COLUMN `operation_unit`,
DROP COLUMN `operation_type`,
DROP COLUMN `level`,
DROP COLUMN `org_id`,
ADD COLUMN `function_name` VARCHAR(100) NULL COMMENT '功能名称' AFTER `operation_type`,
CHANGE COLUMN `user_id` `user_id` BIGINT NOT NULL COMMENT '用户对象id' AFTER `school_id`,
CHANGE COLUMN `ip` `ip` VARCHAR(32) CHARACTER SET 'utf8mb4' NOT NULL COMMENT 'ip地址' AFTER `user_id`,
CHANGE COLUMN `privilege_id` `privilege_id` BIGINT NULL DEFAULT NULL COMMENT '权限菜单id' AFTER `ip`,
CHANGE COLUMN `customized_operation_type` `operation_type` VARCHAR(32) CHARACTER SET 'utf8mb4' NOT NULL COMMENT '自定义记录日志操作类型（LOGIN(\"用户登录\"),LOGOUT(\"用户登出\"),ADD(\"新增\"),DELETE(\"删除\"),UPDATE(\"修改\"),IMPORT(\"导入\"),EXPORT(\"导出\"),UN_KNOW(\"未知\")）' AFTER `privilege_id`,
CHANGE COLUMN `school_id` `school_id` BIGINT NULL COMMENT '学校id' ,
CHANGE COLUMN `detail` `detail` MEDIUMTEXT CHARACTER SET 'utf8mb4' NULL COMMENT '日志详情' ,
DROP INDEX `operation_log_idx` ,
ADD INDEX `operation_log_idx` USING BTREE (`school_id`, `user_id`, `privilege_id`, `operation_type`, `create_time`);

update basic_operation_log t set t.operation_type = 'SAVE' where t.operation_type = 'EDIT';
update basic_operation_log t set t.operation_type = 'OTHER' where t.operation_type = 'UN_KNOW';

-- drop table if exists exam_detail_course_paper_type;
-- drop table if exists basic_template_org;
-- drop table if exists cloud_user_push_status;
-- drop table if exists exam_card_detail;
-- drop table if exists exam_paper_class_marker;
-- drop table if exists exam_paper_group;
-- drop table if exists exam_paper_group_marker;
-- drop table if exists exam_paper_structure;
-- drop table if exists exam_task_sync;
-- drop table if exists t_sync_exam_log;
-- drop table if exists t_sync_stmms_exam;

-- delete脚本需要加上新增的表

