USE teachcloud_db;

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 basic_template_org;
drop table cloud_user_push_status;
drop table exam_card_detail;
drop table exam_paper_class_marker;
drop table exam_paper_group;
drop table exam_paper_group_marker;
drop table exam_paper_structure;
drop table exam_task_sync;
drop table t_sync_exam_log;
drop table t_sync_stmms_exam;

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

