-- ----------------------------
-- Table structure for ck_alarm_config
-- ----------------------------
DROP TABLE IF EXISTS `CK_ALARM_CONFIG`;
CREATE TABLE `CK_ALARM_CONFIG`
(
    `SID`                BIGINT(65) NOT NULL,
    `ALARM_NAME`         VARCHAR(255),
    `THRESHOLD_TYPE`     CHAR(1) COMMENT '1、数值 2、百分比',
    `THRESHOLD_RELATION` VARCHAR(64) COMMENT 'gt代表> eq代表= lt代表<',
    `THRESHOLD_VALUE`    VARCHAR(10),
    `ALARM_LEVEL`        CHAR(1) COMMENT '1、一般 2、中等 3、严重',
    `STATE`              CHAR(1) COMMENT '1、新增 2、生效 3、挂起',
    `DELETED`            CHAR(1)      NOT NULL,
    `CREATE_BY`          VARCHAR(255) NOT NULL,
    `CREATE_TIME`        DATETIME     NOT NULL,
    `UPDATE_BY`          VARCHAR(255),
    `UPDATE_TIME`        DATETIME,
    `REMARK`             VARCHAR(255),
    `messagetype`        INT(11),
    `STANDBY`            VARCHAR(255),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'CK_ALARM_CONFIG' ROW_FORMAT = DYNAMIC;

alter table CK_ALARM_CONFIG alter column DELETED set default 0;

-- ----------------------------
-- Table structure for ck_alarm_record
-- ----------------------------
DROP TABLE IF EXISTS `CK_ALARM_RECORD`;
CREATE TABLE `CK_ALARM_RECORD`
(
    `SID`                 BIGINT(65) NOT NULL,
    `RELATION_ID`         BIGINT(65),
    `RELATION_TABLE`      VARCHAR(10) COMMENT 'TABLE:表检核、ITEM:nosql检核、COMMON:通用检核',
    `ALARM_SID`           BIGINT(65) COMMENT 'CK_ALARM_CONFIG SID',
    `CHECK_LOG_SID`       BIGINT(65) COMMENT 'CK_CHECK_LOG SID',
    `CONTENT`             VARCHAR(1000),
    `message_send_result` VARCHAR(255),
    `RECEIVED_BY`         VARCHAR(255),
    `RECEIPT_TIME`        DATETIME,
    `STATE`               CHAR(1) COMMENT '提醒、不再提醒',
    `DELETED`             CHAR(1) COMMENT '1删除，0不删除（默认0）',
    `CREATE_BY`           VARCHAR(255),
    `CREATE_TIME`         DATETIME,
    `UPDATE_BY`           VARCHAR(255),
    `UPDATE_TIME`         DATETIME,
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '告警记录表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_calendar
-- ----------------------------
DROP TABLE IF EXISTS `CK_CALENDAR`;
CREATE TABLE `CK_CALENDAR`
(
    `CK_ID`       VARCHAR(255) NOT NULL,
    `CK_NAME`     VARCHAR(255) NOT NULL,
    `CK_DESC`     VARCHAR(255),
    `CK_YEAR`     INT(11) NOT NULL,
    `CK_DATELIST` LONGTEXT     NOT NULL,
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    PRIMARY KEY (`CK_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_check_log
-- ----------------------------
DROP TABLE IF EXISTS `CK_CHECK_LOG`;
CREATE TABLE `CK_CHECK_LOG`
(
    `SID`              BIGINT(65) NOT NULL,
    `METHOD_CONFIG_ID` BIGINT(65),
    `CHECK_TIME`       DATETIME,
    `CHECK_END_TIME`   DATETIME,
    `CHECK_DURATION`   VARCHAR(10),
    `JOB_ID`           BIGINT(20),
    `JOB_LOG_ID`       BIGINT(20),
    `CHECK_STATUS`     VARCHAR(10),
    `RESULT_ID`        VARCHAR(64),
    `ERROR_REMARK`     LONGTEXT,
    PRIMARY KEY (`SID`) USING BTREE,
    UNIQUE INDEX `SID`(`SID`) USING BTREE,
    INDEX              `JOB_LOG_ID`(`JOB_LOG_ID`) USING BTREE,
    INDEX              `METHOD_CONFIG_ID`(`METHOD_CONFIG_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_check_log_latest
-- ----------------------------
DROP TABLE IF EXISTS `CK_CHECK_LOG_LATEST`;
CREATE TABLE `CK_CHECK_LOG_LATEST`
(
    `METHOD_CONFIG_ID` BIGINT(65),
    `LOG_SID`          BIGINT(65),
    PRIMARY KEY (`METHOD_CONFIG_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_check_result
-- ----------------------------
DROP TABLE IF EXISTS `CK_CHECK_RESULT`;
CREATE TABLE `CK_CHECK_RESULT`
(
    `SID`               BIGINT(65) NOT NULL COMMENT '主键',
    `INDEX_SID`         BIGINT(65) COMMENT '所属指标',
    `CHECK_FREQUENCY`   VARCHAR(5) COMMENT '检核频率',
    `CHECK_TIME`        DATETIME COMMENT '检核时间',
    `CHECK_END_TIME`    DATETIME COMMENT '检核结束时间',
    `CHECK_DURATION`    VARCHAR(10) COMMENT '检核时长',
    `ERROR_NUM`         BIGINT(65) COMMENT '错误总数',
    `SUM_NUM`           BIGINT(65) COMMENT '总次数',
    `RESOURCE_SID`      BIGINT(65) COMMENT '资源id',
    `ITEM_SID`          BIGINT(65) COMMENT '资源项id',
    `ERROR_KEYWORD`     TEXT COMMENT '错误数据关键字',
    `ERROR_VALUE`       TEXT COMMENT '错误数据关键字',
    `ERROR_REMARK`      LONGTEXT,
    `SOURCE_DATE`       DATETIME COMMENT '归属日期',
    `ERROR_SOURCE1`     VARCHAR(200) COMMENT '错误数据来源目录',
    `ERROR_SOURCE2`     VARCHAR(100) COMMENT '错误数据来源资源',
    `ERROR_SOURCE3`     VARCHAR(50) COMMENT '错误数据来源定位',
    `METHOD_CONFIG_ID`  BIGINT(65) NOT NULL COMMENT '关联\"检核规则配置表\"的主键',
    `JOB_ID`            BIGINT(20) COMMENT '任务id',
    `JOB_LOG_ID`        BIGINT(20) COMMENT '日志id',
    `CHECK_RESULT_URL`  VARCHAR(200) COMMENT '检核结果文件下载地址',
    `CHECK_STATUS`      VARCHAR(10) COMMENT '检核状态 1 成功 0失败',
    `CHECK_RESULT_PATH` VARCHAR(200) COMMENT '检核结果上传路径',
    `CHECK_RESULT`      TEXT COMMENT '检核结果上传路径',

    PRIMARY KEY (`SID`) USING BTREE,
    UNIQUE INDEX `SID`(`SID`) USING BTREE,
    INDEX               `JOB_LOG_ID`(`JOB_LOG_ID`) USING BTREE,
    INDEX               `METHOD_CONFIG_ID`(`METHOD_CONFIG_ID`) USING BTREE,
    INDEX               `index_ck_check_result`(`CHECK_TIME`) USING BTREE,
    INDEX               `index_ck_check_result_method_config_id`(`METHOD_CONFIG_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_check_result_latest
-- ----------------------------
DROP TABLE IF EXISTS `CK_CHECK_RESULT_LATEST`;
CREATE TABLE `CK_CHECK_RESULT_LATEST`
(
    `METHOD_CONFIG_ID` BIGINT(65) NOT NULL,
    `JOB_ID`           BIGINT(20),
    `MAX_JOB_LOG_ID`   BIGINT(20),
    `MAX_CHECK_TIME`   DATETIME,
    PRIMARY KEY (`METHOD_CONFIG_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for ck_frequency
-- ----------------------------
DROP TABLE IF EXISTS `CK_FREQUENCY`;
CREATE TABLE `CK_FREQUENCY`
(
    `NAME`        VARCHAR(128) NOT NULL,
    `TYPE`        CHAR(1),
    `INTERVALNUM` INT(3) COMMENT '如果是类型是周期性，间隔不允许为空，默认为1',
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    `EXPRESSION`  VARCHAR(255),
    `DESCRIPTION` VARCHAR(255),
    PRIMARY KEY (`NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_general_config
-- ----------------------------
DROP TABLE IF EXISTS `CK_GENERAL_CONFIG`;
CREATE TABLE `CK_GENERAL_CONFIG`
(
    `SID`           BIGINT(65) NOT NULL,
    `CONFIG_TYPE`   CHAR(1) COMMENT '1、数据抖动 2、数据偏移 3、数据堆积 4、数据对照',
    `CONFIG_NAME`   VARCHAR(255),
    `STATE`         CHAR(1)      NOT NULL DEFAULT '1' COMMENT '1、新建 2、启用  3、停用',
    `DELETED`       CHAR(1)      NOT NULL DEFAULT '0',
    `CREATE_BY`     VARCHAR(255) NOT NULL,
    `CREATE_TIME`   DATETIME     NOT NULL,
    `UPDATE_BY`     VARCHAR(255),
    `UPDATE_TIME`   DATETIME,
    `REMARK`        VARCHAR(255),
    `STANDBY`       VARCHAR(500),
    `SCHEDULE_ID`   BIGINT(65),
    `SCHEDULE_NAME` VARCHAR(128),
    `PRINCIPAL`     VARCHAR(255) COMMENT '责任人',
    `ALARM_ID`      BIGINT(65),
    `CHECK_CONFIG`  VARCHAR(255),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'CK_GENERAL_CONFIG' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_general_config_detail
-- ----------------------------
DROP TABLE IF EXISTS `CK_GENERAL_CONFIG_DETAIL`;
CREATE TABLE `CK_GENERAL_CONFIG_DETAIL`
(
    `SID`              BIGINT(65) NOT NULL,
    `CONFIG_ID`        BIGINT(65) NOT NULL COMMENT '与通用检核规则配置表SID关联',
    `RESOURCE_NAME`    VARCHAR(2000) COMMENT '与资产信息表（DA_RESOURCE_INFO)表的数据资源编码（RESOURCE_NAME）关联',
    `RESOURCE_ID`      BIGINT(65) COMMENT '与资产信息表（DA_RESOURCE_INFO)表的主键SID关联',
    `DATA_SOURCE_NAME` VARCHAR(64),
    `INSTANCE_CODE`    VARCHAR(255) COMMENT '与DS_RESOURCE_ITEM的INSTANCE_CODE关联',
    `ITEM_CODE`        VARCHAR(200) COMMENT '与资产数据项（DA_RESOURCE_ITEM）表中的数据资源项标识（ITEM_CODE）关联',
    `ITEM_NAME`        VARCHAR(2000) COMMENT '与资产数据项（DA_RESOURCE_ITEM）表中的元数据项名称（ITEM_NAME）关联',
    `TABLE_CODE`       VARCHAR(128) COMMENT '与资产信息表（DA_RESOURCE_INFO)表的数据资源编码（TABLE_CODE）关联',
    `EXT_CONDITION`    VARCHAR(500),
    `UP_THRESHOLD`     VARCHAR(20),
    `DOWN_THRESHOLD`   VARCHAR(20),
    `PERIOD`           INT(11),
    `PERIOD_TYPE`      CHAR(1) COMMENT '1、天 2、小时 3、分钟',
    `ITEM_ID`          BIGINT(65),
    `DATA_SOURCE_SID`  BIGINT(65),
    `SCHEMA_CODE`      VARCHAR(255),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'CK_GENERAL_CONFIG_DETAIL' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_general_result
-- ----------------------------
DROP TABLE IF EXISTS `CK_GENERAL_RESULT`;
CREATE TABLE `CK_GENERAL_RESULT`
(
    `SID`            BIGINT(65) NOT NULL,
    `CONFIG_ID`      BIGINT(65) NOT NULL COMMENT '关联通用检核规则配置表主键SID',
    `AVERAGE_VALUE`  VARCHAR(20),
    `UP_THRESHOLD`   VARCHAR(20),
    `DOWN_THRESHOLD` VARCHAR(20),
    `CREATE_TIME`    DATETIME,
    `JOB_ID`         BIGINT(20),
    `JOB_LOG_ID`     BIGINT(20),
    `LOG_MESSAGE`    VARCHAR(8000),
    `COUNT_OUT_OF_RANGE` BIGINT(65),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'CK_GENERAL_RESULT' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_general_result_detail
-- ----------------------------
DROP TABLE IF EXISTS `CK_GENERAL_RESULT_DETAIL`;
CREATE TABLE `CK_GENERAL_RESULT_DETAIL`
(
    `SID`              BIGINT(65) NOT NULL,
    `RESULT_SID`       BIGINT(65) NOT NULL COMMENT '关联通用检核结果表的SID',
    `DATA_SOURCE_NAME` VARCHAR(64),
    `TABLE_CODE`       VARCHAR(128) COMMENT '与资产信息表（DA_RESOURCE_INFO)表的数据资源编码（TABLE_CODE）关联',
    `RESOURCE_ID`      BIGINT(65) COMMENT '与资产信息表（DA_RESOURCE_INFO)表的主键SID关联',
    `RESOURCE_NAME`    VARCHAR(2000) COMMENT '与资产信息表（DA_RESOURCE_INFO)表的数据资源编码（RESOURCE_NAME）关联',
    `ITEM_CODE`        VARCHAR(200) COMMENT '与资产数据项（DA_RESOURCE_ITEM）表中的数据资源项标识（SID）关联',
    `ITEM_NAME`        VARCHAR(2000) COMMENT '与资产数据项（DA_RESOURCE_ITEM）表中的元数据项名称（ITEM_NAME）关联',
    `ACTUAL_VALUE`     VARCHAR(20),
    `LINE_NUM`         VARCHAR(20),
    `INSTANCE_CODE`    VARCHAR(255),
    `EXT_CONDITION`    VARCHAR(500),
    `ITEM_ID`          BIGINT(65),
    `DATA_SOURCE_SID`  BIGINT(65),
    `SCHEMA_CODE`      VARCHAR(255),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_group
-- ----------------------------
DROP TABLE IF EXISTS `CK_GROUP`;
CREATE TABLE `CK_GROUP`
(
    `SID`         BIGINT(65) NOT NULL,
    `GROUP_NAME`  VARCHAR(128),
    `UPPER_GROUP` BIGINT(65) COMMENT '父节点id，一级节点为空',
    `DESCRIPTION` TEXT,
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    `UPPER_NAME`  VARCHAR(128) COMMENT '简称',
    PRIMARY KEY (`SID`) USING BTREE,
    INDEX         `INDEX_CK_GROUP_UPPERGROUP`(`GROUP_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_group_relation
-- ----------------------------
DROP TABLE IF EXISTS `CK_GROUP_RELATION`;
CREATE TABLE `CK_GROUP_RELATION`
(
    `CONFIGSID`   BIGINT(65) NOT NULL,
    `CONFIGTYPE`  INT(11) NOT NULL COMMENT '1,检核规则，2，通用检核配置',
    `GROUPSID`    BIGINT(65),
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    PRIMARY KEY (`CONFIGSID`, `CONFIGTYPE`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_index_info
-- ----------------------------
DROP TABLE IF EXISTS `CK_INDEX_INFO`;
CREATE TABLE `CK_INDEX_INFO`
(
    `SID`          BIGINT(65) NOT NULL COMMENT '主键',
    `INDEX_CODE`   VARCHAR(128) COMMENT '指标代码',
    `INDEX_NAME`   VARCHAR(128) COMMENT '指标名称',
    `CHECK_TYPE`   CHAR(1) COMMENT '检核类型',
    `INDEX_LEVEL`  VARCHAR(2) COMMENT '指标级别',
    `PARENT_SID`   VARCHAR(40) COMMENT '上级指标ID',
    `INDEX_WEIGHT` BIGINT(5) COMMENT '权重（百分制）',
    `REMARK`       TEXT,
    `DELETED`      CHAR(1),
    `CREATE_BY`    VARCHAR(255),
    `CREATE_TIME`  DATETIME,
    `UPDATE_BY`    VARCHAR(255),
    `UPDATE_TIME`  DATETIME NULL DEFAULT NULL,
    `ALARM_ID`     BIGINT(65) COMMENT '告警信息ID,关联告警信息id',
    `ALARM_NAME`   VARCHAR(128) COMMENT '告警名称,关联告警信息名称',
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '检核指标表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_index_weight_info
-- ----------------------------
DROP TABLE IF EXISTS `CK_INDEX_WEIGHT_INFO`;
CREATE TABLE `CK_INDEX_WEIGHT_INFO`
(
    `SID`         BIGINT(65) NOT NULL COMMENT '主键',
    `INDEX_SID`   BIGINT(65) COMMENT '标准主键SID',
    `INDEX_NAME`  VARCHAR(128) COMMENT '指标名称',
    `START_VALUE` BIGINT(3) COMMENT '起始值',
    `END_VALUE`   BIGINT(3) COMMENT '结束值',
    `SCORE`       BIGINT(3) COMMENT '分数',
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME NULL DEFAULT NULL,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '标准权值设置表' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for ck_knowledge_info
-- ----------------------------
DROP TABLE IF EXISTS `CK_KNOWLEDGE_INFO`;
CREATE TABLE `CK_KNOWLEDGE_INFO`
(
    `SID`         BIGINT(65) NOT NULL,
    `TITLE`       VARCHAR(255),
    `CONTENT`     LONGTEXT,
    `TARGET`      VARCHAR(255),
    `DELETED`     CHAR(1),
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    `PREVIEW`     LONGTEXT,
    `READNUM`     BIGINT(10) DEFAULT 0,
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_knowledge_log
-- ----------------------------
DROP TABLE IF EXISTS `CK_KNOWLEDGE_LOG`;
CREATE TABLE `CK_KNOWLEDGE_LOG`
(
    `SID`           BIGINT(65) NOT NULL,
    `KNOWLEDGE_SID` BIGINT(65),
    `DELETED`       CHAR(1),
    `CREATE_BY`     VARCHAR(255),
    `CREATE_TIME`   DATETIME,
    `UPDATE_BY`     VARCHAR(255),
    `UPDATE_TIME`   DATETIME
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_method_config
-- ----------------------------
DROP TABLE IF EXISTS `CK_METHOD_CONFIG`;
CREATE TABLE `CK_METHOD_CONFIG`
(
    `SID`              BIGINT(65) NOT NULL,
    `NAME`             VARCHAR(500) NOT NULL,
    `CODE`             VARCHAR(255) COMMENT '保留字段',
    `CHECK_METHOD`     CHAR(1) COMMENT '1、SQL检核 2、NOSQL检核',
    `RESOURCE_ID`      BIGINT(65) COMMENT '与资产信息表（DA_RESOURCE_INFO)表的主键SID关联',
    `RESOURCE_NAME`    VARCHAR(2000) COMMENT '与资产信息表（DA_RESOURCE_INFO)表的数据资源编码（RESOURCE_NAME）关联',
    `ITEM_ID`          BIGINT(65) COMMENT '与资产数据项（DA_RESOURCE_ITEM）表中的数据资源项标识（SID）关联',
    `ITEM_CODE`        VARCHAR(255) COMMENT '与资产数据项（DA_RESOURCE_ITEM）表中的元数据项编码（ITEM_CODE）关联',
    `ITEM_NAME`        VARCHAR(2000) COMMENT '与资产数据项（DA_RESOURCE_ITEM）表中的元数据项名称（ITEM_NAME）关联',
    `TABLE_CODE`       VARCHAR(128) NOT NULL COMMENT '与资产信息表（DA_RESOURCE_INFO)表的数据资源编码（TABLE_CODE）关联',
    `INSTANCE_CODE`    VARCHAR(255) COMMENT '与DS_RESOURCE_ITEM的INSTANCE_CODE关联',
    `FULLSQL`          VARCHAR(3000) COMMENT '根据前端配置的信息，组装成的完整的SQL 如果条件中存在{CheckField}占位符，则需要替换为相应的字段名称',
    `WHERESQL`         VARCHAR(3000) COMMENT 'SQL配置方式中，用户输入的where的SQL语句',
    `NUMSQL`           VARCHAR(3000),
    `CHECK_TYPE`       CHAR(1),
    `INDEX_ID`         BIGINT(65) COMMENT '指标id（SQL检核配置需要写入）',
    `INDEX_CODE`       VARCHAR(128),
    `INDEX_NAME`       VARCHAR(128),
    `SCHEDULE_ID`      BIGINT(65),
    `SCHEDULE_NAME`    VARCHAR(128),
    `CONFIG_TYPE`      CHAR(1) COMMENT '1、可视化配置   2、SQL配置',
    `CHECK_TPL`        INT(2) COMMENT '检核模板',
    `CHECK_CONFIG`     TEXT COMMENT '检查配置JSON',
    `IS_ALARM`         CHAR(1) COMMENT '1、自定义告警  0、默认使用检核指标配置的告警 默认是0',
    `ALARM_ID`         BIGINT(65),
    `ALARM_NAME`       VARCHAR(128),
    `ALARM_TIME`       DATETIME,
    `STATE`            CHAR(1)      NOT NULL COMMENT '1、新建 2、启用 3、停用',
    `DELETED`          CHAR(1)      NOT NULL,
    `CREATE_BY`        VARCHAR(255) NOT NULL,
    `CREATE_TIME`      DATETIME     NOT NULL,
    `UPDATE_BY`        VARCHAR(255),
    `UPDATE_TIME`      DATETIME,
    `REMARK`           VARCHAR(255),
    `STANDBY`          VARCHAR(500),
    `SHOW_FIELD`       VARCHAR(2000) COMMENT '显示字段',
    `DATA_SOURCE_NAME` VARCHAR(255) COMMENT '数据源名称',
    `DATA_SOURCE_SID`  BIGINT(65) COMMENT '数据源SID',
    `RESOURCE_TYPE`    VARCHAR(255) COMMENT '资源类型',
    `SCHEMA_CODE`      VARCHAR(255),
    `PRINCIPAL`        VARCHAR(255) COMMENT '责任人',
    `SINK_MODE`        VARCHAR(64) COMMENT '结果输出方式',
    `DATA_FROM`        VARCHAR(64) COMMENT '检核规则创建来源, 默认为NULL',
    PRIMARY KEY (`SID`) USING BTREE,
    INDEX              `index_ck_method_config`(`RESOURCE_ID`) USING BTREE,
    INDEX              `index_ck_method_config1`(`DELETED`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '此表用于配置检核规则（即原检核方法配置）CK_METHOD_CONFIG' ROW_FORMAT = DYNAMIC;

alter table CK_METHOD_CONFIG alter column DELETED set default 0;

-- ----------------------------
-- Table structure for ck_method_config_course  //todo 这张表没数据
-- ----------------------------
DROP TABLE IF EXISTS `CK_METHOD_CONFIG_COURSE`;
CREATE TABLE `CK_METHOD_CONFIG_COURSE`
(
    `SID`              bigint(65) NOT NULL,
    `METHOD_CONFIG_ID` bigint(65) NULL DEFAULT NULL,
    `OPT`              char(2) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '&&且 ||或',
    `TABLE_CODE`       varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `ITEM_CODE`        varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `INSTANCE_CODE`    varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `WILDCARD`         char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '前缀匹配、后缀匹配、全模糊匹配、等于、不等于、包含、不包含、大于、大于等于、小于、小于等于、区间（包括边界）、区间（不包括边界）、区间（包含前边界）、区间（包含后边界）',
    `ACTUAL_VALUE`     varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `STARTTIME`        varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `ENDTIME`          varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `DICT_ID`          varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    `ITEM_ID`          bigint(65) NULL DEFAULT NULL,
    `ITEM_NAME`        varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '记录SQL检核配置过程的表。主要是记录可视化配置的信息' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_method_item
-- ----------------------------
DROP TABLE IF EXISTS `CK_METHOD_ITEM`;
CREATE TABLE `CK_METHOD_ITEM`
(
    `SID`         BIGINT(65) NOT NULL,
    `CONFIG_SID`  BIGINT(65) COMMENT '数据项ID',
    `INDEX_SID`   BIGINT(65) COMMENT '指标ID',
    `PARENT_SID`  BIGINT(65) COMMENT '父级ID',
    `OPT`         VARCHAR(10),
    `RULE_SID`    BIGINT(65) COMMENT '规则ID',
    `EXPRESSION`  VARCHAR(200),
    `IDENTIFIER`  VARCHAR(200),
    `CHECK_MODE`  CHAR(1),
    `DELETED`     CHAR(1),
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    `REMARK`      VARCHAR(255),
    `STANDBY`     VARCHAR(500),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'CK_METHOD_ITEM' ROW_FORMAT = DYNAMIC;


-- ----------------------------
-- Table structure for ck_result_detail
-- ----------------------------
DROP TABLE IF EXISTS `CK_RESULT_DETAIL`;
CREATE TABLE `CK_RESULT_DETAIL`
(
    `SID`          BIGINT(65) NOT NULL,
    `RESULTID`     BIGINT(65),
    `CHECK_COLUMN` VARCHAR(1000),
    `COLUMN1`      VARCHAR(500) COMMENT '预留字段1',
    `COLUMN2`      VARCHAR(500) COMMENT '预留字段2',
    `COLUMN3`      VARCHAR(500) COMMENT '预留字段3',
    `COLUMN4`      VARCHAR(500) COMMENT '预留字段4',
    `COLUMN5`      VARCHAR(500) COMMENT '预留字段5',
    `COLUMN6`      VARCHAR(500),
    `COLUMN7`      VARCHAR(500),
    `COLUMN8`      VARCHAR(500),
    `COLUMN9`      VARCHAR(500),
    `COLUMN10`     VARCHAR(500),
    `COLUMN11`     VARCHAR(500),
    `COLUMN12`     VARCHAR(500),
    `COLUMN13`     VARCHAR(500),
    `COLUMN14`     VARCHAR(500),
    `COLUMN15`     VARCHAR(500),
    `COLUMN16`     VARCHAR(500),
    `COLUMN17`     VARCHAR(500),
    `COLUMN18`     VARCHAR(500),
    `COLUMN19`     VARCHAR(500),
    `COLUMN20`     VARCHAR(500),
    `COLUMN21`     VARCHAR(500),
    `COLUMN22`     VARCHAR(500),
    `COLUMN23`     VARCHAR(500),
    `COLUMN24`     VARCHAR(500),
    `COLUMN25`     VARCHAR(500),
    `COLUMN26`     VARCHAR(500),
    `COLUMN27`     VARCHAR(500),
    `COLUMN28`     VARCHAR(500),
    `COLUMN29`     VARCHAR(500),
    `COLUMN30`     VARCHAR(500),
    `COLUMN31`     VARCHAR(500),
    `COLUMN32`     VARCHAR(500),
    `COLUMN33`     VARCHAR(500),
    `COLUMN34`     VARCHAR(500),
    `CREATE_BY`    VARCHAR(255),
    `CREATE_TIME`  DATETIME,
    `UPDATE_BY`    VARCHAR(255),
    `UPDATE_TIME`  DATETIME,
    `TYPE`         CHAR(1) COMMENT '1字段名，2字段对应的值',
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '检核结果明细表 CK_RESULT_DETAIL' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_result_options
-- ----------------------------
DROP TABLE IF EXISTS `CK_RESULT_OPTIONS`;
CREATE TABLE `CK_RESULT_OPTIONS`
(
    `SID`          BIGINT(65) NOT NULL,
    `CHECK_METHOD` CHAR(1) NOT NULL COMMENT '1、SQL检核 2、NOSQL检核',
    `RESULT_SID`   BIGINT(65) NOT NULL,
    `OPTION_SID`   BIGINT(65) NOT NULL COMMENT '关联damp库下的PO_OPTIONS表的SID',
    `DELETED`      CHAR(1),
    `CREATE_BY`    VARCHAR(255),
    `CREATE_TIME`  DATETIME,
    `UPDATE_BY`    VARCHAR(255),
    `UPDATE_TIME`  DATETIME,
    `REMARK`       VARCHAR(255),
    `STANDBY`      VARCHAR(500),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '检核结果与问题的对应关系表' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_rule_info
-- ----------------------------
DROP TABLE IF EXISTS `CK_RULE_INFO`;
CREATE TABLE `CK_RULE_INFO`
(
    `SID`             BIGINT(65) NOT NULL,
    `RULE_CODE`       VARCHAR(30) COMMENT '规则编码',
    `RULE_NAME`       VARCHAR(50) COMMENT '规则名称',
    `RULE_OPTION`     VARCHAR(20) COMMENT '操作符，CK_RULE_OPTION 包含【=,!=,<,>,match,in等】',
    `RULE_VALUE`      TEXT COMMENT '规则值，包含【具体值，正则表达式，表名.字段名 等】',
    `RULE_VALUE_TYPE` CHAR(1) COMMENT '规则值类型，CK_RULE_VALUE_TYPE :包含【1为普通值；2为特殊值；3为码表值】',
    `EXPRESSION`      TEXT COMMENT '根据操作符和规则值运算出来的最终表达式',
    `REMARK`          TEXT COMMENT '备注',
    `DELETED`         CHAR(1) COMMENT '是否删除 0:否 1:是',
    `CREATE_BY`       VARCHAR(255),
    `CREATE_TIME`     DATETIME,
    `UPDATE_BY`       VARCHAR(255),
    `UPDATE_TIME`     DATETIME,
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '数据检核规则' ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for ck_schedule_config
-- ----------------------------
DROP TABLE IF EXISTS `CK_SCHEDULE_CONFIG`;
CREATE TABLE `CK_SCHEDULE_CONFIG`
(
    `SID`            BIGINT(65) NOT NULL,
    `NAME`           VARCHAR(128),
    `JOB_ID`         INT(11) COMMENT '关联xxljob任务的主键id',
    `JOB_GROUP`      INT(11) COMMENT 'XXLJOB的执行器id',
    `TYPE`           CHAR(1),
    `INTERVALNUM`    INT(3) COMMENT '如果是类型是周期性，间隔不允许为空，默认为1',
    `STARTTIME`      VARCHAR(20),
    `JOB_HANDLER`    VARCHAR(255) COMMENT '任务类别',
    `STATE`          CHAR(1)      NOT NULL COMMENT '1、新建 2、启用 3、停用',
    `DELETED`        CHAR(1)      NOT NULL,
    `CREATE_BY`      VARCHAR(255) NOT NULL,
    `CREATE_TIME`    DATETIME     NOT NULL,
    `UPDATE_BY`      VARCHAR(255),
    `UPDATE_TIME`    DATETIME,
    `REMARK`         VARCHAR(255),
    `STANDBY`        VARCHAR(500),
    `CALENDAR`       VARCHAR(255),
    `FREQUENCY_NAME` VARCHAR(255),
    `EXPRESSION`     VARCHAR(255),
    PRIMARY KEY (`SID`) USING BTREE,
    INDEX            `I_job_id1`(`JOB_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- todo cl_开头表暂时保留, 应该都是检核工作台资源目录相关的
-- ----------------------------
-- Table structure for cl_classif_info
-- ----------------------------
DROP TABLE IF EXISTS `CL_CLASSIF_INFO`;
CREATE TABLE `CL_CLASSIF_INFO`
(
    `SID`               BIGINT(65) NOT NULL,
    `CLASSIF_NAME`      VARCHAR(128),
    `UPPER_CLASSIF`     BIGINT(65) COMMENT '父节点id，一级节点为空',
    `SEQ`               VARCHAR(1024) COMMENT '.11.22.33.',
    `IS_LEAF`           CHAR(1) COMMENT 'Y/N',
    `DISPLAY_ORDER`     BIGINT(65) COMMENT '1、2、3...99',
    `DESCRIPTION`       TEXT,
    `LEVEL_NUM`         BIGINT(65) COMMENT '1、2、3',
    `CLASSIF_FULL_NAME` VARCHAR(500) COMMENT '一级名称-二级名称-叶子名称',
    `CLASSIF_TYPE`      VARCHAR(5),
    `RESOURCE_MAPPING`  VARCHAR(128) COMMENT '自动映射数据资源',
    `IS_AUTH`           CHAR(1) COMMENT '确定该分类是否需要做鉴权 0:不需要 1:需要',
    `CREATE_BY`         VARCHAR(255),
    `CREATE_TIME`       DATETIME,
    `UPDATE_BY`         VARCHAR(255),
    `UPDATE_TIME`       DATETIME,
    `CLASSIFTEMPLATE`   VARCHAR(255),
    `SHOW_SCHEMA`       VARCHAR(10) COMMENT '是否展示SCHEMA节点 0:否,1:是',
    `ABBR_NAME`         VARCHAR(128) COMMENT '简称',
    PRIMARY KEY (`SID`) USING BTREE,
    UNIQUE INDEX `IDEX_CLS_SEQ`(`SEQ`) USING BTREE,
    INDEX               `IDEX_CLS_UPPERCLASSIF`(`UPPER_CLASSIF`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cl_data_classif
-- ----------------------------
DROP TABLE IF EXISTS `CL_DATA_CLASSIF`;
CREATE TABLE `CL_DATA_CLASSIF`
(
    `RESOURCE_ID`   BIGINT(65) NOT NULL COMMENT '资源注册后，关联数据资源',
    `CLASSIF_SID`   BIGINT(65) NOT NULL,
    `RESOURCE_TYPE` CHAR(1) COMMENT '目录级、数据级、数据项级',
    `CREATE_BY`     VARCHAR(255),
    `CREATE_TIME`   DATETIME,
    `UPDATE_BY`     VARCHAR(255),
    `UPDATE_TIME`   DATETIME,
    PRIMARY KEY (`RESOURCE_ID`, `CLASSIF_SID`) USING BTREE,
    INDEX           `IDX_CDC_CLASSIF_SID`(`CLASSIF_SID`) USING BTREE,
    INDEX           `IDX_CDC_RESOURCE_ID`(`RESOURCE_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cl_data_level
-- ----------------------------
DROP TABLE IF EXISTS `CL_DATA_LEVEL`;
CREATE TABLE `CL_DATA_LEVEL`
(
    `RESOURCE_SID`  BIGINT(65) NOT NULL COMMENT '资源注册后，关联数据资源',
    `LEVEL_SID`     BIGINT(65) NOT NULL,
    `RESOURCE_TYPE` CHAR(1) COMMENT '0目录级、1数据级、2数据项级',
    `CREATE_BY`     VARCHAR(255),
    `CREATE_TIME`   DATETIME,
    `UPDATE_BY`     VARCHAR(255),
    `UPDATE_TIME`   DATETIME,
    PRIMARY KEY (`RESOURCE_SID`, `LEVEL_SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cl_level_info
-- ----------------------------
DROP TABLE IF EXISTS `CL_LEVEL_INFO`;
CREATE TABLE `CL_LEVEL_INFO`
(
    `SID`         BIGINT(65) NOT NULL,
    `LEVEL_CODE`  BIGINT(65),
    `LEVEL_NAME`  VARCHAR(64),
    `LEVEL_DESC`  VARCHAR(128),
    `UPPER_LEVEL` BIGINT(65) COMMENT '第一级时为空',
    `LEVEL_NUM`   BIGINT(65) COMMENT '1/2',
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cl_resouce_count
-- ----------------------------
DROP TABLE IF EXISTS `CL_RESOUCE_COUNT`;
CREATE TABLE `CL_RESOUCE_COUNT`
(
    `sid`          BIGINT(65) NOT NULL,
    `TOTAL_NUM`    INT(11),
    `BATCH_NUMBER` BIGINT(65),
    PRIMARY KEY (`sid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cl_resouce_count_temp
-- ----------------------------
DROP TABLE IF EXISTS `CL_RESOUCE_COUNT_TEMP`;
CREATE TABLE `CL_RESOUCE_COUNT_TEMP`
(
    `sid`          BIGINT(65) NOT NULL,
    `TOTAL_NUM`    INT(11),
    `BATCH_NUMBER` BIGINT(65) COMMENT '批次号',
    PRIMARY KEY (`sid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cl_role_classif
-- ----------------------------
DROP TABLE IF EXISTS `CL_ROLE_CLASSIF`;
CREATE TABLE `CL_ROLE_CLASSIF`
(
    `ROLE_SID`    VARCHAR(65) NOT NULL,
    `CLASSIF_SID` BIGINT(65) NOT NULL,
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    PRIMARY KEY (`ROLE_SID`, `CLASSIF_SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cl_role_level
-- ----------------------------
DROP TABLE IF EXISTS `CL_ROLE_LEVEL`;
CREATE TABLE `CL_ROLE_LEVEL`
(
    `ROLE_SID`    VARCHAR(65) NOT NULL,
    `LEVEL_SID`   BIGINT(65) NOT NULL,
    `CREATE_BY`   VARCHAR(255),
    `CREATE_TIME` DATETIME,
    `UPDATE_BY`   VARCHAR(255),
    `UPDATE_TIME` DATETIME,
    PRIMARY KEY (`ROLE_SID`, `LEVEL_SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cof_dict_entry
-- ----------------------------
DROP TABLE IF EXISTS `COF_DICT_ENTRY`;
CREATE TABLE `COF_DICT_ENTRY`
(
    `ID`           VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '字典项ID',
    `CODE`         VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典项编码',
    `DICT_TYPE_ID` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典类型ID',
    `NAME`         VARCHAR(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '字典项名称',
    `DESCRIPTION`  VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '描述',
    `CREATE_TIME`  DATETIME NULL DEFAULT NULL COMMENT '创建时间',
    `UPDATE_TIME`  DATETIME NULL DEFAULT NULL COMMENT '更新时间',
    `TENANT_ID`    VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户ID',
    `PARENT_ID`    VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '父字典项ID',
    `LOCALE`       VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '默认语言',
    `STATUS`       VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '状态 ',
    `SORT_NO`      INT(11) NULL DEFAULT NULL COMMENT '排序字段',
    `IS_LEAF`      TINYINT(1) NULL DEFAULT NULL COMMENT '是否叶节点',
    `TREE_LEVEL`   INT(11) NULL DEFAULT NULL COMMENT '层级',
    `SEQ`          VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '序列码',
    `IS_FIXED`     TINYINT(1) NULL DEFAULT NULL COMMENT '是否固定，如果是，则数据不能修改，不能删除',
    PRIMARY KEY (`ID`) USING BTREE,
    INDEX          `COF_DICT_ENTRY_INDEX_CODE`(`CODE`) USING BTREE,
    INDEX          `COF_DICT_ENTRY_INDEX_NAME`(`NAME`) USING BTREE,
    INDEX          `COF_DICT_ENTRY_INDEX_SEQ`(`SEQ`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典项' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for cof_dict_type
-- ----------------------------
DROP TABLE IF EXISTS `COF_DICT_TYPE`;
CREATE TABLE `COF_DICT_TYPE`
(
    `ID`          VARCHAR(64) NOT NULL COMMENT '字典类型ID',
    `CODE`        VARCHAR(64) COMMENT '字典类型编码',
    `NAME`        VARCHAR(128) COMMENT '字典类型名称',
    `DESCRIPTION` VARCHAR(256) COMMENT '描述',
    `CREATE_TIME` DATETIME COMMENT '创建时间',
    `UPDATE_TIME` DATETIME COMMENT '更新时间',
    `TENANT_ID`   VARCHAR(64) COMMENT '租户ID',
    `PARENT_ID`   VARCHAR(64) COMMENT '父字典类型ID',
    `LOCALE`      VARCHAR(64) COMMENT '默认语言',
    `SORT_NO`     INT(11) COMMENT '排序字段',
    `IS_LEAF`     TINYINT(1) COMMENT '是否叶节点',
    `TREE_LEVEL`  INT(11) COMMENT '层级',
    `SEQ`         VARCHAR(256) COMMENT '序列码',
    `IS_FIXED`    TINYINT(1) COMMENT '是否固定，如果是，则数据不能修改，不能删除',
    PRIMARY KEY (`ID`) USING BTREE,
    INDEX         `COF_DICT_TYPE_INDEX_CODE`(`CODE`) USING BTREE,
    INDEX         `COF_DICT_TYPE_INDEX_NAME`(`NAME`) USING BTREE,
    INDEX         `COF_DICT_TYPE_INDEX_SEQ`(`SEQ`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '字典类型' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for ds_data_config_mgr
-- ----------------------------
DROP TABLE IF EXISTS `DS_DATA_CONFIG_MGR`;
CREATE TABLE `DS_DATA_CONFIG_MGR`
(
    `SID`                BIGINT(65) NOT NULL,
    `CONFIGCODE`         VARCHAR(50) NOT NULL,
    `CONFIGNAME`         VARCHAR(50) NOT NULL,
    `CONFIGTYPE`         VARCHAR(25) NOT NULL,
    `USERKEYTABFILE`     VARCHAR(255),
    `KRB5FILE`           VARCHAR(255),
    `HIVECLIENTPROPFILE` VARCHAR(255),
    `HDFSSITEFILE`       VARCHAR(255),
    `CORESITEFILE`       VARCHAR(255),
    `HBASESITEFILE`      VARCHAR(255),
    `DESCRIPTION`        VARCHAR(500),
    `CREATE_BY`          VARCHAR(255),
    `CREATE_TIME`        DATETIME,
    `UPDATE_BY`          VARCHAR(255),
    `UPDATE_TIME`        DATETIME,
    `PATH_TYPE`          VARCHAR(255) DEFAULT 'LOCAL' COMMENT 'LOCAL/SFTP',
    `SFTP_PATH`          VARCHAR(255) COMMENT 'SFTP的路径',
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for ds_data_source
-- ----------------------------
DROP TABLE IF EXISTS `DS_DATA_SOURCE`;
CREATE TABLE `DS_DATA_SOURCE`
(
    `SID`                  BIGINT(65) NOT NULL,
    `DATA_SOURCE_NAME`     VARCHAR(300) COMMENT '数据源名称',
    `URL`                  VARCHAR(1000),
    `DRIVER`               VARCHAR(100),
    `USER_NAME`            VARCHAR(60),
    `PWD`                  VARCHAR(255),
    `SOURCE`               VARCHAR(10) COMMENT '数据源来源：1：元数据:2：自建:3：同步',
    `CREATE_BY`            VARCHAR(255),
    `CREATE_TIME`          DATETIME,
    `UPDATE_BY`            VARCHAR(255),
    `UPDATE_TIME`          DATETIME,
    `DATA_SOURCE_CODE`     VARCHAR(255),
    `METACUBE_DEFINE_NAME` VARCHAR(255),
    `DATASOURCE_TYPE`      VARCHAR(50),
    `CONFIGMGR_SID`        VARCHAR(65),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for ds_hbase_mappping
-- ----------------------------
DROP TABLE IF EXISTS `DS_HBASE_MAPPPING`;
CREATE TABLE `DS_HBASE_MAPPPING`
(
    `sid`              BIGINT(65) NOT NULL,
    `hive_ds_id`       VARCHAR(100),
    `hive_ds_name`     VARCHAR(100),
    `hive_db_name`     VARCHAR(100),
    `hive_table`       VARCHAR(100),
    `hbase_ds_id`      VARCHAR(100),
    `hbase_ds_name`    VARCHAR(100),
    `hbase_namespace`  VARCHAR(100),
    `hbase_table`      VARCHAR(100) NOT NULL,
    `storage_type`     VARCHAR(20) DEFAULT 'string',
    `column_mappings`  TEXT,
    `serde_properties` TEXT,
    `tbl_properties`   VARCHAR(1024),
    `create_time`      DATETIME,
    `create_by`        VARCHAR(255),
    `update_time`      DATETIME,
    `update_by`        VARCHAR(255),
    PRIMARY KEY (`sid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'HBase映射表管理' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for ds_resource_info
-- ----------------------------
DROP TABLE IF EXISTS `DS_RESOURCE_INFO`;
CREATE TABLE `DS_RESOURCE_INFO`
(
    `TABLE_TAG`             VARCHAR(255),
    `SID`                   bigint(65) NOT NULL,
    `RESOURCE_CODE`         VARCHAR(64),
    `RESOURCE_NAME`         VARCHAR(2000),
    `DIRECTORY_CODE`        VARCHAR(64),
    `DIRECTORY_NAME`        VARCHAR(2000),
    `AUTHORITY_UNIT`        VARCHAR(128),
    `SOURCE_TYPE`           bigint(65),
    `OBTAIN_WAY`            bigint(65),
    `APP_SYSTEM`            VARCHAR(128),
    `MANAGE_UNIT`           VARCHAR(128),
    `DATA_LOCATION`         VARCHAR(32),
    `STORAGE_CENTER`        VARCHAR(32),
    `STATUS`                char(1) COMMENT '状态:  4已发布',
    `DESCRIPTION`           VARCHAR(2000),
    `STORAGE_SCALE`         VARCHAR(128),
    `STORAGE_CYCLE`         VARCHAR(128),
    `UPDATE_CYCLE`          VARCHAR(128),
    `UPDATE_SCALE`          VARCHAR(128),
    `DATA_UPDATE_TIME`      datetime,
    `REGISTER_TIME`         datetime,
    `META_DIR_CODE`         VARCHAR(128) COMMENT '资源关联的表所在目录编码',
    `SCHEMA_CODE`           VARCHAR(128) COMMENT '资源关联的表所在库编码',
    `TABLE_CODE`            VARCHAR(128) COMMENT '资源关联的表编码',
    `CREATE_BY`             VARCHAR(255),
    `CREATE_TIME`           datetime,
    `UPDATE_BY`             VARCHAR(255),
    `UPDATE_TIME`           datetime,
    `DATA_SOURCE_NAME`      VARCHAR(300) COMMENT '数据源名称',
    `RESOURCE_TYPE`         VARCHAR(20),
    `INIT_SOLR`             char(1) COMMENT '是否已加入solr',
    `DATA_ORGANIZATION`     bigint(65) COMMENT '数组组织ID',
    `LABEL_1`               bigint(65) COMMENT '数组组织-标签1ID',
    `LABEL_2`               bigint(65) COMMENT '数组组织-标签2ID',
    `LABEL_3`               bigint(65) COMMENT '数组组织-标签3ID',
    `LABEL_4`               bigint(65) COMMENT '数组组织-标签4ID',
    `LABEL_5`               bigint(65) COMMENT '数组组织-标签5ID',
    `INSTANCE_ID`           VARCHAR(128),
    `ISPEAT`                VARCHAR(64) COMMENT '是否重复',
    `TABLEDESC`             VARCHAR(6000),
    `DATAMODE`              VARCHAR(255) COMMENT '数据生成方式',
    `WHYREPEAT`             VARCHAR(500) COMMENT '重复原因',
    `DIFFERSERV`            VARCHAR(255),
    `TABLE_RECORD`          VARCHAR(255),
    `MAPPING_NUMBER`        VARCHAR(200),
    `MAPPING_FIELD`         VARCHAR(200),
    `DATA_TABLE_NUM`        VARCHAR(255),
    `DEPLOY_TYPE`           VARCHAR(300),
    `LAST_UPDATE_TIME`      VARCHAR(100),
    `FUNCTION_TEMPLATE`     VARCHAR(255),
    `SUB_FUNCTION_TEMPLATE` VARCHAR(255),
    `IS_ACCESS`             VARCHAR(255),
    `mainDataId`            VARCHAR(100),
    `WHY_NEGATIVELIST`      VARCHAR(255),
    `IS_NEGATIVELIST`       VARCHAR(255),
    `ID`                    VARCHAR(100),
    `mainTableId`           VARCHAR(100),
    `busi_type_num`         VARCHAR(100),
    `topic_num`             VARCHAR(100),
    `TABLE_NAMESPACE`       VARCHAR(255),
    `TABLE_NAME`            VARCHAR(512),
    `principal`             VARCHAR(255) COMMENT '责任人',
    PRIMARY KEY (`SID`) USING BTREE,
    INDEX                   `IDX_DRI_DATAORGANIZATION`(`DATA_ORGANIZATION`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '存储数据资源基本信息，如数据名称等，与元数据的表对应' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for ds_resource_item
-- ----------------------------
DROP TABLE IF EXISTS `DS_RESOURCE_ITEM`;
CREATE TABLE `DS_RESOURCE_ITEM`
(
    `SID`                  BIGINT(65) NOT NULL,
    `RESOURCE_SID`         BIGINT(65),
    `ITEM_CODE`            VARCHAR(200),
    `ITEM_NAME`            VARCHAR(2000),
    `IS_QUERY`             CHAR(1),
    `QUERY_MATCH_TYPE`     VARCHAR(128),
    `IS_SUBSCRIBE`         CHAR(1),
    `SUBSCRIBE_MATCH_TYPE` VARCHAR(128),
    `CREATE_BY`            VARCHAR(255),
    `CREATE_TIME`          DATETIME,
    `UPDATE_BY`            VARCHAR(255),
    `UPDATE_TIME`          DATETIME,
    `INSTANCE_ID`          VARCHAR(255) COMMENT '元数据id',
    `SYNCDATE`             DATETIME COMMENT '元数据同步时间',
    `SEQ`                  BIGINT(65),
    `ITEM_TYPE`            VARCHAR(500),
    `INSTANCE_CODE`        VARCHAR(255) COMMENT '字段英文名',
    `INSTANCE_NAME`        VARCHAR(2000) COMMENT '中文名',
    `COMMENTS`             VARCHAR(5000) COMMENT '描述，注释',
    `IS_PK`                VARCHAR(255) COMMENT '是否主键',
    `IS_UNIQUE`            VARCHAR(255) COMMENT '是否唯一键',
    `IS_FK`                VARCHAR(255) COMMENT '是否外键',
    `IS_NULLABLE`          VARCHAR(255) COMMENT '是否为空',
    `COLLENGTHS`           VARCHAR(255) COMMENT '长度',
    `SCALES`               VARCHAR(255) COMMENT '小数位',
    `INITIAL_VALUE`        VARCHAR(255) COMMENT '默认值',
    `IS_SHARE`             VARCHAR(255) COMMENT '是否有条件共享',
    `IS_MASKING`           VARCHAR(255) COMMENT '是否脱敏',
    `DATA_TYPE`            VARCHAR(500) COMMENT '数据类型',
    `WHY_SHARE`            VARCHAR(2000) COMMENT '不能共享原因',
    `DESEN_RULE`           VARCHAR(500) COMMENT '脱敏规则',
    `STD_CODE`             VARCHAR(255) COMMENT '标准编码',
    `STORAGE_FORMAT`       VARCHAR(255) COMMENT '存储格式',
    `IS_BASE`              VARCHAR(255) COMMENT '是否基线版',
    `SOURCE_SYSTEM`        VARCHAR(255) COMMENT '来源系统',
    `OWN_USER`             VARCHAR(255) COMMENT '所属用户',
    `SOURCE_TB_EN`         VARCHAR(255) COMMENT '源表英文名',
    `SOURCE_TB_CN`         VARCHAR(255) COMMENT '源表中文名',
    `SOURCE_TB_DESC`       TEXT,
    `SOURCE_COL_EN`        VARCHAR(255) COMMENT '源表字段英文',
    `SOURCE_COL_CN`        VARCHAR(255) COMMENT '源字段中文名',
    `SOURCE_COL_DESC`      TEXT,
    `REB_DEPT`             VARCHAR(255) COMMENT '责任部门',
    `BUS_DEPT_IS_CFM`      VARCHAR(255) COMMENT '业务部门是否确认',
    `DATA_IS_CFM`          VARCHAR(255) COMMENT '数据是否落地',
    `LATEST_VER_NO`        VARCHAR(255) COMMENT '最新版本号',
    `LATEST_REVISION_NO`   VARCHAR(255) COMMENT '最终修订版本号',
    `CONSTRAINTS_KEY`      VARCHAR(255) COMMENT '约束键',
    `status`               VARCHAR(10),
    `ID`                   VARCHAR(100),
    `mainTableId`          VARCHAR(100),
    `mainDataId`           VARCHAR(100),
    `SOURCE_COL_TYPE`      VARCHAR(100),
    `principal`            VARCHAR(255) COMMENT '责任人',
    PRIMARY KEY (`SID`) USING BTREE,
    INDEX                  `IDX_DSRI_RESOURCESID`(`RESOURCE_SID`) USING BTREE,
    INDEX                  `IDX_DSRI_INSTANCEID`(`INSTANCE_ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '存储数据资源项信息，与元数据的列对应，其与数据资源信息表对应关系为多对1' ROW_FORMAT = Dynamic;


-- ----------------------------
-- Table structure for po_feedback
-- ----------------------------
DROP TABLE IF EXISTS `PO_FEEDBACK`;
CREATE TABLE `PO_FEEDBACK`
(
    `SID`         BIGINT(65) NOT NULL,
    `OPTIONID`    BIGINT(65) NOT NULL,
    `USERNAME`    VARCHAR(32) NOT NULL,
    `FEEDBACK`    TEXT        NOT NULL,
    `CREATE_BY`   VARCHAR(255) COMMENT '创建时的userid',
    `UPDATE_BY`   VARCHAR(255) COMMENT '最后一次修改者的userid',
    `CREATE_TIME` DATETIME,
    `UPDATE_TIME` DATETIME COMMENT '最后一次修改该记录的时间',
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

-- ----------------------------
-- Table structure for po_files
-- ----------------------------
DROP TABLE IF EXISTS `PO_FILES`;
CREATE TABLE `PO_FILES`
(
    `SID`            BIGINT(65) NOT NULL,
    `RELID`          BIGINT(65) COMMENT '附件所关联的对象ID',
    `FILENAME`       VARCHAR(64) NOT NULL,
    `ACTUALFILENAME` VARCHAR(64) NOT NULL,
    `FILEPATH`       VARCHAR(255) COMMENT '可以使用 http://ip:port/files/文件名称 访问上传路径下的文件',
    `CREATE_BY`      VARCHAR(255) COMMENT '创建时的userid',
    `UPDATE_BY`      VARCHAR(255) COMMENT '最后一次修改者的userid',
    `CREATE_TIME`    DATETIME,
    `UPDATE_TIME`    DATETIME COMMENT '最后一次修改该记录的时间',
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for po_options
-- ----------------------------
DROP TABLE IF EXISTS `PO_OPTIONS`;
CREATE TABLE `PO_OPTIONS`
(
    `SID`          BIGINT(65) NOT NULL,
    `TITLE`        VARCHAR(32) NOT NULL,
    `SOURCE`       VARCHAR(32) NOT NULL COMMENT '来源于静态参数 存静态参数的ID 有   质量检核  隐患  用户反馈 其他途径',
    `DATARESOURCE` VARCHAR(32),
    `FIELD`        VARCHAR(32),
    `DESCRIPTION`  TEXT        NOT NULL,
    `STATUS`       CHAR(1)     NOT NULL COMMENT '0  未反馈 1  已反馈 9  已关闭',
    `USERNAME`     VARCHAR(32) NOT NULL,
    `CREATE_BY`    VARCHAR(255) COMMENT '创建时的userid',
    `UPDATE_BY`    VARCHAR(255) COMMENT '最后一次修改者的userid',
    `CREATE_TIME`  DATETIME,
    `UPDATE_TIME`  DATETIME COMMENT '最后一次修改该记录的时间',
    `CONTACTINFO`  VARCHAR(255),
    PRIMARY KEY (`SID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

DROP TABLE IF EXISTS `DQMS_OPERATION_LOG`;
create table DQMS_OPERATION_LOG
(
    ID                   varchar(64) not null comment '操作日志ID',
    OPERATOR_ID          varchar(64) comment '操作者ID',
    OPERATOR_NAME        varchar(64) comment '操作者名称',
    OPERATE_TYPE         int comment '操作类型',
    OPERATE_DATE         datetime comment '时间',
    TARGET_TYPE          varchar(64) comment '目标类型',
    TARGET_MODEL_ID      varchar(64) comment '目标ID',
    TARGET_MODEL_NAME    varchar(64) comment '目标名称',
    MESSAGE              text comment '信息',
    TENANT_ID            varchar(64) comment '租户ID',
    primary key (ID)
);

alter table DQMS_OPERATION_LOG comment '操作日志';
alter table DQMS_OPERATION_LOG add index DQMS_OPERATION_LOG_INDEX_OPERATOR(OPERATOR_NAME);
alter table DQMS_OPERATION_LOG add index DQMS_OPERATION_LOG_INDEX_OPERATE_TYPE(OPERATE_TYPE);
alter table DQMS_OPERATION_LOG add index DQMS_OPERATION_LOG_INDEX_TARGET(TARGET_TYPE, TARGET_MODEL_ID, TARGET_MODEL_NAME);

DROP TABLE IF EXISTS `DQMS_OPERATION_LOG_DETAIL`;
create table DQMS_OPERATION_LOG_DETAIL
(
    ID                   varchar(64) not null comment '日志详情ID',
    OLD_DATA_JSON        text comment '旧值',
    NEW_DATA_JSON        text comment '新值',
    primary key (ID)
);

alter table DQMS_OPERATION_LOG_DETAIL comment '操作日志详情';

-- ---------------------------
-- 组织机构评分
-- ---------------------------
DROP TABLE IF EXISTS DQMS_RATING_RESULT;
CREATE TABLE DQMS_RATING_RESULT(
   ID BIGINT PRIMARY KEY AUTO_INCREMENT,
   ORG_ID VARCHAR(64) COMMENT '组织ID',
   ORG_NAME VARCHAR(50) COMMENT '组织名',
   ORG_LEVEL VARCHAR(2)  COMMENT '组织等级',
   PARENT_ORG_ID VARCHAR(64)  COMMENT '父组织ID',
   SCORE DOUBLE  COMMENT '得分',
   START_DATE DATETIME COMMENT'评估开始日期',
   END_DATE DATETIME COMMENT'评估截至日期',
   RATING_CYCLE VARCHAR(50) COMMENT '评分周期 年（year）、季度（quarter）、月（month）、周（week），默认月',
   RATING_POINT VARCHAR(50)  COMMENT'评分点 例如：2023-01',
   CREATE_TIME DATETIME,
   CREATE_USER VARCHAR(25),
   LAST_MODIFIER_TIME DATETIME,
   LAST_MODIFIER_USER VARCHAR(25)
);
