-- ----------------------------
--  Table structure for `pm_break_record`
-- ----------------------------
DROP TABLE IF EXISTS `pm_break_record`;
CREATE TABLE `pm_break_record` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) NOT NULL,
  `creator_id` bigint(20) DEFAULT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `updater_id` bigint(20) DEFAULT NULL,
  `org_id` bigint(20) NOT NULL,
  `exam_id` bigint(20) NOT NULL,
  `group_type` varchar(16) COLLATE utf8_bin NOT NULL,
  `group_name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `status` varchar(16) COLLATE utf8_bin DEFAULT NULL,
  `start_number` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `end_number` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_BREAK_RECORD_001` (`org_id`,`exam_id`,`group_type`),
  KEY `IDX_BREAK_RECORD_002` (`exam_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
--  Table structure for `pm_check_record`
-- ----------------------------
DROP TABLE IF EXISTS `pm_check_record`;
CREATE TABLE `pm_check_record` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) NOT NULL,
  `creator_id` bigint(20) DEFAULT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `updater_id` bigint(20) DEFAULT NULL,
  `org_id` bigint(20) NOT NULL,
  `exam_id` bigint(20) NOT NULL,
  `group_type` varchar(16) COLLATE utf8_bin NOT NULL,
  `status` varchar(16) COLLATE utf8_bin NOT NULL,
  `group_name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `start_number` varchar(255) COLLATE utf8_bin NOT NULL,
  `end_number` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_CHECK_RECORD_001` (`org_id`,`exam_id`,`group_type`),
  KEY `IDX_CHECK_RECORD_002` (`exam_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
--  Table structure for `pm_exam`
-- ----------------------------
DROP TABLE IF EXISTS `pm_exam`;
CREATE TABLE `pm_exam` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) NOT NULL,
  `creator_id` bigint(20) DEFAULT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `updater_id` bigint(20) DEFAULT NULL,
  `org_id` bigint(20) NOT NULL,
  `name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `enable` bigint(1) NOT NULL,
  `group_type` varchar(255) COLLATE utf8_bin NOT NULL,
  `check_sort` varchar(255) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `IDX_EXAM_001` (`org_id`,`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
--  Table structure for `pm_exam_student`
-- ----------------------------
DROP TABLE IF EXISTS `pm_exam_student`;
CREATE TABLE `pm_exam_student` (
  `create_time` datetime(6) NOT NULL,
  `creator_id` bigint(20) DEFAULT NULL,
  `update_time` datetime(6) DEFAULT NULL,
  `updater_id` bigint(20) DEFAULT NULL,
  `org_id` bigint(20) NOT NULL,
  `exam_id` bigint(20) NOT NULL,
  `sort_no` bigint(20) NOT NULL,
  `name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `course_code` varchar(255) COLLATE utf8_bin NOT NULL,
  `student_code` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `exam_number` varchar(255) COLLATE utf8_bin NOT NULL,
  `exam_site` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `exam_room` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`exam_id`, `sort_no`),
  KEY `IDX_EXAM_STUDENT_001` (`org_id`,`exam_id`),
  KEY `IDX_EXAM_STUDENT_002` (`exam_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
--  Table structure for `pm_exam_user_relation`
-- ----------------------------
DROP TABLE IF EXISTS `pm_exam_user_relation`;
CREATE TABLE `pm_exam_user_relation` (
  `user_id` bigint(20) NOT NULL,
  `exam_id` bigint(20) NOT NULL,
  `create_time` datetime(6) NOT NULL,
  `update_time` datetime(6) NOT NULL,
  `creator_id` bigint(20) DEFAULT NULL,
  `updater_id` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`user_id`,`exam_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
--  Table structure for `pm_org`
-- ----------------------------
DROP TABLE IF EXISTS `pm_org`;
CREATE TABLE `pm_org` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) NOT NULL,
  `update_time` datetime(6) NOT NULL,
  `name` varchar(255) COLLATE utf8_bin NOT NULL,
  `code` varchar(255) COLLATE utf8_bin NOT NULL,
  `enable` bit(1) NOT NULL,
  `access_key` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `access_secret` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `description` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `domain_name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `logo_url` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `IDX_ORG_01` (`code`),
  UNIQUE KEY `IDX_ORG_02` (`domain_name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
--  Table structure for `pm_user`
-- ----------------------------
DROP TABLE IF EXISTS `pm_user`;
CREATE TABLE `pm_user` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `create_time` datetime(6) NOT NULL,
  `creator_id` bigint(20) DEFAULT NULL,
  `update_time` datetime(6) NOT NULL,
  `updater_id` bigint(20) DEFAULT NULL,
  `login_name` varchar(255) COLLATE utf8_bin NOT NULL,
  `name` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `enable` bit(1) NOT NULL,
  `password` varchar(255) COLLATE utf8_bin DEFAULT NULL,
  `role` varchar(64) COLLATE utf8_bin NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `IDX_USER_01` (`login_name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

INSERT INTO `pm_user` (`id`, `create_time`, `update_time`, `enable`, `login_name`, `name`, `password`,`creator_id`,`updater_id`, `role`) VALUES (1, now(), now(), 1, 'admin', '超管', UPPER(SHA2(CONCAT('1','0'),256)),1, 1,'ADMIN');

