-- 艺术数据模块子表初始化脚本

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for art_school_campus
-- ----------------------------
DROP TABLE IF EXISTS `art_school_campus`;
CREATE TABLE `art_school_campus` (
  `campus_id` bigint NOT NULL AUTO_INCREMENT COMMENT '校区主键ID',
  `tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
  `school_id` bigint NOT NULL COMMENT '学校ID',
  `school_name` varchar(128) NOT NULL DEFAULT '' COMMENT '学校名称(冗余)',
  `campus_name` varchar(128) NOT NULL COMMENT '校区名称',
  `location` varchar(256) DEFAULT '' COMMENT '校区位置(文本)',
  `address` varchar(256) DEFAULT '' COMMENT '校区地址',
  `lng` decimal(10,6) DEFAULT NULL COMMENT '经度',
  `lat` decimal(10,6) DEFAULT NULL COMMENT '纬度',
  `introduction` text COMMENT '校区介绍',
  `create_dept` bigint DEFAULT NULL COMMENT '创建部门',
  `create_by` bigint DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` bigint DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`campus_id`),
  UNIQUE KEY `uk_school_campus_name` (`school_id`,`campus_name`),
  KEY `idx_campus_school_id` (`school_id`),
  KEY `idx_campus_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='学校校区表';

-- ----------------------------
-- Table structure for art_school_college
-- ----------------------------
DROP TABLE IF EXISTS `art_school_college`;
CREATE TABLE `art_school_college` (
  `college_id` bigint NOT NULL AUTO_INCREMENT COMMENT '学院主键ID',
  `tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
  `school_id` bigint NOT NULL COMMENT '学校ID',
  `school_name` varchar(128) NOT NULL DEFAULT '' COMMENT '学校名称(冗余)',
  `college_code` varchar(32) DEFAULT '' COMMENT '学院编码(可选)',
  `college_name` varchar(128) NOT NULL COMMENT '学院名称',
  `introduction` text COMMENT '学院介绍',
  `sort_no` int DEFAULT '0' COMMENT '排序',
  `create_dept` bigint DEFAULT NULL COMMENT '创建部门',
  `create_by` bigint DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` bigint DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`college_id`),
  UNIQUE KEY `uk_school_college_name` (`school_id`,`college_name`),
  KEY `idx_college_school_id` (`school_id`),
  KEY `idx_college_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='学校学院表';

-- ----------------------------
-- Table structure for art_school_enroll_plan
-- ----------------------------
DROP TABLE IF EXISTS `art_school_enroll_plan`;
CREATE TABLE `art_school_enroll_plan` (
  `plan_id` bigint NOT NULL AUTO_INCREMENT COMMENT '招生计划主键ID',
  `tenant_id` varchar(20) NOT NULL DEFAULT '000000' COMMENT '租户编号',
  `school_id` bigint NOT NULL COMMENT '学校ID',
  `school_name` varchar(128) NOT NULL DEFAULT '' COMMENT '学校名称(冗余)',
  `year` smallint NOT NULL COMMENT '年份',
  `province` varchar(32) NOT NULL COMMENT '招生省份',
  `subject_type` varchar(16) DEFAULT '' COMMENT '选科类型',
  `major_id` bigint DEFAULT NULL COMMENT '专业ID(可选)',
  `major_name` varchar(128) NOT NULL COMMENT '专业名称',
  `education_level` varchar(16) DEFAULT '' COMMENT '学历层次',
  `plan_num` int NOT NULL COMMENT '计划数',
  `create_dept` bigint DEFAULT NULL COMMENT '创建部门',
  `create_by` bigint DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` bigint DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`plan_id`),
  UNIQUE KEY `uk_plan_unique` (`school_id`,`year`,`province`,`subject_type`,`major_name`,`education_level`),
  KEY `idx_plan_school_year` (`school_id`,`year`),
  KEY `idx_plan_year_province` (`year`,`province`),
  KEY `idx_plan_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='学校招生计划表';

SET FOREIGN_KEY_CHECKS = 1;
