DROP PROCEDURE IF EXISTS createCom;
DELIMITER $$
CREATE
    PROCEDURE createCom()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM information_schema.columns  WHERE table_name='system_update_message' AND COLUMN_NAME = 'release_date') THEN
ALTER TABLE `system_update_message`   
  ADD COLUMN `release_date` DATETIME NULL   COMMENT '发布时间';
    END IF;
END$$
DELIMITER ;
CALL createCom;
DROP PROCEDURE createCom;


ALTER TABLE `base_student_school_roll`   
  ADD INDEX (`class_id`),
  ADD INDEX (`grade_id`);

DROP PROCEDURE IF EXISTS createCom;
DELIMITER $$
CREATE
    PROCEDURE createCom()
BEGIN
    IF NOT EXISTS(SELECT 1 FROM information_schema.columns  WHERE table_name='xjr_menu' AND COLUMN_NAME = 'is_show_servce') THEN
ALTER TABLE `xjr_menu`   
  ADD COLUMN `is_show_servce` SMALLINT DEFAULT 1  NULL   COMMENT '是否显示在服务中心（0：否 1：是）' ;

    END IF;
END$$
DELIMITER ;
CALL createCom;
DROP PROCEDURE createCom;

UPDATE xjr_menu SET is_show_servce = 1 WHERE is_show_servce IS NULL;

ALTER TABLE `data_expert_source`   
  DROP COLUMN `field_json`, 
  CHANGE `api_url` `view_name` VARCHAR(50) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL   COMMENT '视图名称';

ALTER TABLE `base_student`   
  ADD COLUMN `native_place_type` VARCHAR(50) NULL   COMMENT '籍贯类型' ;

DROP TABLE IF EXISTS data_expert_source;
CREATE TABLE `data_expert_source` (
  `id` BIGINT NOT NULL,
  `create_user_id` BIGINT DEFAULT NULL,
  `create_date` DATETIME(3) DEFAULT NULL,
  `modify_user_id` BIGINT DEFAULT NULL,
  `modify_date` DATETIME(3) DEFAULT NULL,
  `delete_mark` INT DEFAULT NULL,
  `enabled_mark` INT DEFAULT NULL,
  `sort_code` INT DEFAULT NULL,
  `name` VARCHAR(100) DEFAULT NULL COMMENT '数据源名称',
  `source_type` VARCHAR(50) DEFAULT NULL COMMENT '数据源类型',
  `view_name` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '视图名称',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='数据导出-数据源设置';

DROP TABLE IF EXISTS data_expert_source_field;
CREATE TABLE `data_expert_source_field` (
  `id` BIGINT NOT NULL,
  `create_user_id` BIGINT DEFAULT NULL,
  `create_date` DATETIME(3) DEFAULT NULL,
  `modify_user_id` BIGINT DEFAULT NULL,
  `modify_date` DATETIME(3) DEFAULT NULL,
  `delete_mark` INT DEFAULT NULL,
  `enabled_mark` INT DEFAULT NULL,
  `sort_code` INT DEFAULT NULL,
  `data_expert_source_id` BIGINT DEFAULT NULL COMMENT '数据源(data_expert_source)',
  `field_name` VARCHAR(100) DEFAULT NULL COMMENT '字段名称',
  `show_name` VARCHAR(50) DEFAULT NULL COMMENT '映射名称',
  `remarks` VARCHAR(50) DEFAULT NULL COMMENT '备注',
  `data_group` VARCHAR(50) DEFAULT NULL COMMENT '数据分组',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='数据导出-数据源-字段设置';

DROP TABLE IF EXISTS data_expert_template;
CREATE TABLE `data_expert_template` (
  `id` BIGINT NOT NULL,
  `create_user_id` BIGINT DEFAULT NULL,
  `create_date` DATETIME(3) DEFAULT NULL,
  `modify_user_id` BIGINT DEFAULT NULL,
  `modify_date` DATETIME(3) DEFAULT NULL,
  `delete_mark` INT DEFAULT NULL,
  `enabled_mark` INT DEFAULT NULL,
  `sort_code` INT DEFAULT NULL,
  `name` VARCHAR(100) DEFAULT NULL COMMENT '模板名称',
  `data_expert_source_id` BIGINT DEFAULT NULL COMMENT '数据源(data_expert_source)',
  `field_json` LONGTEXT COMMENT '字段配置',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='数据导出-数据模板';
