CREATE TABLE `basic_field` (
     `id` BIGINT(20) NOT NULL COMMENT '主键',
     `school_id` BIGINT(20) NOT NULL COMMENT '学校ID',
     `code` VARCHAR(45) NOT NULL COMMENT '字段代码',
     `name` VARCHAR(45) NOT NULL COMMENT '字段名称',
     `enable` TINYINT(1) NOT NULL COMMENT '是否选中',
     `disabled` TINYINT(1) NOT NULL COMMENT '是否禁用',
     `basic_field` TINYINT(1) NOT NULL COMMENT '是否基础字段',
     `create_id` BIGINT(20) NULL,
     `create_time` BIGINT(20) NULL,
     `update_id` BIGINT(20) NULL,
     `update_time` BIGINT(20) NULL,
     PRIMARY KEY (`id`))
    COMMENT = '字段管理表';

ALTER TABLE `t_b_task` CHANGE COLUMN `org_id` `exam_id` BIGINT NULL DEFAULT NULL COMMENT '考试ID' ;
ALTER TABLE `exam_student` ADD COLUMN `extend_fields` MEDIUMTEXT NULL COMMENT '扩展字段' AFTER `remark`;
ALTER TABLE `t_b_task` CHANGE COLUMN `txt_file_path` `error_file_path` VARCHAR(500) CHARACTER SET 'utf8mb4' NULL DEFAULT NULL COMMENT '错误文件路径' ;

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `enable`, `default_auth`, `front_display`) VALUES ('273', '字段管理', 'FieldManage', 'MENU', '8', '2', '1', '0', '1');
UPDATE `sys_privilege` SET `sequence` = '4' WHERE (`id` = '510');
UPDATE `sys_privilege` SET `sequence` = '5' WHERE (`id` = '9');
UPDATE `sys_privilege` SET `sequence` = '6' WHERE (`id` = '20');
UPDATE `sys_privilege` SET `sequence` = '10' WHERE (`id` = '549');

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('274', '查询', '/api/admin/basic/field/list', 'URL', '273', '1', 'AUTH', '1', '1', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('275', '保存', '/api/admin/basic/field/save', 'URL', '273', '2', 'AUTH', '1', '1', '1');
UPDATE `sys_privilege` SET `related` = '274,275' WHERE (`id` = '273');

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('33', '模板下载', '/api/admin/exam/student/download_template', 'URL', '20', '5', 'AUTH', '1', '1', '1');
UPDATE `sys_privilege` SET `related` = '32,33' WHERE (`id` = '26');

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('567', '查询列表', '/api/admin/basic/filetype/list', 'URL', '560', '4', 'AUTH', '1', '1', '1');

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('205', '根据学号获取考生信息', '/api/admin/client/student/get', 'URL', '200', '5','AUTH', '1', '1', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('206', '获取考场/班级', '/api/admin/client/classroom/get', 'URL', '200', '6', 'AUTH', '1', '1', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('207', '获取批次号', '/api/admin/client/batch_no/get', 'URL', '200', '7', 'AUTH', '1', '1', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('208', '新增学生', '/api/admin/client/student/save', 'URL', '200', '8', 'AUTH', '1', '1', '1');
UPDATE `sys_privilege` SET `related` = '30,202,203,204,205,206,207,208,274,565,567' WHERE (`id` = '200');

CREATE TABLE `basic_batch_number` (
        `exam_id` BIGINT(20) NOT NULL COMMENT '考试ID',
        `user_id` BIGINT(20) NOT NULL COMMENT '用户ID',
        `alphabet` VARCHAR(4) NULL COMMENT '字母（前缀）',
        `sequence` INT NULL COMMENT '序号',
        PRIMARY KEY (`exam_id`, `user_id`));

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('276', '删除图片', '/api/admin/paper/document/picture/delete', 'URL', '260', '8', 'AUTH', '1', '1', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('277', '旋转保存图片', '/api/admin/paper/document/picture/save', 'URL', '260', '9', 'AUTH', '1', '1', '1');
UPDATE `sys_privilege` SET `related` = '267,268,269,270,271,276,277' WHERE (`id` = '264');

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('278', '汇总统计', '/api/admin/paper/document/stat', 'URL', '260', '10', 'AUTH', '1', '1', '1');
UPDATE `sys_privilege` SET `related` = '266,278' WHERE (`id` = '261');
UPDATE `sys_privilege` SET `related` = '266,278' WHERE (`id` = '262');
UPDATE `sys_privilege` SET `related` = '266,278' WHERE (`id` = '263');

INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `related`, `enable`, `default_auth`, `front_display`) VALUES ('253', '清除学生数据', 'ClearStudentScanData', 'LINK', '244', '6', 'AUTH', '254', '1', '0', '1');
INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('254', '清除学生数据接口', '/api/admin/paper/scan_task/clear_single_data', 'URL', '244', '4', 'AUTH', '1', '1', '1');

UPDATE `sys_privilege` SET `enable` = '0' WHERE (`id` = '12');

ALTER TABLE `exam_course` DROP INDEX `idx_1`;
ALTER TABLE `paper_library` ADD INDEX `idx_3` (`create_id` ASC);
ALTER TABLE `paper_library_other` DROP INDEX `idx_1` ,ADD INDEX `idx_1` (`paper_scan_task_id` ASC, `file_type_id` ASC);
