-- Source: vega/vega-backend/migrations/mariadb/0.5.0/init.sql
-- Copyright The kweaver.ai Authors.
--
-- Licensed under the Apache License, Version 2.0.
-- See the LICENSE file in the project root for details.

-- ==========================================
-- VEGA Catalog 表结构定义
-- ==========================================

-- ==========================================
-- Schema定义说明（f_schema_definition字段JSON格式）
-- ==========================================
-- f_schema_definition 字段使用JSON数组格式存储所有字段信息，每个字段包含以下属性：
--
-- 基础属性：
--   - name: 字段名称
--   - type: VEGA统一类型 (integer, unsigned_integer, float, decimal, string, text, date, datetime, time, boolean, binary, json, vector)
--   - description: 字段描述
--   - type_config: 类型配置对象 (如 {"max_length": 128}, {"dimension": 768})
--
-- 源端映射：
--   - source_name: 源端字段名（可能与name不同）
--   - source_type: 源端字段类型
--   - is_native: 是否为系统自动同步的字段
--
-- 字段属性：
--   - is_primary: 是否为主键
--   - is_nullable: 是否可为空
--   - default_value: 默认值
--   - ordinal_position: 字段顺序位置
--
-- 字段特征（features数组，可选，用于扩展字段能力）：
--   - feature_type: 特征类型 (keyword, fulltext, vector)
--   - feature_config: 特征配置对象 (如分词器、向量空间类型等)
--   - ref_field_name: 引用的字段名称（用于借用其他字段的能力）
--   - enabled: 是否启用
--
-- 示例：
-- [
--   {
--     "name": "id",
--     "type": "integer",
--     "description": "主键ID",
--     "type_config": {"length": 11},
--     "source_name": "id",
--     "source_type": "int(11)",
--     "is_native": true,
--     "is_primary": true,
--     "is_nullable": false,
--     "default_value": "",
--     "ordinal_position": 1
--   },
--   {
--     "name": "content",
--     "type": "text",
--     "description": "文章内容",
--     "type_config": {},
--     "source_name": "content",
--     "source_type": "text",
--     "is_native": true,
--     "is_primary": false,
--     "is_nullable": true,
--     "default_value": "",
--     "ordinal_position": 2,
--     "features": [
--       {
--         "feature_type": "fulltext",
--         "feature_config": {"analyzer": "ik_max_word"},
--         "ref_field_name": "",
--         "is_default": true
--       }
--     ]
--   },
--   {
--     "name": "embedding",
--     "type": "vector",
--     "description": "向量嵌入",
--     "type_config": {"dimension": 768},
--     "source_name": "",
--     "source_type": "",
--     "is_native": false,
--     "is_primary": false,
--     "is_nullable": true,
--     "default_value": "",
--     "ordinal_position": 3,
--     "features": [
--       {
--         "feature_type": "vector",
--         "feature_config": {"space_type": "cosinesimil", "m": 16, "ef_construction": 200},
--         "ref_field_name": "",
--         "is_default": true
--       }
--     ]
--   }
-- ]
-- ==========================================
USE adp;
-- ==========================================
-- 1. t_catalog 主表
-- ==========================================
CREATE TABLE IF NOT EXISTS t_catalog (
    -- 主键与基础信息
    f_id                      VARCHAR(40) NOT NULL DEFAULT '' COMMENT 'catalog唯一标识',
    f_name                    VARCHAR(255) NOT NULL DEFAULT '' COMMENT '目录名称，系统一级命名空间',
    f_tags                    VARCHAR(255) NOT NULL DEFAULT '[]' COMMENT '标签，逗号分隔，用于分类和检索',
    f_description             VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '目录描述',

    f_type                    VARCHAR(20) NOT NULL DEFAULT '' COMMENT '目录类型: physical, logical',
    f_enabled                 BOOLEAN NOT NULL DEFAULT TRUE COMMENT '是否启用',

    -- Physical Catalog 专属字段
    f_connector_type          VARCHAR(50) NOT NULL DEFAULT '' COMMENT '数据源类型: mysql, postgresql, s3, kafka, elasticsearch, api, prometheus, etc.',
    f_connector_config        MEDIUMTEXT NOT NULL COMMENT '加密存储的连接配置（JSON格式）',
    f_metadata                MEDIUMTEXT NOT NULL COMMENT '自动发现的元数据（JSON格式），如数据库版本等',

    -- 状态管理
    f_health_check_enabled    BOOLEAN NOT NULL DEFAULT TRUE COMMENT '是否启用健康检查',
    f_health_check_status     VARCHAR(20) NOT NULL DEFAULT 'healthy' COMMENT '连接状态: healthy, degraded, unhealthy, offline, disabled',
    f_last_check_time         BIGINT(20) NOT NULL DEFAULT 0 COMMENT '最后健康检查时间',
    f_health_check_result     TEXT NOT NULL COMMENT '健康检查结果',

    -- 审计字段
    f_creator                 VARCHAR(128) NOT NULL DEFAULT '' COMMENT '创建者id',
    f_creator_type            VARCHAR(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
    f_create_time             BIGINT(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
    f_updater                 VARCHAR(128) NOT NULL DEFAULT ''COMMENT '更新者id',
    f_updater_type            VARCHAR(20) NOT NULL DEFAULT '' COMMENT '更新者类型',
    f_update_time             BIGINT(20) NOT NULL DEFAULT 0 COMMENT '更新时间',

    -- 索引
    PRIMARY KEY (f_id),
    UNIQUE INDEX uk_name (f_name),
    INDEX idx_type (f_type),
    INDEX idx_connector_type (f_connector_type),
    INDEX idx_health_check_status (f_health_check_status)
)  ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT='目录表，管理数据源连接和命名空间';


-- ==========================================
-- 2. t_catalog_discover_policy 发现与变更策略表
-- ==========================================
CREATE TABLE IF NOT EXISTS t_catalog_discover_policy (
    f_id                      VARCHAR(40) NOT NULL DEFAULT '' COMMENT '所属catalog ID',

    -- 状态
    f_enabled                 BOOLEAN NOT NULL DEFAULT FALSE COMMENT '是否启用',

    -- 发现策略配置
    f_discover_mode          VARCHAR(20) NOT NULL DEFAULT 'manual' COMMENT '数据资源发现模式: manual, scheduled, event_driven',
    f_discover_cron          VARCHAR(100) NOT NULL DEFAULT '' COMMENT 'scheduled模式的cron表达式',
    f_discover_config        MEDIUMTEXT NOT NULL COMMENT '发现策略详细配置',

    -- 变更处理策略
    f_on_resource_added       VARCHAR(20) NOT NULL DEFAULT 'auto_register' COMMENT '新增数据资源策略: auto_register, pending_review, ignore',
    f_on_resource_removed     VARCHAR(20) NOT NULL DEFAULT 'mark_stale' COMMENT '删除数据资源策略: auto_remove, mark_stale, ignore',
    f_on_schema_changed       VARCHAR(20) NOT NULL DEFAULT 'auto_update' COMMENT 'Schema变更策略: auto_update, pending_review, ignore',
    f_on_file_content_changed VARCHAR(20) NOT NULL DEFAULT 'pending_review' COMMENT '文件内容变更策略: pending_review, ignore',

    -- 策略详细配置
    f_change_policy_config    MEDIUMTEXT NOT NULL COMMENT '变更策略详细配置（如通知设置、审批流程等）',

    -- 索引
    PRIMARY KEY (f_id),
    INDEX idx_discover_mode (f_discover_mode),
    INDEX idx_enabled (f_enabled)
)  ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT='Catalog发现与变更策略配置表';


-- ==========================================
-- 3. t_resource 数据资源主表
-- ==========================================
CREATE TABLE IF NOT EXISTS t_resource (
    -- 主键与基础信息
    f_id                      VARCHAR(40) NOT NULL DEFAULT '' COMMENT 'resource唯一标识',
    f_catalog_id              VARCHAR(40) NOT NULL DEFAULT '' COMMENT '所属catalog ID',
    f_name                    VARCHAR(255) NOT NULL DEFAULT '' COMMENT '数据资源名称，catalog下唯一',
    f_tags                    VARCHAR(255) NOT NULL DEFAULT '[]' COMMENT '标签，JSON数组格式',
    f_description             VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '数据资源描述',

    f_category                VARCHAR(20) NOT NULL DEFAULT '' COMMENT '数据资源类型: table, file, fileset, api, metric, topic, index, logicview, dataset',

    -- 状态管理
    f_status                  VARCHAR(20) NOT NULL DEFAULT 'active' COMMENT '数据资源状态: active, disabled, deprecated, stale',
    f_status_message          VARCHAR(500) NOT NULL DEFAULT '' COMMENT '状态说明',

    -- 物理数据资源专属字段
    f_database                VARCHAR(128) NOT NULL DEFAULT '' COMMENT '所属数据库名称（实例级连接时使用）',
    f_source_identifier       VARCHAR(500) NOT NULL DEFAULT '' COMMENT '源端标识(表名/文件路径/索引名等)',
    f_source_metadata         MEDIUMTEXT NOT NULL COMMENT '源端元数据（JSON格式）',

    -- Schema相关
    f_schema_definition       MEDIUMTEXT NOT NULL COMMENT 'Schema定义（JSON数组格式，包含所有字段信息）',

    -- LogicView 专属字段
    f_logic_type              VARCHAR(20) NOT NULL DEFAULT '' COMMENT '逻辑类型: derived(衍生), composite(复合), 仅LogicView使用',
    f_logic_definition        MEDIUMTEXT NOT NULL COMMENT '逻辑定义（JSON格式），仅LogicView使用',

    -- Local查询配置（物化）
    f_local_enabled           BOOLEAN NOT NULL DEFAULT FALSE COMMENT '是否启用Local查询（物化）',
    f_local_storage_engine    VARCHAR(50) NOT NULL DEFAULT '' COMMENT '物化存储引擎: elasticsearch, opensearch, lancedb, pgvector',
    f_local_storage_config    MEDIUMTEXT NOT NULL COMMENT '物化存储配置（JSON格式）',
    f_local_index_name        VARCHAR(255) NOT NULL DEFAULT '' COMMENT '物化后的索引名称',

    -- 同步配置
    f_sync_strategy           VARCHAR(20) NOT NULL DEFAULT '' COMMENT '同步策略: cdc, bulk_load, etl_pipeline, polling, micro_batch, reindex, snapshot',
    f_sync_config             MEDIUMTEXT NOT NULL COMMENT '同步配置（JSON格式：调度周期、批次大小等）',
    f_sync_status             VARCHAR(20) NOT NULL DEFAULT 'not_synced' COMMENT '同步状态: not_synced, syncing, synced, failed',
    f_last_sync_time          BIGINT(20) NOT NULL DEFAULT 0 COMMENT '最后同步时间',
    f_sync_error_message      TEXT NOT NULL COMMENT '同步错误信息',

    -- 审计字段
    f_creator                 VARCHAR(128) NOT NULL DEFAULT '' COMMENT '创建者id',
    f_creator_type            VARCHAR(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
    f_create_time             BIGINT(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
    f_updater                 VARCHAR(128) NOT NULL DEFAULT '' COMMENT '更新者id',
    f_updater_type            VARCHAR(20) NOT NULL DEFAULT '' COMMENT '更新者类型',
    f_update_time             BIGINT(20) NOT NULL DEFAULT 0 COMMENT '更新时间',

    -- 索引
    PRIMARY KEY (f_id),
    UNIQUE INDEX uk_catalog_name (f_catalog_id, f_name),
    INDEX idx_category (f_category),
    INDEX idx_status (f_status)
)  ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT='数据资源主表，管理所有类型的数据资源';


-- ==========================================
-- 4. t_resource_schema_history Schema历史表
-- ==========================================
CREATE TABLE IF NOT EXISTS t_resource_schema_history (
    f_id                      VARCHAR(40) NOT NULL DEFAULT '' COMMENT '历史记录唯一标识',
    f_resource_id             VARCHAR(40) NOT NULL DEFAULT '' COMMENT '所属resource ID',
    f_schema_version          VARCHAR(40) NOT NULL DEFAULT '' COMMENT 'Schema版本号',
    f_schema_definition       MEDIUMTEXT NOT NULL COMMENT 'Schema定义快照（JSON数组格式）',

    -- 变更信息
    f_change_type             VARCHAR(20) NOT NULL DEFAULT '' COMMENT '变更类型: created, field_added, field_removed, field_modified, type_changed',
    f_change_summary          VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '变更摘要',
    f_schema_inferred         BOOLEAN NOT NULL DEFAULT FALSE COMMENT 'Schema是否为自动推导',
    f_change_time             BIGINT(20) NOT NULL DEFAULT 0 COMMENT '变更时间',

    -- 索引
    PRIMARY KEY (f_id),
    INDEX idx_resource_id (f_resource_id)
)  ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT='数据资源Schema历史表，记录Schema变更历史';


-- ==========================================
-- 5. t_connector_type Connector 类型注册表
-- ==========================================
CREATE TABLE IF NOT EXISTS t_connector_type (
    -- 主键与基础信息
    f_type                    VARCHAR(40) NOT NULL DEFAULT '' COMMENT 'connector类型,唯一标识',
    f_name                    VARCHAR(255) NOT NULL DEFAULT '' COMMENT '类型名称: mysql, postgresql, kafka...',
    f_tags                    VARCHAR(255) NOT NULL DEFAULT '[]' COMMENT '标签，JSON数组格式',
    f_description             VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '类型描述',

    -- 类型分类
    f_mode                    VARCHAR(20) NOT NULL DEFAULT '' COMMENT '模式: local, remote',
    f_category                VARCHAR(32) NOT NULL DEFAULT '' COMMENT '分类: table, index, topic, file, api',

    -- Remote 模式专用字段
    f_endpoint                VARCHAR(512) NOT NULL DEFAULT '' COMMENT '远程服务地址 (仅remote模式)',

    -- 字段配置列表（JSON数组格式）
    f_field_config            MEDIUMTEXT NOT NULL COMMENT '字段配置列表（JSON数组格式，定义连接配置的结构）',

    -- 状态
    f_enabled                 BOOLEAN NOT NULL DEFAULT TRUE COMMENT '是否启用',

    -- 索引
    PRIMARY KEY (f_type),
    UNIQUE INDEX uk_name (f_name),
    INDEX idx_mode (f_mode),
    INDEX idx_category (f_category),
    INDEX idx_enabled (f_enabled)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT='Connector类型注册表';


-- ==========================================
-- 6. 初始化内置 Local Connector
-- ==========================================
INSERT INTO t_connector_type (f_type, f_name, f_description, f_mode, f_category, f_field_config, f_enabled)
SELECT 'mariadb', 'mariadb', 'MariaDB 关系型数据库连接器', 'local', 'table',
    '{
        "host":      {"name":"主机地址","type":"string","description":"数据库服务器主机地址","required":true,"encrypted":false},
        "port":      {"name":"端口号","type":"integer","description":"数据库服务器端口","required":true,"encrypted":false},
        "username":  {"name":"用户名","type":"string","description":"数据库用户名","required":true,"encrypted":false},
        "password":  {"name":"密码","type":"string","description":"数据库密码","required":true,"encrypted":true},
        "databases": {"name":"数据库列表","type":"array","description":"数据库名称列表（可选，为空则连接实例级别）","required":false,"encrypted":false},
        "options":   {"name":"连接参数","type":"object","description":"连接参数（如 charset, timeout 等）","required":false,"encrypted":false}
    }',
    TRUE
FROM DUAL WHERE NOT EXISTS ( SELECT f_type FROM t_connector_type WHERE f_type = 'mariadb' );

INSERT INTO t_connector_type (f_type, f_name, f_description, f_mode, f_category, f_field_config, f_enabled)
SELECT 'mysql', 'mysql', 'MySQL 关系型数据库连接器', 'local', 'table',
       '{
           "host":      {"name":"主机地址","type":"string","description":"数据库服务器主机地址","required":true,"encrypted":false},
           "port":      {"name":"端口号","type":"integer","description":"数据库服务器端口","required":true,"encrypted":false},
           "username":  {"name":"用户名","type":"string","description":"数据库用户名","required":true,"encrypted":false},
           "password":  {"name":"密码","type":"string","description":"数据库密码","required":true,"encrypted":true},
           "databases": {"name":"数据库列表","type":"array","description":"数据库名称列表（可选，为空则连接实例级别）","required":false,"encrypted":false},
           "options":   {"name":"连接参数","type":"object","description":"连接参数（如 charset, timeout 等）","required":false,"encrypted":false}
       }',
       TRUE
FROM DUAL WHERE NOT EXISTS ( SELECT f_type FROM t_connector_type WHERE f_type = 'mysql' );

INSERT INTO t_connector_type (f_type, f_name, f_description, f_mode, f_category, f_field_config, f_enabled)
SELECT 'opensearch', 'opensearch', 'OpenSearch 搜索引擎连接器', 'local', 'index',
    '{
        "host":          {"name":"主机地址","type":"string","description":"OpenSearch 服务器主机地址","required":true,"encrypted":false},
        "port":          {"name":"端口号","type":"integer","description":"OpenSearch 服务器端口","required":true,"encrypted":false},
        "username":      {"name":"用户名","type":"string","description":"认证用户名","required":false,"encrypted":false},
        "password":      {"name":"密码","type":"string","description":"认证密码","required":false,"encrypted":true},
        "index_pattern": {"name":"索引模式","type":"string","description":"索引匹配模式（可选，如 log-*）","required":false,"encrypted":false}
    }',
    TRUE
FROM DUAL WHERE NOT EXISTS ( SELECT f_type FROM t_connector_type WHERE f_type = 'opensearch' );

INSERT INTO t_connector_type (f_type, f_name, f_description, f_mode, f_category, f_field_config, f_enabled)
SELECT 'postgresql', 'postgresql', 'PostgreSQL 关系型数据库连接器', 'local', 'table',
       '{
           "host":      {"name":"主机地址","type":"string","description":"数据库服务器主机地址","required":true,"encrypted":false},
           "port":      {"name":"端口号","type":"integer","description":"数据库服务器端口","required":true,"encrypted":false},
           "username":  {"name":"用户名","type":"string","description":"数据库用户名","required":true,"encrypted":false},
           "password":  {"name":"密码","type":"string","description":"数据库密码","required":true,"encrypted":true},
           "database":  {"name":"数据库名","type":"string","description":"PostgreSQL 连接目标 database","required":true,"encrypted":false},
           "schemas":   {"name":"Schema 列表","type":"array","description":"可选；为空则扫描当前库下除系统 schema 外的用户 schema；非空则仅扫描列出的 schema","required":false,"encrypted":false},
           "options":   {"name":"连接参数","type":"object","description":"连接参数（如 sslmode、connect_timeout 等）","required":false,"encrypted":false}
       }',
       TRUE
FROM DUAL WHERE NOT EXISTS ( SELECT f_type FROM t_connector_type WHERE f_type = 'postgresql' );

-- ==========================================
-- 7. t_discover_task 发现任务表
-- ==========================================
CREATE TABLE IF NOT EXISTS t_discover_task (
    -- 主键与关联信息
    f_id                      VARCHAR(40) NOT NULL DEFAULT '' COMMENT '任务唯一标识',
    f_catalog_id              VARCHAR(40) NOT NULL DEFAULT '' COMMENT '所属catalog ID',
    f_trigger_type            VARCHAR(20) NOT NULL DEFAULT 'manual' COMMENT '触发类型: manual(立即执行), scheduled(定时驱动)',

    -- 任务状态
    f_status                  VARCHAR(20) NOT NULL DEFAULT 'pending' COMMENT '任务状态: pending, running, completed, failed',
    f_progress                INT NOT NULL DEFAULT 0 COMMENT '任务进度: 0-100',
    f_message                 VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '任务消息/错误信息',

    -- 时间信息
    f_start_time              BIGINT(20) NOT NULL DEFAULT 0 COMMENT '开始执行时间',
    f_finish_time             BIGINT(20) NOT NULL DEFAULT 0 COMMENT '完成时间',

    -- 执行结果
    f_result                  MEDIUMTEXT NOT NULL COMMENT '发现结果（JSON格式，包含发现的资源统计等）',

    -- 审计字段
    f_creator                 VARCHAR(128) NOT NULL DEFAULT '' COMMENT '创建者id',
    f_creator_type            VARCHAR(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
    f_create_time             BIGINT(20) NOT NULL DEFAULT 0 COMMENT '创建时间',

    -- 索引
    PRIMARY KEY (f_id),
    INDEX idx_catalog_id (f_catalog_id),
    INDEX idx_status (f_status)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT='发现任务表，记录异步资源发现任务的状态和结果';

-- ==========================================
-- 8. t_build_task 构建任务表
-- ==========================================
CREATE TABLE IF NOT EXISTS t_build_task (
    -- 主键与关联信息
    f_id                      VARCHAR(40) NOT NULL COMMENT '任务ID',
    f_resource_id             VARCHAR(40) NOT NULL COMMENT '资源ID',

    -- 任务状态
    f_status                  VARCHAR(20) NOT NULL COMMENT '任务状态: pending, running, completed, failed',
    f_mode                    VARCHAR(20) NOT NULL COMMENT '任务模式: full, incremental, realtime',
    f_total_count             BIGINT NOT NULL DEFAULT 0 COMMENT '总数',
    f_synced_count            BIGINT NOT NULL DEFAULT 0 COMMENT '已同步数',
    f_vectorized_count        BIGINT NOT NULL DEFAULT 0 COMMENT '已做向量数',
    f_synced_mark             VARCHAR(100) DEFAULT NULL COMMENT '同步标记',
    f_error_msg               TEXT DEFAULT NULL COMMENT '错误信息',

    -- 审计字段
    f_creator_id              VARCHAR(40) NOT NULL COMMENT '创建人ID',
    f_creator_type            VARCHAR(20) NOT NULL COMMENT '创建人类型',
    f_create_time             BIGINT NOT NULL COMMENT '创建时间',
    f_updater_id              VARCHAR(40) NOT NULL COMMENT '更新人ID',
    f_updater_type            VARCHAR(20) NOT NULL COMMENT '更新人类型',
    f_update_time             BIGINT NOT NULL COMMENT '更新时间',

    -- 索引
    PRIMARY KEY (f_id),
    INDEX idx_resource_id (f_resource_id),
    INDEX idx_status (f_status),
    INDEX idx_create_time (f_create_time)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT='构建任务表';

-- Source: vega/data-connection/migrations/mariadb/0.2.0/init.sql
-- Copyright The kweaver.ai Authors.
--
-- Licensed under the Apache License, Version 2.0.
-- See the LICENSE file in the project root for details.

USE adp;

CREATE TABLE IF NOT EXISTS `data_source` (
    `id` char(36) NOT NULL COMMENT '主键，生成规则:36位uuid',
    `name` varchar(128) NOT NULL COMMENT '数据源展示名称',
    `type_name` varchar(30) NOT NULL COMMENT '数据库类型',
    `bin_data` blob NOT NULL COMMENT '数据源配置信息',
    `comment` varchar(255) DEFAULT NULL COMMENT '描述',
    `created_by_uid` char(36) NOT NULL COMMENT '创建人',
    `created_at` datetime(3) NOT NULL COMMENT '创建时间',
    `updated_by_uid` char(36) DEFAULT NULL COMMENT '修改人',
    `updated_at` datetime(3) DEFAULT NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
    );

CREATE TABLE IF NOT EXISTS `t_data_source_info` (
      `f_id` varchar(36) NOT NULL COMMENT '主键，生成规则:36位uuid',
      `f_name` varchar(128) NOT NULL COMMENT '数据源展示名称',
      `f_type` varchar(30) NOT NULL COMMENT '数据库类型',
      `f_catalog` varchar(50) COMMENT '数据源catalog名称',
      `f_database` varchar(100) COMMENT '数据库名称',
      `f_schema` varchar(100) COMMENT '数据库模式',
      `f_connect_protocol` varchar(30) NOT NULL COMMENT '连接方式',
      `f_host` varchar(128) NOT NULL COMMENT '地址',
      `f_port` int NOT NULL COMMENT '端口',
      `f_account` varchar(128) COMMENT '账户',
      `f_password` varchar(1024) COMMENT '密码',
      `f_storage_protocol` varchar(30) COMMENT '存储介质',
      `f_storage_base` varchar(1024) COMMENT '存储路径',
      `f_token` varchar(100) COMMENT 'token认证',
      `f_replica_set` varchar(100) COMMENT '副本集名称',
      `f_is_built_in` tinyint NOT NULL DEFAULT '0' COMMENT '是否为内置数据源（0 特殊 1 非内置 2 内置），默认为0',
      `f_comment` varchar(255) COMMENT '描述',
      `f_created_by_uid` varchar(36) COMMENT '创建人',
      `f_created_at` datetime(3) COMMENT '创建时间',
      `f_updated_by_uid` varchar(36) COMMENT '修改人',
      `f_updated_at` datetime(3) COMMENT '更新时间',
      PRIMARY KEY (`f_id`)
);

INSERT INTO `t_data_source_info` (`f_id`,`f_name`,`f_type`,`f_connect_protocol`,`f_host`,`f_port`,`f_is_built_in`,`f_created_at`,`f_updated_at`)
SELECT 'cedb5294-07c3-45b1-a273-17baefa62800','索引库','index_base','http','mdl-index-base-svc',13013,2,current_timestamp(),current_timestamp()
FROM DUAL WHERE NOT EXISTS( SELECT `f_id` FROM `t_data_source_info` WHERE `f_id` = 'cedb5294-07c3-45b1-a273-17baefa62800' AND `f_type` = 'index_base');

CREATE TABLE IF NOT EXISTS `t_task_scan` (
  `id` char(36) NOT NULL COMMENT '唯一id，雪花算法',
  `type` tinyint NOT NULL DEFAULT 0 COMMENT '扫描任务：0 :即时-数据源;1 :即时-数据表;2: 定时-数据源;3: 定时-数据表',
  `name` varchar(128) NOT NULL COMMENT '任务名称',
  `ds_id` char(36) DEFAULT NULL COMMENT '数据源唯一标识',
  `scan_status` tinyint DEFAULT NULL COMMENT '任务状态',
  `start_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '任务开始时间',
  `end_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '任务结束时间',
  `create_user` varchar(100) NOT NULL DEFAULT '' COMMENT '创建用户（ID），默认空字符串',
  `task_params_info` text DEFAULT NULL COMMENT '任务执行参数信息',
  `task_process_info` text DEFAULT NULL COMMENT '任务执行进度信息',
  `task_result_info` text DEFAULT NULL COMMENT '任务执行结果信息',
  `schedule_id` char(36) DEFAULT NULL COMMENT '定时任务配置id',
  PRIMARY KEY (`id`),
  KEY `t_task_scan_ds_id_IDX` (`ds_id`)
);

CREATE TABLE IF NOT EXISTS `t_task_scan_table` (
  `id` char(36) NOT NULL COMMENT '唯一id，雪花算法',
  `task_id` char(36) NOT NULL COMMENT '关联任务id',
  `ds_id` char(36) NOT NULL COMMENT '数据源唯一标识',
  `ds_name` varchar(128) NOT NULL COMMENT '数据源名称',
  `table_id` char(36) NOT NULL COMMENT 'table的唯一id',
  `table_name` varchar(128) NOT NULL COMMENT 'table的name',
  `schema_name` varchar(128) NOT NULL COMMENT 'schema的name',
  `scan_status` tinyint DEFAULT NULL COMMENT '任务状态：0 等待;1 进行中;2 成功;3 失败',
  `start_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '任务开始时间',
  `end_time` datetime  DEFAULT NULL COMMENT '任务结束时间',
  `create_user` varchar(100) NOT NULL DEFAULT '' COMMENT '创建用户（ID），默认空字符串',
  `scan_params` text DEFAULT NULL COMMENT '任务执行参数信息',
  `scan_result_info` text DEFAULT NULL COMMENT '任务执行结果：',
  `error_stack` text DEFAULT NULL COMMENT '异常堆栈信息',
  `operation_type` tinyint DEFAULT NULL COMMENT '操作类型:0:insert 1:delete 2:update 3:unknown',
  PRIMARY KEY (`id`),
  KEY `t_task_scan_table_task_id_IDX` (`task_id`),
  KEY `t_task_scan_table_table_id_IDX` (`table_id`)
);

CREATE TABLE IF NOT EXISTS `t_table_scan` (
  `f_id` char(36) NOT NULL COMMENT '唯一id，雪花算法',
  `f_name` varchar(128) NOT NULL COMMENT '表名称',
  `f_advanced_params` text DEFAULT NULL COMMENT '高级参数，格式为"{key(1): value(1), ... , key(n): value(n)}"',
  `f_description` varchar(2048) DEFAULT NULL COMMENT '表注释',
  `f_table_rows` bigint NOT NULL DEFAULT 0 COMMENT '表数据量，默认0',
  `f_data_source_id` char(36) NOT NULL COMMENT '数据源唯一标识',
  `f_data_source_name` varchar(128) NOT NULL COMMENT '冗余字段，数据源名称',
  `f_schema_name` varchar(128) NOT NULL COMMENT '冗余字段，schema名称',
  `f_task_id` char(36) NOT NULL COMMENT '关联任务id',
  `f_version` int NOT NULL DEFAULT 1 COMMENT '版本号',
  `f_create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
  `f_create_user` varchar(100) NOT NULL DEFAULT '' COMMENT '创建用户（ID），默认空字符串',
  `f_operation_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '修改时间，默认当前时间',
  `f_operation_user` varchar(100) NOT NULL DEFAULT '' COMMENT '修改用户（ID），默认空字符串',
  `f_operation_type` tinyint NOT NULL DEFAULT 0 COMMENT '状态：0新增1删除2更新',
  `f_status` tinyint NOT NULL DEFAULT 3 COMMENT '任务状态：0 等待;1 进行中;2 成功;3 失败',
  `f_status_change` tinyint NOT NULL DEFAULT 0 COMMENT '状态是否发生变化：0 否1 是',
  `f_scan_source` tinyint(4) DEFAULT NULL COMMENT '扫描来源',
  PRIMARY KEY (`f_id`),
  KEY `t_table_scan_f_data_source_id_IDX` (`f_task_id`)
);

CREATE TABLE IF NOT EXISTS `t_table_field_scan` (
  `f_id` char(36) NOT NULL COMMENT '唯一id，雪花算法',
  `f_field_name` varchar(128) NOT NULL COMMENT '字段名',
  `f_table_id` char(36) NOT NULL COMMENT 'Table唯一标识',
  `f_table_name` varchar(128) NOT NULL COMMENT '表名',
  `f_field_type` varchar(128) DEFAULT NULL COMMENT '字段类型',
  `f_field_length` int DEFAULT NULL COMMENT '字段长度',
  `f_field_precision` int DEFAULT NULL COMMENT '字段精度',
  `f_field_comment` varchar(2048) DEFAULT NULL COMMENT '字段注释',
  `f_field_order_no` int DEFAULT NULL,
  `f_advanced_params` varchar(2048) DEFAULT NULL COMMENT '字段高级参数',
  `f_version` int NOT NULL DEFAULT 1 COMMENT '版本号',
  `f_create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
  `f_create_user` varchar(100) NOT NULL DEFAULT '' COMMENT '创建用户（ID），默认空字符串',
  `f_operation_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '修改时间，默认当前时间',
  `f_operation_user` varchar(100) NOT NULL DEFAULT '' COMMENT '修改用户（ID），默认空字符串',
  `f_operation_type` tinyint NOT NULL DEFAULT 0 COMMENT '状态：0新增1删除2更新',
  `f_status_change` tinyint NOT NULL DEFAULT 0 COMMENT '状态是否发生变化：0 否1 是',
  PRIMARY KEY (`f_id`),
  KEY `t_table_field_scan_f_table_id_IDX` (`f_table_id`)
);

CREATE TABLE IF NOT EXISTS `t_task_scan_schedule` (
  `id` char(36) NOT NULL COMMENT '唯一id，雪花算法',
  `type` tinyint NOT NULL DEFAULT 0 COMMENT '扫描任务：0 :即时-数据源;1 :即时-数据表;2: 定时-数据源',
  `name` varchar(128) NOT NULL COMMENT '任务名称',
  `cron_expression` varchar(64) NOT NULL COMMENT 'cron表达式',
  `scan_strategy` varchar(64) DEFAULT NULL COMMENT '快速扫描策略',
  `task_status` tinyint DEFAULT 0 COMMENT '定时扫描任务:0 close 1 open',
  `ds_id` char(36) DEFAULT NULL COMMENT '数据源唯一标识',
  `create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
  `create_user` varchar(64) DEFAULT NULL COMMENT '创建用户',
  `operation_time` datetime DEFAULT NULL,
  `operation_user` varchar(64) DEFAULT NULL,
  `operation_type` tinyint NOT NULL DEFAULT 0 COMMENT '状态：0新增1删除2更新',
PRIMARY KEY (`id`),
KEY `t_task_scan_ds_id_IDX` (`ds_id`)
);


-- metadata tables


CREATE TABLE IF NOT EXISTS `t_data_quality_model` (
                                                      `f_id` bigint NOT NULL COMMENT '主键id，唯一标识',
                                                      `f_ds_id` bigint NOT NULL COMMENT '数据源ID',
                                                      `f_dolphinscheduler_ds_id` bigint NOT NULL COMMENT 'dolphinscheduler数据源ID',
                                                      `f_db_type` varchar(50) NOT NULL COMMENT '数据库类型',
    `f_tb_name` varchar(512) NOT NULL COMMENT '表名称',
    `f_process_definition_code` bigint NOT NULL COMMENT '工作流定义ID',
    `f_crontab` varchar(128) DEFAULT NULL COMMENT '定时任务表达式',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_data_quality_rule` (
                                                     `f_id` bigint NOT NULL COMMENT '主键id，唯一标识',
                                                     `f_field_name` varchar(512) NOT NULL COMMENT '字段名称',
    `f_rule_id` tinyint NOT NULL COMMENT '质量规则ID：1-空值检测，，2-自定义SQL，5-字段长度校验，6-唯一性校验，7-正则表达式，9-枚举值校验，10-表行数校验',
    `f_threshold` double DEFAULT NULL COMMENT '阈值，默认0',
    `f_check_val` varchar(10240) DEFAULT NULL COMMENT '1、自定义sql：填写sql语句；2、字段长度校验：填写字段长度；3、正则表达式：填写正则表达式；4、枚举值校验：填写枚举值，逗号分割；5、表行数校验：填写表行数。',
    `f_check_val_name` varchar(128) DEFAULT NULL COMMENT '自定义sql时，填写的实际值名',
    `f_model_id` bigint NOT NULL COMMENT '质量模型ID',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_data_source` (
    `f_id` char(36) NOT NULL COMMENT '唯一id，雪花算法',
    `f_name` varchar(128) NOT NULL COMMENT '数据源名称',
    `f_data_source_type` tinyint NOT NULL COMMENT '类型，关联字典表f_dict_type为1时的f_dict_key',
    `f_data_source_type_name` varchar(256) NOT NULL COMMENT '类型名称，对应字典表f_dict_type为1时的f_dict_value',
    `f_user_name` varchar(128) NOT NULL COMMENT '用户名',
    `f_password` varchar(1024) NOT NULL COMMENT '密码',
    `f_description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述',
    `f_extend_property` varchar(255) NOT NULL DEFAULT '' COMMENT '扩展属性，默认为空字符串',
    `f_host` varchar(128) NOT NULL COMMENT 'HOST',
    `f_port` int NOT NULL COMMENT '端口',
    `f_enable_status` tinyint NOT NULL DEFAULT 1 COMMENT '禁用/启用状态，1 启用，2 停用，默认为启用',
    `f_connect_status` tinyint NOT NULL DEFAULT 1 COMMENT '连接状态，1 成功，2 失败，默认为成功',
    `f_authority_id` bigint NOT NULL DEFAULT 0 COMMENT '权限域（目前为预留字段），默认0',
    `f_create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
    `f_create_user` varchar(100) NOT NULL DEFAULT '' COMMENT '创建用户（ID），默认空字符串',
    `f_update_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '修改时间，默认当前时间',
    `f_update_user` varchar(100) NOT NULL DEFAULT '' COMMENT '修改用户（ID），默认空字符串',
    `f_database` varchar(100) DEFAULT NULL COMMENT '数据库名称',
    `f_info_system_id` varchar(128) DEFAULT NULL COMMENT '信息系统id',
    `f_dolphin_id` bigint DEFAULT NULL COMMENT 'dolphin数据元id',
    `f_delete_code` bigint DEFAULT 0 COMMENT '逻辑删除标识码',
    `f_live_update_status` tinyint NOT NULL DEFAULT 0 COMMENT '实时更新标识（0无需更新，1待更新，2更新中，3连接不可用，4无权限，5待广播',
    `f_live_update_benchmark` varchar(255) DEFAULT NULL COMMENT '实时更新基准',
    `f_live_update_time` datetime DEFAULT current_timestamp() COMMENT '实时更新时间',
    PRIMARY KEY (`f_id`),
    UNIQUE KEY `t_data_source_un` (`f_name`,`f_create_user`,`f_info_system_id`,`f_delete_code`)
    );


CREATE TABLE IF NOT EXISTS `t_dict` (
                                        `f_id` int NOT NULL AUTO_INCREMENT COMMENT '唯一id，自增ID',
                                        `f_dict_type` tinyint NOT NULL COMMENT '字典类型\n1：数据源类型\n2：Oracle字段类型\n3：MySQL字段类型\n4：PostgreSQL字段类型\n5：SqlServer字段类型\n6：Hive字段类型\n7：HBase字段类型\n8：MongoDB字段类型\n9：FTP字段类型\n10：HDFS字段类型\n11：SFTP字段类型\n12：CMQ字段类型\n13：Kafka字段类型\n14：API字段类型',
                                        `f_dict_key` tinyint NOT NULL COMMENT '枚举值',
                                        `f_dict_value` varchar(256) NOT NULL COMMENT '枚举对应描述',
    `f_extend_property` varchar(1024) NOT NULL COMMENT '扩展属性',
    `f_enable_status` tinyint NOT NULL DEFAULT 2 COMMENT '启用状态，1 启用，2 停用，默认为停用',
    PRIMARY KEY (`f_id`),
    UNIQUE KEY `t_dict_un` (`f_dict_type`,`f_dict_key`)
    );


CREATE TABLE IF NOT EXISTS `t_indicator` (
                                             `f_id` bigint NOT NULL COMMENT '唯一id，雪花算法',
                                             `f_indicator_name` varchar(128) NOT NULL COMMENT '指标名称',
    `f_indicator_type` varchar(128) NOT NULL COMMENT '指标类型',
    `f_indicator_value` bigint NOT NULL COMMENT '指标数值',
    `f_create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
    `f_indicator_object_id` bigint DEFAULT NULL COMMENT '关联对象ID',
    `f_authority_id` bigint NOT NULL DEFAULT 0 COMMENT '权限域（目前为预留字段），默认0',
    `f_advanced_params` varchar(255) NOT NULL DEFAULT '[]' COMMENT '指标高级参数',
    PRIMARY KEY (`f_id`,`f_create_time`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_edge_column` (
    `f_id` varchar(64) NOT NULL COMMENT '主键ID，根据f_table_id和f_column_id值MD5计算得到',
    `f_parent_id` varchar(64) NOT NULL COMMENT '源字段ID',
    `f_child_id` varchar(64) NOT NULL COMMENT '目标字段ID',
    `f_create_type` varchar(20) DEFAULT NULL COMMENT '创建类型： HIVE/DATAX/SPARK/USER_REPORT',
    `f_query_text` text DEFAULT NULL COMMENT '生成血缘的sql或者脚本说明',
    `created_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `deleted_at` bigint DEFAULT 0 COMMENT '删除时间（逻辑删除）',
    `f_create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间，时间戳',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_edge_column_table_relation` (
    `f_id` varchar(64) NOT NULL COMMENT '主键ID，根据f_table_id和f_column_id值MD5计算得到',
    `f_table_id` varchar(64) NOT NULL COMMENT '表ID',
    `f_column_id` varchar(64) NOT NULL COMMENT '字段ID',
    `created_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `deleted_at` bigint DEFAULT 0 COMMENT '删除时间（逻辑删除）',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_edge_table` (
    `f_id` varchar(64) NOT NULL COMMENT '主键ID，根据f_table_id和f_column_id值MD5计算得到',
    `f_parent_id` varchar(64) NOT NULL COMMENT '源ID',
    `f_child_id` varchar(64) NOT NULL COMMENT '目标ID',
    `f_create_type` varchar(20) DEFAULT NULL COMMENT '创建类型： HIVE/DATAX/SPARK/USER_REPORT',
    `f_query_text` text DEFAULT NULL COMMENT '生成血缘的sql或者脚本说明',
    `created_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `deleted_at` bigint DEFAULT 0 COMMENT '删除时间（逻辑删除）',
    `f_create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间，时间戳',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_graph_info` (
    `app_id` char(20) NOT NULL COMMENT '图谱appId',
    `graph_id` bigint DEFAULT NULL COMMENT '图谱graphId',
    PRIMARY KEY (`app_id`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_log` (
    `id` char(36) NOT NULL DEFAULT (uuid()),
    `class_id` char(36) NOT NULL COMMENT '实体的主键id',
    `class_type` char(36) NOT NULL COMMENT '实体类型',
    `action_type` char(10) NOT NULL COMMENT '操作类型：insert update delete',
    `class_data` text NOT NULL COMMENT '血缘实体json',
    `created_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    PRIMARY KEY (`id`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_relation` (
    `unique_id` varchar(255) NOT NULL COMMENT '实体ID',
    `class_type` tinyint DEFAULT NULL COMMENT '类型，1:column,2:indicator',
    `parent` text DEFAULT NULL COMMENT '上一个节点',
    `child` text DEFAULT NULL COMMENT '下一个节点',
    `created_at` datetime(3) DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) DEFAULT current_timestamp(3) COMMENT '更新时间',
    PRIMARY KEY (`unique_id`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_tag_column` (
    `f_id` varchar(64) NOT NULL COMMENT '主键ID，根据f_table_id和f_column值MD5计算得到',
    `f_table_id` varchar(64) NOT NULL COMMENT 't_lineage_tag_table表ID',
    `f_column` varchar(255) NOT NULL COMMENT '字段名称',
    `created_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `deleted_at` bigint DEFAULT 0 COMMENT '删除时间（逻辑删除）',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_tag_table` (
    `f_id` varchar(64) NOT NULL COMMENT '主键ID，根据f_db_type、f_ds_id、f_jdbc_url、f_jdbc_user、f_db_name、f_db_schema、f_tb_name值MD5计算得到',
    `f_db_type` varchar(64) NOT NULL COMMENT '数据库类型',
    `f_ds_id` varchar(64) DEFAULT NULL COMMENT '数据源ID',
    `f_jdbc_url` varchar(255) DEFAULT NULL COMMENT '数据库连接URL',
    `f_jdbc_user` varchar(255) DEFAULT NULL COMMENT '数据库JDBC 用户名',
    `f_db_name` varchar(255) DEFAULT NULL COMMENT '数据库名称',
    `f_db_schema` varchar(255) DEFAULT NULL COMMENT '模式名称',
    `f_tb_name` varchar(255) NOT NULL COMMENT '表名称',
    `created_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `deleted_at` bigint DEFAULT 0 COMMENT '删除时间（逻辑删除）',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_indicator2` (
                                              `f_id` bigint NOT NULL COMMENT '唯一id，雪花算法',
                                              `f_indicator_name` varchar(128) NOT NULL COMMENT '指标名称',
    `f_indicator_type` varchar(128) NOT NULL COMMENT '指标类型',
    `f_indicator_value` bigint NOT NULL COMMENT '指标数值',
    `f_create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
    `f_indicator_object_id` bigint DEFAULT NULL COMMENT '关联对象ID',
    `f_authority_id` bigint NOT NULL DEFAULT 0 COMMENT '权限域（目前为预留字段），默认0',
    `f_advanced_params` varchar(255) NOT NULL DEFAULT '[]' COMMENT '指标高级参数',
    PRIMARY KEY (`f_id`,`f_create_time`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_tag_column2` (
    `unique_id` varchar(255) NOT NULL COMMENT '列的唯一id',
    `uuid` char(36) DEFAULT NULL COMMENT '字段的uuid',
    `technical_name` varchar(255) DEFAULT NULL COMMENT '列技术名称',
    `business_name` varchar(255) DEFAULT NULL COMMENT '列业务名称',
    `comment` varchar(300) DEFAULT NULL COMMENT '字段注释',
    `data_type` varchar(255) DEFAULT NULL COMMENT '字段的数据类型',
    `primary_key` tinyint DEFAULT NULL COMMENT '是否主键',
    `table_unique_id` char(36) DEFAULT NULL COMMENT '属于血缘表的uuid',
    `expression_name` text DEFAULT NULL COMMENT 'column的生成表达式',
    `column_unique_ids` varchar(1024) DEFAULT '' COMMENT 'column的生成依赖的column的uid',
    `action_type` varchar(10) DEFAULT NULL COMMENT '操作类型:insertupdatedelete',
    `created_at` datetime(3) DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) DEFAULT current_timestamp(3) COMMENT '更新时间',
    PRIMARY KEY (`unique_id`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_tag_indicator2` (
    `uuid` char(36) NOT NULL COMMENT '指标的uuid',
    `name` varchar(128) NOT NULL COMMENT '指标名称',
    `description` varchar(300) DEFAULT NULL COMMENT '指标名称描述',
    `code` varchar(128) NOT NULL COMMENT '指标编号',
    `indicator_type` varchar(10) NOT NULL COMMENT '指标类型:atomic原子derived衍生composite复合',
    `expression` text DEFAULT NULL COMMENT '指标表达式，如果指标是原子或复合指标时',
    `indicator_uuids` varchar(1024) DEFAULT '' COMMENT '引用的指标uuid',
    `time_restrict` text DEFAULT NULL COMMENT '时间限定表达式，如果指标是衍生指标时',
    `modifier_restrict` text DEFAULT NULL COMMENT '普通限定表达式，如果指标是衍生指标时',
    `owner_uid` varchar(50) DEFAULT NULL COMMENT '数据ownerID',
    `owner_name` varchar(128) DEFAULT NULL COMMENT '数据owner名称',
    `department_id` char(36) DEFAULT NULL COMMENT '所属部门id',
    `department_name` varchar(128) DEFAULT NULL COMMENT '所属部门名称',
    `column_unique_ids` varchar(1024) DEFAULT '' COMMENT '依赖的字段的unique_id',
    `action_type` varchar(10) NOT NULL COMMENT '操作类型:insertupdatedelete',
    `created_at` datetime(3) DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) DEFAULT current_timestamp(3) COMMENT '更新时间',
    PRIMARY KEY (`uuid`)
    );


CREATE TABLE IF NOT EXISTS `t_lineage_tag_table2` (
    `unique_id` varchar(255) NOT NULL COMMENT '唯一id',
    `uuid` char(36) NOT NULL COMMENT '表的uuid',
    `technical_name` varchar(255) NOT NULL COMMENT '表技术名称',
    `business_name` varchar(255) DEFAULT NULL COMMENT '表业务名称',
    `comment` varchar(300) DEFAULT NULL COMMENT '表注释',
    `table_type` varchar(36) NOT NULL COMMENT '表类型',
    `datasource_id` char(36) DEFAULT NULL COMMENT '数据源id',
    `datasource_name` varchar(255) DEFAULT NULL COMMENT '数据源名称',
    `owner_id` char(36) DEFAULT NULL COMMENT '数据Ownerid',
    `owner_name` varchar(128) DEFAULT NULL COMMENT '数据OwnerName',
    `department_id` char(36) DEFAULT NULL COMMENT '所属部门id',
    `department_name` varchar(128) DEFAULT NULL COMMENT '所属部门mame',
    `info_system_id` char(36) DEFAULT NULL COMMENT '信息系统id',
    `info_system_name` varchar(128) DEFAULT NULL COMMENT '信息系统名称',
    `database_name` varchar(128) NOT NULL COMMENT '数据库名称',
    `catalog_name` varchar(255) NOT NULL DEFAULT '' COMMENT '数据源catalog名称',
    `catalog_addr` varchar(1024) NOT NULL DEFAULT '' COMMENT '数据源地址',
    `catalog_type` varchar(128) NOT NULL COMMENT '数据库类型名称',
    `task_execution_info` varchar(128) DEFAULT NULL COMMENT '表加工任务的相关名称',
    `action_type` varchar(10) NOT NULL COMMENT '操作类型:insertupdatedelete',
    `created_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '创建时间',
    `updated_at` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '更新时间',
    PRIMARY KEY (`unique_id`)
    );


CREATE TABLE IF NOT EXISTS `t_live_ddl` (
                                            `f_id` bigint NOT NULL AUTO_INCREMENT COMMENT '唯一标识',
                                            `f_data_source_id` bigint NOT NULL DEFAULT 0 COMMENT '数据源ID',
                                            `f_data_source_name` varchar(255) NOT NULL DEFAULT '' COMMENT '数据源名称',
    `f_origin_catalog` varchar(255) DEFAULT NULL COMMENT '物理catalog',
    `f_virtual_catalog` varchar(255) DEFAULT NULL COMMENT '虚拟化catalog',
    `f_schema_id` bigint DEFAULT NULL COMMENT 'schemaID',
    `f_schema_name` varchar(255) DEFAULT NULL COMMENT 'schema名称',
    `f_table_id` bigint DEFAULT NULL COMMENT 'tableID',
    `f_table_name` varchar(255) DEFAULT NULL COMMENT 'table名称',
    `f_sql_type` varchar(100) DEFAULT NULL COMMENT 'sql类型(AlterTable,AlterColumn,CreateTable,CommentTable,CommentColumn,DropTable,RenameTable)',
    `f_sql_text` text NOT NULL COMMENT 'sql文本',
    `f_live_update_benchmark` varchar(255) NOT NULL DEFAULT '' COMMENT '实时更新基准',
    `f_monitor_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '监听时间，默认当前时间',
    `f_update_status` tinyint DEFAULT NULL COMMENT '更新状态（0全量更新，1增量更新，2忽略更新，3待更新，4解析失败，5更新失败）',
    `f_update_message` varchar(2000) DEFAULT NULL COMMENT '更新信息',
    `f_push_status` tinyint DEFAULT NULL COMMENT '0不推送,1待推送,2已推送',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_schema` (
                                          `f_id` bigint NOT NULL COMMENT '唯一id，雪花算法',
                                          `f_name` varchar(128) NOT NULL COMMENT 'schema名称',
    `f_data_source_id` char(36) NOT NULL COMMENT '数据源唯一标识',
    `f_data_source_name` varchar(128) NOT NULL COMMENT '冗余字段，数据源名称',
    `f_data_source_type` tinyint NOT NULL COMMENT '冗余字段，数据源类型，关联字典表f_dict_type为1时的f_dict_key',
    `f_data_source_type_name` varchar(256) NOT NULL COMMENT '冗余字段，数据源类型名称，对应字典表f_dict_type为1时的f_dict_value',
    `f_authority_id` bigint NOT NULL DEFAULT 0 COMMENT '权限域（目前为预留字段），默认0',
    `f_create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
    `f_create_user` varchar(100) NOT NULL DEFAULT '' COMMENT '创建用户（ID），默认空字符串',
    `f_update_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '修改时间，默认当前时间',
    `f_update_user` varchar(100) NOT NULL DEFAULT '' COMMENT '修改用户（ID），默认空字符串',
    PRIMARY KEY (`f_id`),
    UNIQUE KEY `t_schema_un` (`f_data_source_id`,`f_name`)
    );


CREATE TABLE IF NOT EXISTS `t_table` (
                                         `f_id` bigint NOT NULL COMMENT '唯一id，雪花算法',
                                         `f_name` varchar(128) NOT NULL COMMENT '表名称',
    `f_advanced_params` text NOT NULL COMMENT '高级参数，默认为"{}"，格式为"{key(1): value(1), ... , key(n): value(n)}"',
    `f_description` varchar(2048) DEFAULT NULL COMMENT '表注释',
    `f_table_rows` bigint NOT NULL DEFAULT 0 COMMENT '表数据量，默认0',
    `f_schema_id` bigint NOT NULL COMMENT 'schema唯一标识',
    `f_schema_name` varchar(128) NOT NULL COMMENT '冗余字段，schema名称',
    `f_data_source_id` char(36) NOT NULL COMMENT '数据源唯一标识',
    `f_data_source_name` varchar(128) NOT NULL COMMENT '冗余字段，数据源名称',
    `f_data_source_type` tinyint NOT NULL COMMENT '冗余字段，数据源类型，关联字典表f_dict_type为1时的f_dict_key',
    `f_data_source_type_name` varchar(256) NOT NULL COMMENT '冗余字段，数据源类型名称，对应字典表f_dict_type为1时的f_dict_value',
    `f_version` int NOT NULL DEFAULT 1 COMMENT '版本号',
    `f_authority_id` varchar(100) NOT NULL DEFAULT '' COMMENT '权限域（目前为预留字段），默认0',
    `f_create_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
    `f_create_user` varchar(100) NOT NULL DEFAULT '' COMMENT '创建用户（ID），默认空字符串',
    `f_update_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '修改时间，默认当前时间',
    `f_update_user` varchar(100) NOT NULL DEFAULT '' COMMENT '修改用户（ID），默认空字符串',
    `f_delete_flag` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除标识',
    `f_delete_time` datetime DEFAULT NULL COMMENT '逻辑删除时间',
    `f_scan_source` tinyint DEFAULT NULL COMMENT '扫描来源',
    PRIMARY KEY (`f_id`),
    UNIQUE KEY `t_table_un` (`f_data_source_id`,`f_schema_id`,`f_name`)
    );


CREATE TABLE IF NOT EXISTS `t_table_field` (
                                               `f_table_id` bigint NOT NULL COMMENT 'Table唯一标识',
                                               `f_field_name` varchar(128) NOT NULL COMMENT '字段名',
    `f_field_type` varchar(128) DEFAULT NULL COMMENT '字段类型',
    `f_field_length` int DEFAULT NULL COMMENT '字段长度',
    `f_field_precision` int DEFAULT NULL COMMENT '字段精度',
    `f_field_comment` varchar(2048) DEFAULT NULL COMMENT '字段注释',
    `f_advanced_params` varchar(2048) NOT NULL DEFAULT '[]' COMMENT '字段高级参数',
    `f_update_flag` tinyint NOT NULL DEFAULT 0 COMMENT '更新标识',
    `f_update_time` datetime DEFAULT NULL COMMENT '更新时间',
    `f_delete_flag` tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除标识',
    `f_delete_time` datetime DEFAULT NULL COMMENT '逻辑删除时间',
    PRIMARY KEY (`f_table_id`,`f_field_name`)
    );


CREATE TABLE IF NOT EXISTS `t_table_field_his` (
                                                   `f_id` bigint NOT NULL COMMENT '唯一id，雪花算法',
                                                   `f_field_name` varchar(128) NOT NULL COMMENT '字段名',
    `f_field_type` varchar(128) DEFAULT NULL COMMENT '字段类型',
    `f_field_length` int DEFAULT NULL COMMENT '字段长度',
    `f_field_precision` int DEFAULT NULL COMMENT '字段精度',
    `f_field_comment` varchar(2048) DEFAULT NULL COMMENT '字段注释',
    `f_table_id` bigint NOT NULL COMMENT 'Table唯一标识',
    `f_version` int NOT NULL DEFAULT 1 COMMENT '版本号',
    `f_advanced_params` varchar(255) NOT NULL DEFAULT '[]' COMMENT '字段高级参数',
    PRIMARY KEY (`f_id`,`f_version`)
    );


CREATE TABLE IF NOT EXISTS `t_task` (
                                        `f_id` bigint NOT NULL COMMENT '唯一id，雪花算法',
                                        `f_object_id` char(36) DEFAULT NULL COMMENT '任务对象id',
    `f_object_type` tinyint DEFAULT NULL COMMENT '任务对象类型1数据源、2数据表',
    `f_name` varchar(255) DEFAULT NULL COMMENT '任务名称',
    `f_status` tinyint NOT NULL COMMENT '任务状态：0成功，1失败，2进行中',
    `f_start_time` datetime NOT NULL DEFAULT current_timestamp() COMMENT '任务开始时间',
    `f_end_time` datetime DEFAULT NULL COMMENT '任务结束时间',
    `f_create_user` varchar(100) NOT NULL DEFAULT '' COMMENT '创建用户',
    `f_authority_id` bigint NOT NULL DEFAULT 0 COMMENT '权限域（目前为预留字段），默认0',
    `f_advanced_params` varchar(255) NOT NULL DEFAULT '[]' COMMENT '任务高级参数',
    PRIMARY KEY (`f_id`)
    );


CREATE TABLE IF NOT EXISTS `t_task_log` (
                                            `f_id` bigint NOT NULL COMMENT '唯一id，雪花算法',
                                            `f_task_id` bigint DEFAULT NULL COMMENT '任务id',
                                            `f_log` text DEFAULT NULL COMMENT '任务日志文本',
                                            `f_authority_id` bigint NOT NULL DEFAULT 0 COMMENT '权限域（目前为预留字段），默认0',
                                            PRIMARY KEY (`f_id`)
    );




-- 添加虚拟化数据源类型
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,1,'Oracle','{"dbCatalogName": 关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,2,'MySQL','{"dbCatalogName": 关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,3,'PostgreSQL','{"dbCatalogName": 关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,4,'SqlServer','{"dbCatalogName": 关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,5,'Hive','{"dbCatalogName": 关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,6,'HBase','{"dbCatalogName": 非关系型数据库}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,7,'MongoDB','{"dbCatalogName": 非关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 7);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,9,'HDFS','{"dbCatalogName": 文件系统}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 9);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,10,'SFTP','{"dbCatalogName": 文件系统}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 10);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,11,'CMQ','{"dbCatalogName": 消息队列}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 11);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,12,'Kafka','{"dbCatalogName": 消息队列}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 12);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,13,'API','{"dbCatalogName": 其他}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 13);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,14,'CLICKHOUSE', '{"dbCatalogName": 非关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 14);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,15,'doris','{"dbCatalogName": 非关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 15);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,16,'mariadb','{"dbCatalogName": 关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 16);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,17,'dm','{"dbCatalogName": 关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 17);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 1,18,'maxcompute','{"dbCatalogName": 关系型数据库}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 1 AND f_dict_key = 18);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,1,'VARCHAR2','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,2,'NUMBER','{"jdbcType":2,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,3,'NVARCHAR2','{"jdbcType":-9,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,4,'DATE','{"jdbcType":91,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,5,'NCLOB','{"jdbcType":2011,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,6,'TIMESTAMP','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,7,'CLOB','{"jdbcType":2005,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 7);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,8,'TIMESTAMP(6)','{"jdbcType":10,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 8);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,9,'CHAR','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 9);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,10,'VARCHAR','{"jdbcType":11,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 10);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,11,'FLOAT','{"jdbcType":6,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 11);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,12,'BLOB','{"jdbcType":2004,"javaColumnType":"7","sparkColumnType":"8","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 12);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,13,'DECIMAL','{"jdbcType":3,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 13);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,14,'LONG','{"jdbcType":-1,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 14);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,15,'INT','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 15);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,16,'RAW','{"jdbcType":-3,"javaColumnType":"7","sparkColumnType":"8","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 16);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,17,'TIMESTAMP(4)','{"jdbcType":3,"javaColumnType":"8","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 17);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,18,'ROWID','{"jdbcType":-8,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 18);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,19,'AQ$_SUBSCRIBERS','{"jdbcType":2003,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 19);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,20,'LONG RAW','{"jdbcType":-4,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 20);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,21,'NCHAR','{"jdbcType":-15,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 21);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,1,'DOUBLE','{"jdbcType":8,"javaColumnType":"3","sparkColumnType":"4","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,2,'TINYINT','{"jdbcType":-6,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,3,'BOOLEAN','{"jdbcType":16,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,4,'INTEGER','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,5,'VARCHAR','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,6,'CHAR','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,7,'BLOB','{"jdbcType":-4,"javaColumnType":"7","sparkColumnType":"8","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 7);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,8,'SMALLINT','{"jdbcType":5,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 8);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,9,'MEDIUMINT','{"jdbcType":4,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 9);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,10,'BIT','{"jdbcType":-7,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 10);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,11,'FLOAT','{"jdbcType":7,"javaColumnType":"3","sparkColumnType":"4","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 11);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,12,'DECIMAL','{"jdbcType":3,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 12);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,13,'DATE','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 13);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,14,'TIME','{"jdbcType":92,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 14);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,15,'DATETIME','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 15);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,16,'TIMESTAMP','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 16);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,17,'YEAR','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 17);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,18,'INT','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 18);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,19,'BIGINT','{"jdbcType":-5,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 19);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,20,'LONGTEXT','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 20);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,21,'TEXT','{"jdbcType":-1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 21);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,22,'JSON','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 22);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,23,'MEDIUMTEXT','{"jdbcType":13,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 23);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,24,'SET','{"jdbcType":11,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 24);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,25,'MEDIUMBLOB','{"jdbcType":11,"javaColumnType":"7","sparkColumnType":"8","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 25);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,26,'LONGBLOB','{"jdbcType":11,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 26);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,27,'VARBINARY','{"jdbcType":-3,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 27);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,28,'BINARY','{"jdbcType":-2,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 28);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,29,'ENUM','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 29);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,30,'TINYTEXT','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 30);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,1,'int2','{"jdbcType":12,"javaColumnType":"3","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,2,'int4','{"jdbcType":12,"javaColumnType":"3","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,3,'int8','{"jdbcType":-5,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,4,'varchar','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,5,'date','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,6,'timestamp','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,7,'timestampwithouttimezone','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 7);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,8,'bigint','{"jdbcType":11,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 8);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,9,'decimal','{"jdbcType":3,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 9);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,10,'TEXT','{"jdbcType":5,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 10);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,11,'bigserial','{"jdbcType":11,"javaColumnType":"2","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 11);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,12,'timestampwithtimezone','{"jdbcType":99,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 12);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,13,'numeric','{"jdbcType":3,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 13);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,14,'float8','{"jdbcType":12,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 14);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,15,'float4','{"jdbcType":12,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 15);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,16,'bpchar','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 16);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,17,'serial','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 17);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,18,'json','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 18);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,19,'bytea','{"jdbcType":2004,"javaColumnType":"7","sparkColumnType":"8","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 19);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,20,'bool','{"jdbcType":16,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 20);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,21,'array','{"jdbcType":2003}',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 21);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,22,'numeric','{"jdbcType":2,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 22);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,1,'varchar','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,2,'int','{"jdbcType":4,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,3,'datetime','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,4,'smallint','{"jdbcType":5,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,5,'sysname','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,6,'date','{"jdbcType":93,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,7,'datetime2','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 7);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,8,'nvarchar','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 8);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,9,'intidentity','{"jdbcType":11,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 9);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,10,'decimal','{"jdbcType":11,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 10);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,11,'char','{"jdbcType":11,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 11);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,12,'bigint','{"jdbcType":3,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 12);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,13,'uniqueidentifier','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 13);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,14,'tinyint','{"jdbcType":4,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 14);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,15,'real','{"jdbcType":11,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 15);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,16,'nchar','{"jdbcType":11,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 16);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,1,'INT','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,2,'STRING','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,3,'BOOLEAN','{"jdbcType":16,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,4,'DECIMAL','{"jdbcType":3,"javaColumnType":"3","sparkColumnType":"3","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,5,'TIMESTAMP','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"string","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,6,'SMALLINT','{"jdbcType":5,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,7,'TINYINT','{"jdbcType":-6,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 7);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,8,'BINARY','{"jdbcType":-2,"javaColumnType":"7","sparkColumnType":"8","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 8);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,9,'VARCHAR','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 9);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,10,'CHAR','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 10);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,11,'DATE','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 11);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,12,'DOUBLE','{"jdbcType":8,"javaColumnType":"3","sparkColumnType":"4","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 12);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,13,'BIGINT','{"jdbcType":-5,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 13);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,14,'FLOAT','{"jdbcType":6,"javaColumnType":"3","sparkColumnType":"4","flinkColumnType":"4","dbCatalogName":"关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 14);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,1,'hbase-int','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,2,'hbase-string','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,3,'hbase-date','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,4,'hbase_long','{"jdbcType":-5,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,5,'hbase_bytes','{"jdbcType":-2,"javaColumnType":"7","sparkColumnType":"8","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,6,'hbase_boolean','{"jdbcType":16,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,7,'hbase_double','{"jdbcType":8,"javaColumnType":"3","sparkColumnType":"4","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 7);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,8,'hbase_timestamp','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 8);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,1,'DOUBLE','{"jdbcType":8,"javaColumnType":"3","sparkColumnType":"4","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,2,'STRING','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,3,'OBJECT','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,4,'ARRAY','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,5,'DATE','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,6,'INT','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,7,'OBJECTID','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 7);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,8,'LONG','{"jdbcType":-5,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 8);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,9,'BASICDBOBJECT','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 9);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,10,'INTERGER','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 10);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,11,'NULL','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 11);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,12,'INTEGER','{"jdbcType":11,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 12);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,13,'BASICDBLIST','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"非关系型数据库"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 13);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 9,4,'FTPLONG','{"jdbcType":-5,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 9 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 9,5,'FTPDATE','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 9 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 9,6,'FTPTIMESTAMP','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 9 AND f_dict_key = 6);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 10,1,'HDFSSTRING','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 10 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 10,2,'HDFSINT','{"jdbcType":-5,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 10 AND f_dict_key = 2);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 11,1,'SFTPLONG','{"jdbcType":-5,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 11 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 11,2,'SFTPTIMESTAMP','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 11 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 11,3,'SFTPDATE','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 11 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 11,4,'SFTPDOUBLE','{"jdbcType":8,"javaColumnType":"3","sparkColumnType":"4","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 11 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 11,5,'SFTPSTRING','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 11 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 11,6,'FTPINT','{"jdbcType":6,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"文件系统"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 11 AND f_dict_key = 6);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 13,1,'kafkaString','{"jdbcType":12,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"消息队列"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 13 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 13,2,'kafkaInteger','{"jdbcType":4,"javaColumnType":"1","sparkColumnType":"1","flinkColumnType":"4","dbCatalogName":"消息队列"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 13 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 13,3,'kafkaLong','{"jdbcType":-5,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"消息队列"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 13 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 13,4,'kafkaDouble','{"jdbcType":8,"javaColumnType":"3","sparkColumnType":"4","flinkColumnType":"4","dbCatalogName":"消息队列"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 13 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 13,5,'kafkaBool','{"jdbcType":16,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"消息队列"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 13 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 13,6,'kafkaDate','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"消息队列"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 13 AND f_dict_key = 6);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 13,7,'kafkaTimestamp','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"消息队列"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 13 AND f_dict_key = 7);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 14,1,'api_boolean','{"jdbcType":16,"javaColumnType":"5","sparkColumnType":"6","flinkColumnType":"4","dbCatalogName":"其他"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 14 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 14,2,'api_date','{"jdbcType":91,"javaColumnType":"6","sparkColumnType":"7","flinkColumnType":"4","dbCatalogName":"其他"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 14 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 14,3,'api_timestamp','{"jdbcType":93,"javaColumnType":"8","sparkColumnType":"9","flinkColumnType":"4","dbCatalogName":"其他"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 14 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 14,4,'api_long','{"jdbcType":4,"javaColumnType":"2","sparkColumnType":"2","flinkColumnType":"4","dbCatalogName":"其他"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 14 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 14,5,'api_string','{"jdbcType":1,"javaColumnType":"4","sparkColumnType":"5","flinkColumnType":"4","dbCatalogName":"其他"}',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 14 AND f_dict_key = 5);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 15,1,'oracle.jdbc.OracleDriver','oracle驱动类',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 15 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 15,2,'com.mysql.cj.jdbc.Driver','mysql驱动类',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 15 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 15,3,'org.postgresql.Driver','postgresql驱动类',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 15 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 15,4,'com.microsoft.sqlserver.jdbc.SQLServerDriver','sqlserver驱动类',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 15 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 15,5,'org.apache.hive.jdbc.HiveDriver','hive驱动类',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 15 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 15,14,'jdbc:clickhouse://', 'clickhouse-jdbc前缀', 1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 15 AND f_dict_key = 14);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 16,1,'jdbc:oracle:thin:@//','oracle-jdbc前缀',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 16 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 16,2,'jdbc:mysql://','mysql-jdbc前缀',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 16 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 16,3,'jdbc:postgresql://','postgresql-jdbc前缀',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 16 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 16,4,'jdbc:sqlserver://','sqlserver-jdbc前缀',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 16 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 16,5,'jdbc:hive2://','hive2-jdbc前缀',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 16 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 16,14,'com.clickhouse.jdbc.ClickHouseDriver','clickhouse驱动类',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 16 AND f_dict_key = 14);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 17,1,'select 1 from dual','oracle-有效性检测',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 17 AND f_dict_key = 1);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 17,2,'select 1','mysql-有效性检测',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 17 AND f_dict_key = 2);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 17,3,'select version()','postgresql-有效性检测',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 17 AND f_dict_key = 3);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 17,4,'select 1','sqlserver-有效性检测',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 17 AND f_dict_key = 4);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 17,5,'select 1','hive2-有效性检测',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 17 AND f_dict_key = 5);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 17,14,'select 1','clickhouse有效性检测',1 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 17 AND f_dict_key = 14);


INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 2,0,'UNKNOWN','',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 2 AND f_dict_key = 0);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 3,0,'UNKNOWN','',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 3 AND f_dict_key = 0);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 4,0,'UNKNOWN','',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 4 AND f_dict_key = 0);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 5,0,'UNKNOWN','',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 5 AND f_dict_key = 0);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 6,0,'UNKNOWN','',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 6 AND f_dict_key = 0);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 7,0,'UNKNOWN','',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 7 AND f_dict_key = 0);
INSERT INTO t_dict(f_dict_type,f_dict_key,f_dict_value,f_extend_property,f_enable_status) SELECT 8,0,'UNKNOWN','',2 FROM DUAL WHERE NOT EXISTS ( SELECT f_id from t_dict where f_dict_type = 8 AND f_dict_key = 0);


-- 当前血缘初始化依赖于 AnyFabric，引擎从 AnyFabric 剥离后，临时跳过血缘的初始化逻辑。后续考虑整体方案。
INSERT INTO t_lineage_graph_info (app_id,graph_id) SELECT '1',0 FROM DUAL WHERE NOT EXISTS ( SELECT app_id from t_lineage_graph_info where app_id = 1);
INSERT INTO t_lineage_graph_info (app_id,graph_id) SELECT '2',0 FROM DUAL WHERE NOT EXISTS ( SELECT app_id from t_lineage_graph_info where app_id = 2);
INSERT INTO t_lineage_graph_info (app_id,graph_id) SELECT '3',0 FROM DUAL WHERE NOT EXISTS ( SELECT app_id from t_lineage_graph_info where app_id = 3);
INSERT INTO t_lineage_graph_info (app_id,graph_id) SELECT '4',0 FROM DUAL WHERE NOT EXISTS ( SELECT app_id from t_lineage_graph_info where app_id = 4);
INSERT INTO t_lineage_graph_info (app_id,graph_id) SELECT '5',0 FROM DUAL WHERE NOT EXISTS ( SELECT app_id from t_lineage_graph_info where app_id = 5);
INSERT INTO t_lineage_graph_info (app_id,graph_id) SELECT '6',0 FROM DUAL WHERE NOT EXISTS ( SELECT app_id from t_lineage_graph_info where app_id = 6);

-- Source: vega/mdl-data-model/migrations/mariadb/0.1.0/init.sql
-- Copyright The kweaver.ai Authors.
--
-- Licensed under the Apache License, Version 2.0.
-- See the LICENSE file in the project root for details.

USE adp;

-- 指标模型
CREATE TABLE IF NOT EXISTS t_metric_model (
  f_model_id varchar(40) NOT NULL DEFAULT '' COMMENT '指标模型 id',
  f_model_name varchar(40) NOT NULL COMMENT '指标模型名称',
  f_tags varchar(255) DEFAULT NULL COMMENT '标签',
  f_comment varchar(255) DEFAULT NULL COMMENT '备注',
  f_catalog_id varchar(40) NOT NULL DEFAULT '' COMMENT '编目id',
  f_catalog_content text DEFAULT NULL COMMENT '编目内容',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_measure_name varchar(50) NOT NULL DEFAULT '' COMMENT '度量名称',
  f_metric_type varchar(20) NOT NULL COMMENT '指标类型',
  f_data_source varchar(255) NOT NULL COMMENT '数据源',
  f_query_type varchar(20) NOT NULL COMMENT '指标查询语言',
  f_formula text NOT NULL COMMENT '计算公式',
  f_formula_config text DEFAULT NULL COMMENT '计算公式配置化',
  f_analysis_dimessions varchar(8192) DEFAULT NULL COMMENT '分析维度',
  f_order_by_fields varchar(4096) DEFAULT NULL COMMENT '排序字段',
  f_having_condition varchar(2048) DEFAULT NULL COMMENT '值过滤',
  f_date_field varchar(255) DEFAULT NULL COMMENT '时间字段',
  f_measure_field varchar(255) NOT NULL COMMENT '度量字段',
  f_unit_type varchar(40) NOT NULL COMMENT '单位类型',
  f_unit varchar(20) NOT NULL COMMENT '度量单位',
  f_group_id varchar(40) NOT NULL DEFAULT '' COMMENT '指标模型分组 id',
  f_builtin tinyint(2) DEFAULT 0 COMMENT '内置模型标识: 0 非内置, 1 内置',
  f_calendar_interval tinyint(2) DEFAULT 0 COMMENT '是否日历间隔。0: 非日历间隔; 1: 日历间隔',
  PRIMARY KEY (f_model_id),
  UNIQUE KEY uk_model_name (f_group_id, f_model_name)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '指标模型';

-- 指标模型分组
CREATE TABLE IF NOT EXISTS t_metric_model_group (
  f_group_id varchar(40) NOT NULL DEFAULT '' COMMENT '指标模型分组 id',
  f_group_name varchar(40) NOT NULL COMMENT '指标模型分组名称',
  f_comment varchar(255) NOT NULL DEFAULT '' COMMENT '指标模型分组备注',  
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_builtin tinyint(2) NOT NULL DEFAULT 0 COMMENT '内置分组标识: 0 非内置, 1 内置',
  PRIMARY KEY (f_group_id),
  UNIQUE KEY uk_f_group_name (f_group_name)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '指标模型分组';


-- 指标模型持久化任务
CREATE TABLE IF NOT EXISTS t_metric_model_task(
  f_task_id varchar(40) NOT NULL DEFAULT '' COMMENT '任务 id',
  f_task_name varchar(40) NOT NULL COMMENT '任务名称',
  f_comment varchar(255) NOT NULL DEFAULT '' COMMENT '任务备注',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_module_type varchar(20) NOT NULL DEFAULT '' COMMENT '模块类型',
  f_model_id varchar(40) NOT NULL COMMENT '指标模型 id',
  f_schedule varchar(255) NOT NULL COMMENT '执行频率',
  f_variables text DEFAULT NULL COMMENT '变量过滤',
  f_time_windows varchar(1024) DEFAULT NULL COMMENT '时间窗口',
  f_steps varchar(255) NOT NULL DEFAULT '[]' COMMENT '持久化步长',
  f_plan_time bigint(20) NOT NULL DEFAULT 0 COMMENT '计划时间',
  f_index_base varchar(40) NOT NULL COMMENT '索引库类型',
  f_retrace_duration varchar(20) DEFAULT NULL COMMENT '追溯时长',
  f_schedule_sync_status tinyint(2) NOT NULL COMMENT '任务的同步状态。3: 完成',
  f_execute_status tinyint(2) DEFAULT 0 COMMENT '任务的执行状态。4: 执行成功; 5: 执行失败',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建任务的用户id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  PRIMARY KEY (f_task_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '指标持久化任务';


-- 指标索引的静态表，记录指标类索引库的分割时间点，便于升级到__tsid后，指标模型查询的兼容
CREATE TABLE IF NOT EXISTS t_static_metric_index (
  f_id int(11) AUTO_INCREMENT COMMENT '唯一id编号',
  f_base_type varchar(40) NOT NULL COMMENT '指标索引库类型',
  f_split_time datetime DEFAULT current_timestamp() COMMENT '索引库的时间分割',
  PRIMARY KEY (f_id),
  UNIQUE KEY uk_f_index_base_type (f_base_type)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '指标索引库tsid的时间分割静态表';


-- 事件模型聚合规则
CREATE TABLE if not exists t_event_model_aggregate_rules (
  f_aggregate_rule_id varchar(40) NOT NULL DEFAULT '' COMMENT '聚合规则id',
  f_aggregate_rule_type varchar(40) NOT NULL COMMENT '聚合规则类型',
  f_aggregate_algo varchar(900) NOT NULL COMMENT '聚合算法',
  f_rule_priority int(11) NOT NULL COMMENT '规则优先级',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_group_fields varchar(255) DEFAULT '[]' COMMENT '分组字段',
  f_aggregate_analysis_algo varchar(1024) DEFAULT '{}' COMMENT "分析算法",
  PRIMARY KEY (f_aggregate_rule_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin;


-- 事件模型
CREATE TABLE if not exists t_event_models (
  f_event_model_id varchar(40) NOT NULL DEFAULT '' COMMENT '事件模型id',
  f_event_model_name varchar(255) NOT NULL COMMENT '事件模型名称',
  f_event_model_group_name varchar(40) NOT NULL DEFAULT '' COMMENT '事件模型分组名称',
  f_event_model_type varchar(40) NOT NULL COMMENT '事件模型类型',
  f_event_model_tags varchar(255) NOT NULL COMMENT '事件模型标签',
  f_event_model_comment varchar(255) DEFAULT NULL COMMENT '事件模型说明',
  f_data_source_type varchar(40) NOT NULL COMMENT '数据源类型',
  f_data_source varchar(900) DEFAULT NULL COMMENT '数据源对象id',
  f_detect_rule_id varchar(40) NOT NULL COMMENT '检测规则id',
  f_aggregate_rule_id varchar(40) NOT NULL COMMENT '聚合规则id',
  f_default_time_window varchar(40) NOT NULL COMMENT '默认时间窗口',
  f_is_active tinyint(2) DEFAULT 0 COMMENT '是否是定期执行模式',
  f_enable_subscribe tinyint(2) DEFAULT 0 COMMENT '是否是实时订阅模式',
  f_status tinyint(2) DEFAULT 0 COMMENT '是否启用',
  f_downstream_dependent_model varchar(1024) DEFAULT '' COMMENT '依赖模型',
  f_is_custom tinyint(2) NOT NULL COMMENT '是否个性化',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (f_event_model_id),
  UNIQUE KEY uk_f_model_name (f_event_model_name)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin;


-- 事件模型检测规则
CREATE TABLE if not exists t_event_model_detect_rules (
  f_detect_rule_id varchar(40) NOT NULL DEFAULT '' COMMENT '检测规则id',
  f_detect_rule_type varchar(40) NOT NULL COMMENT '检测规则类型',
  f_formula varchar(2014) DEFAULT NULL COMMENT '计算公式',
  f_detect_algo varchar(40) DEFAULT NULL  COMMENT '检测算法',
  f_detect_analysis_algo varchar(1024) DEFAULT '{}' COMMENT '分析算法',
  f_rule_priority int(11) NOT NULL COMMENT "规则优先级",
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (f_detect_rule_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin;


-- 事件模型持久化任务
CREATE TABLE IF NOT EXISTS t_event_model_task (
  f_task_id varchar(40) NOT NULL DEFAULT '' COMMENT '唯一id编号',
  f_model_id varchar(40) NOT NULL COMMENT '事件模型 id',
  f_storage_config varchar(255) NOT NULL COMMENT '存储配置',
  f_schedule varchar(255) NOT NULL COMMENT '执行频率',
  f_dispatch_config varchar(255) NOT NULL COMMENT '调度配置',
  f_execute_parameter varchar(255) NOT NULL COMMENT '执行参数',
  f_task_status tinyint(2) NOT NULL COMMENT '最近一次任务执行状态。4: 执行成功; 5: 执行失败',
  f_error_details varchar(2048) NOT NULL COMMENT '任务执行失败原因',
  f_status_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '执行状态更新时间',
  f_schedule_sync_status tinyint(2) NOT NULL COMMENT '任务的同步状态。3: 完成',
  f_downstream_dependent_task varchar(1024) DEFAULT '' COMMENT '依赖任务',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  PRIMARY KEY (f_task_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '事件模型持久化任务';


-- 事件模型异步任务记录
CREATE TABLE IF NOT EXISTS t_event_model_task_execution_records (
  f_run_id bigint(20) unsigned NOT NULL COMMENT '运行id',
  f_run_type varchar(40) NOT NULL COMMENT '任务类型',
  f_execute_parameter varchar(2048) NOT NULL COMMENT '执行参数',
  f_status varchar(40) DEFAULT '0' COMMENT '状态',
  f_error_details varchar(1024) NOT NULL COMMENT '错误原因',
  f_update_time datetime NOT NULL COMMENT '更新时间',
  f_create_time datetime NOT NULL COMMENT '创建时间',
  PRIMARY KEY (f_run_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin;


-- 数据视图
CREATE TABLE IF NOT EXISTS t_data_view (
  f_view_id varchar(40) NOT NULL DEFAULT '' COMMENT '数据视图 id',
  f_view_name varchar(255) NOT NULL COMMENT '数据视图名称',
  f_technical_name varchar(255) NOT NULL DEFAULT '' COMMENT '技术名称',
  f_group_id varchar(40) NOT NULL DEFAULT '' COMMENT '数据视图分组 id',
  f_type varchar(10) NOT NULL DEFAULT '' COMMENT '视图类型',
  f_query_type varchar(10) NOT NULL DEFAULT '' COMMENT '查询类型',
  f_builtin tinyint(2) DEFAULT 0 COMMENT '内置视图标识: 0 非内置, 1 内置',
  f_tags varchar(255) NOT NULL DEFAULT '' COMMENT '标签',
  f_comment varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
  f_data_source_type varchar(20) NOT NULL DEFAULT '' COMMENT '数据源类型',
  f_data_source_id varchar(40) NOT NULL DEFAULT '' COMMENT '数据源 id',
  f_file_name varchar(128) NOT NULL DEFAULT '' COMMENT '文件名',
  f_excel_config text DEFAULT NULL COMMENT 'excel 配置',
  f_data_scope longtext DEFAULT NULL COMMENT '数据范围',
  f_fields longtext DEFAULT NULL COMMENT '字段列表',
  f_status varchar(20) NOT NULL DEFAULT '' COMMENT '状态',
  f_metadata_form_id varchar(40) NOT NULL DEFAULT '' COMMENT '元数据表单 id',
  f_primary_keys varchar(255) NOT NULL DEFAULT '' COMMENT '主键列表',
  f_sql longtext DEFAULT NULL COMMENT '生成视图sql',
  f_meta_table_name varchar(1024) NOT NULL DEFAULT '' COMMENT '元数据表名',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_delete_time bigint(20) NOT NULL DEFAULT 0 COMMENT '删除时间',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_updater varchar(40) NOT NULL DEFAULT '' COMMENT '更新者id',
  f_updater_type varchar(20) NOT NULL DEFAULT '' COMMENT '更新者类型',
  f_data_source text DEFAULT NULL COMMENT '废弃, 数据视图数据来源',
  f_field_scope tinyint(2) NOT NULL DEFAULT '0' COMMENT '废弃, 字段范围: 0 部分字段, 1 全部字段',
  f_filters text DEFAULT NULL COMMENT '废弃, 过滤条件',
  f_open_streaming tinyint(2) NOT NULL DEFAULT 0 COMMENT '废弃, 是否开启视图实时订阅任务: 0 不开启, 1 开启',
  f_job_id varchar(40) NOT NULL DEFAULT '' COMMENT '废弃, 订阅任务 id',
  f_loggroup_filters longtext DEFAULT NULL COMMENT '废弃, 日志分组过滤条件',
  PRIMARY KEY (f_view_id),
  UNIQUE KEY uk_f_view_name (f_group_id, f_view_name, f_delete_time)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '数据视图';

-- 数据视图分组
CREATE TABLE IF NOT EXISTS t_data_view_group (
  f_group_id varchar(40) NOT NULL DEFAULT '' COMMENT '数据视图分组 id',
  f_group_name varchar(40) NOT NULL COMMENT '数据视图分组名称',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_delete_time bigint(20) NOT NULL DEFAULT 0 COMMENT '删除时间',
  f_builtin tinyint(2) NOT NULL DEFAULT 0 COMMENT '内置视图标识: 0 非内置, 1 内置',
  PRIMARY KEY (f_group_id),
  UNIQUE KEY uk_f_group_name (f_builtin, f_group_name, f_delete_time)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '数据视图分组';

-- 扫描记录
CREATE TABLE IF NOT EXISTS t_scan_record (
    f_record_id varchar(40) NOT NULL DEFAULT '' COMMENT '扫描记录 id',
    f_data_source_id varchar(40) NOT NULL COMMENT '数据源 id',
    f_scanner varchar(40) NOT NULL COMMENT '扫描器',
    f_scan_time bigint(20) NOT NULL DEFAULT 0 COMMENT '扫描时间',
    f_data_source_status varchar(20) NOT NULL DEFAULT '' COMMENT '数据源状态: available 可用 scanning 扫描中',
    f_metadata_task_id varchar(128)  DEFAULT NULL COMMENT '元数据采集平台任务id',
    PRIMARY KEY (f_record_id),
    UNIQUE KEY uk_scan_record (f_data_source_id, f_scanner)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '数据源扫描记录表';

-- 视图行列规则表
CREATE TABLE IF NOT EXISTS t_data_view_row_column_rule (
  f_rule_id varchar(40) NOT NULL DEFAULT '' COMMENT '视图行列规则 id',
  f_rule_name varchar(255) NOT NULL COMMENT '视图行列规则名称',
  f_view_id varchar(40) NOT NULL COMMENT '视图 id',
  f_tags varchar(255) NOT NULL DEFAULT '' COMMENT '标签',
  f_comment varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
  f_fields longtext NOT NULL COMMENT '列',
  f_row_filters text NOT NULL COMMENT '行过滤规则',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间', 
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_updater varchar(40) NOT NULL DEFAULT '' COMMENT '更新者id',
  f_updater_type varchar(20) NOT NULL DEFAULT '' COMMENT '更新者类型',
  PRIMARY KEY (f_rule_id),
  UNIQUE KEY uk_f_rule_name (f_rule_name, f_view_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '数据视图行列规则';

-- 数据字典
CREATE TABLE IF NOT EXISTS t_data_dict (
  f_dict_id varchar(40) NOT NULL COMMENT '数据字典id',
  f_dict_name varchar(255) NOT NULL COMMENT '数据字典名称',
  f_tags varchar(255) NOT NULL COMMENT '标签',
  f_comment varchar(255) DEFAULT NULL COMMENT '备注',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_dict_type varchar(20) NOT NULL DEFAULT 'kv_dict' COMMENT '数据字典类型',
  f_dict_store varchar(255) NOT NULL COMMENT '数据字典的项存放的对应表名称',
  f_dimension varchar(1500) NOT NULL COMMENT '数据字典维度关系',
  f_unique_key tinyint(2) NOT NULL DEFAULT 1 COMMENT '是否唯一键',
  PRIMARY KEY (f_dict_id),
  UNIQUE KEY uk_dict_name (f_dict_name)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '数据字典信息';

-- 数据字典项
CREATE TABLE IF NOT EXISTS t_data_dict_item (
  f_item_id varchar(40) NOT NULL COMMENT '数据字典项id',
  f_dict_id varchar(40) NOT NULL COMMENT '数据字典id',
  f_item_key varchar(3000) NOT NULL COMMENT '数据字典项key值',
  f_item_value varchar(3000) NOT NULL COMMENT '数据字典项value值',
  f_comment varchar(255) COMMENT '数据字典项说明',
  PRIMARY KEY (f_item_id),
  KEY idx_dict_id (f_dict_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '数据字典项信息表';

-- 数据连接
CREATE TABLE IF NOT EXISTS t_data_connection (
  f_connection_id varchar(40) NOT NULL COMMENT '唯一id编号',
  f_connection_name varchar(40) NOT NULL COMMENT '数据连接名称',
  f_tags varchar(255) DEFAULT '' COMMENT '标签',
  f_comment varchar(255) DEFAULT '' COMMENT '数据连接备注',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_data_source_type varchar(40) NOT NULL COMMENT '数据源类型',
  f_config text NOT NULL COMMENT '详细配置',
  f_config_md5 varchar(32) DEFAULT '' COMMENT '详细配置的唯一标识符',
  PRIMARY KEY (f_connection_id),
  UNIQUE KEY uk_f_connection_name (f_connection_name),
  KEY idx_f_data_source_type (f_data_source_type),
  KEY idx_f_config_md5 (f_config_md5)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '数据连接';

-- 数据连接状态
CREATE TABLE IF NOT EXISTS t_data_connection_status (
  f_connection_id varchar(40) NOT NULL COMMENT '数据连接id',
  f_status varchar(5) NOT NULL COMMENT '连接状态',
  f_detection_time bigint(20) NOT NULL DEFAULT 0 COMMENT '检测时间',
  PRIMARY KEY (f_connection_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '数据连接状态';

-- 链路模型
CREATE TABLE IF NOT EXISTS t_trace_model (
  f_model_id varchar(40) NOT NULL COMMENT '唯一id编号',
  f_model_name varchar(40) NOT NULL COMMENT '链路模型名称',
  f_tags varchar(255) DEFAULT '' COMMENT '标签',
  f_comment varchar(255) DEFAULT '' COMMENT '链路模型备注',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_span_source_type varchar(40) NOT NULL COMMENT 'span数据来源类型',
  f_span_config text NOT NULL COMMENT 'span配置',
  f_enabled_related_log tinyint(2) NOT NULL COMMENT '是否开启配置span关联日志配置, 0表示否, 1表示是',
  f_related_log_source_type varchar(40) NOT NULL COMMENT 'span关联日志数据来源类型',
  f_related_log_config text NOT NULL COMMENT 'span关联日志配置',
  PRIMARY KEY (f_model_id),
  UNIQUE KEY uk_f_model_name (f_model_name),
  KEY idx_f_span_source_type (f_span_source_type)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '链路模型';

-- global data-model-job
CREATE TABLE IF NOT EXISTS t_data_model_job (
  f_job_id varchar(40) NOT NULL DEFAULT '' COMMENT '任务 id',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_job_type varchar(40) NOT NULL COMMENT '任务类型',
  f_job_config text COMMENT '任务配置',
  f_job_status varchar(20) NOT NULL COMMENT '任务状态: running 正常, error 异常',
  f_job_status_details text NOT NULL COMMENT '任务状态详情',
  PRIMARY KEY (f_job_id)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '全局任务表';


-- 目标模型
CREATE TABLE IF NOT EXISTS t_objective_model (
  f_model_id varchar(40) NOT NULL DEFAULT '' COMMENT '目标模型 id',
  f_model_name varchar(40) NOT NULL COMMENT '目标模型名称',
  f_tags varchar(255) NOT NULL DEFAULT '' COMMENT '标签',
  f_comment varchar(255) NOT NULL DEFAULT '' COMMENT '备注',
  f_creator varchar(40) NOT NULL DEFAULT '' COMMENT '创建者id',
  f_creator_type varchar(20) NOT NULL DEFAULT '' COMMENT '创建者类型',
  f_create_time bigint(20) NOT NULL DEFAULT 0 COMMENT '创建时间',
  f_update_time bigint(20) NOT NULL DEFAULT 0 COMMENT '更新时间',
  f_objective_type varchar(20) NOT NULL COMMENT '目标类型',
  f_objective_config text NOT NULL COMMENT '目标配置',
  PRIMARY KEY (f_model_id),
  UNIQUE KEY uk_t_objective_model (f_model_name)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '目标模型';


-- --------------------------------------- 初始化数据 --------------------------------------------
-- 未分组
INSERT INTO t_data_view_group (
  f_group_id,
  f_group_name,
  f_create_time,
  f_update_time,
  f_builtin
)
SELECT '', '', 1733903782147, 1733903782147, 0
FROM DUAL
WHERE NOT EXISTS(
  SELECT f_group_id
  FROM t_data_view_group
  WHERE f_group_id = ''
);

-- 索引库
INSERT INTO t_data_view_group (
  f_group_id,
  f_group_name,
  f_create_time,
  f_update_time,
  f_builtin
)
SELECT '__index_base', 'index_base', 1733903782147, 1733903782147, 1
FROM DUAL
WHERE NOT EXISTS(
  SELECT f_group_id
  FROM t_data_view_group
  WHERE f_group_id = '__index_base'
);

-- 未分组
INSERT INTO t_metric_model_group (
  f_group_id,
  f_group_name,
  f_create_time,
  f_update_time,
  f_builtin
)
SELECT '', '', 1733903782147, 1733903782147, 0
FROM DUAL
WHERE NOT EXISTS(
  SELECT f_group_id
  FROM t_metric_model_group
  WHERE f_group_id = ''
);

-- Source: vega/vega-gateway/migrations/mariadb/0.2.0/init.sql
-- Copyright The kweaver.ai Authors.
--
-- Licensed under the Apache License, Version 2.0.
-- See the LICENSE file in the project root for details.

USE adp;


CREATE TABLE IF NOT EXISTS `cache_table` (
  `id` char(36) NOT NULL COMMENT '主键',
  `catalog_name` char(36) NOT NULL COMMENT '对应的逻辑视图的catalog名称',
  `schema_name` char(36) NOT NULL COMMENT '对应的逻辑视图的schema名称',
  `table_name` char(36) NOT NULL COMMENT '对应的逻辑视图的table名称',
  `cts_sql` text DEFAULT NULL COMMENT '表的建表sql',
  `source_create_sql` text DEFAULT NULL COMMENT '样例数据查询sql',
  `current_view_original_text` text DEFAULT NULL COMMENT '最近一次的原始加密sql',
  `status` char(36) NOT NULL COMMENT '可用；异常；正在初始化',
  `mid_status` char(36) DEFAULT NULL COMMENT '在FSM任务的时候的中间状态',
  `deps` varchar(255) DEFAULT '' COMMENT '生成的结果缓存表的id用,分隔',
  `create_time` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '更新时间',
  `update_time` datetime(3) NOT NULL DEFAULT current_timestamp(3) COMMENT '更新时间',
  PRIMARY KEY (`id`)
);


CREATE TABLE IF NOT EXISTS `client_id` (
  `id` int NOT NULL COMMENT '主键id',
  `client_name` varchar(128) DEFAULT NULL COMMENT '客户端名称',
  `client_id` varchar(64) DEFAULT NULL COMMENT '客户端id',
  `client_secret` varchar(64) DEFAULT NULL COMMENT '客户端密码',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`)
);


CREATE TABLE IF NOT EXISTS `excel_column_type` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `catalog` varchar(256) NOT NULL COMMENT '数据源',
  `vdm_catalog` varchar(256) DEFAULT NULL COMMENT 'vdm数据源',
  `schema_name` varchar(256) NOT NULL COMMENT '库名',
  `table_name` varchar(512) NOT NULL COMMENT '表名',
  `column_name` varchar(128) NOT NULL COMMENT '列名',
  `column_comment` varchar(512) DEFAULT NULL COMMENT '列注释',
  `type` varchar(128) NOT NULL COMMENT '字段类型',
  `order_no` int NOT NULL COMMENT '列序号',
  `create_time` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '更新时间',
  PRIMARY KEY (`id`)
);


CREATE TABLE IF NOT EXISTS `excel_table_config` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `catalog` varchar(256) NOT NULL COMMENT '数据源',
  `vdm_catalog` varchar(256) DEFAULT NULL COMMENT 'vdm数据源',
  `schema_name` varchar(256) NOT NULL COMMENT '库名',
  `file_name` varchar(512) NOT NULL COMMENT 'excel文件名',
  `table_name` varchar(512) NOT NULL COMMENT '表名',
  `table_comment` varchar(512) DEFAULT NULL COMMENT '表注释',
  `sheet` varchar(128) DEFAULT NULL COMMENT 'sheet名称',
  `all_sheet` tinyint NOT NULL DEFAULT 0 COMMENT '是否加载所有sheet',
  `sheet_as_new_column` tinyint NOT NULL DEFAULT 0 COMMENT 'sheet是否作为列 1:是 0:否',
  `start_cell` varchar(32) DEFAULT NULL COMMENT '起始单元格',
  `end_cell` varchar(32) DEFAULT NULL COMMENT '结束单元格',
  `has_headers` tinyint NOT NULL DEFAULT 1 COMMENT '是否有表头  1：有； 0：没有',
  `create_time` timestamp NULL DEFAULT current_timestamp() COMMENT '创建时间',
  `update_time` timestamp NOT NULL DEFAULT current_timestamp() COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `excel_table_config_vdm_table_uindex` (`catalog`,`table_name`)
);


CREATE TABLE IF NOT EXISTS `query_info` (
  `query_id` varchar(30) NOT NULL COMMENT 'query id',
  `result` longtext DEFAULT NULL COMMENT '查询结果集',
  `msg` varchar(500) DEFAULT NULL COMMENT '错误详情',
  `task_id` varchar(200) NOT NULL COMMENT '任务Id',
  `state` varchar(30) NOT NULL COMMENT '状态',
  `create_time` varchar(30) NOT NULL COMMENT '创建时间',
  `update_time` varchar(30) NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`query_id`)
);


CREATE TABLE IF NOT EXISTS `task_info` (
  `task_id` varchar(200) NOT NULL COMMENT '主键taskid',
  `state` varchar(30) DEFAULT NULL COMMENT 'task状态',
  `query` longtext DEFAULT NULL,
  `create_time` varchar(30) DEFAULT NULL COMMENT '创建时间',
  `update_time` varchar(30) DEFAULT NULL COMMENT '修改时间',
  `topic` varchar(100) DEFAULT NULL COMMENT 'topic名称',
  `sub_task_id` varchar(200) NOT NULL COMMENT '子任务Id',
  `type` int NOT NULL DEFAULT 1 COMMENT '类型,0:异步查询,1:字段探查',
  `elapsed_time` varchar(30) NOT NULL COMMENT '总耗时',
  `update_count` text NOT NULL COMMENT '结果集大小,只针对insert into或create table as记录大小',
  `schedule_time` varchar(30) NOT NULL COMMENT '调度耗时',
  `queued_time` varchar(30) NOT NULL COMMENT '队列耗时',
  `cpu_time` varchar(30) NOT NULL COMMENT 'cpu耗时',
  PRIMARY KEY (`task_id`,`sub_task_id`)
);

