-- ----------------------------
-- Table structure for knowledge_attach
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_attach`;
CREATE TABLE `knowledge_attach`
(
    `id`              bigint      NOT NULL AUTO_INCREMENT,
    `knowledge_id`    varchar(50) NOT NULL COMMENT '知识库ID',
    `doc_id`          varchar(50) NOT NULL COMMENT '文档ID',
    `doc_name`        varchar(500)         DEFAULT NULL COMMENT '文档名称',
    `doc_type`        varchar(50) NOT NULL COMMENT '文档类型',
    `oss_id`          int                  DEFAULT NULL COMMENT '对象存储ID',
    `pic_status`      tinyint(1)  NOT NULL DEFAULT 10 COMMENT '拆解图片状态:10未开始,20进行中,30已完成',
    `pic_anys_status` tinyint(1)  NOT NULL DEFAULT 10 COMMENT '分析图片状态:10未开始,20进行中,30已完成',
    `vector_status`   tinyint(1)  NOT NULL DEFAULT 10 COMMENT '写入向量数据库状态:10未开始,20进行中,30已完成',
    `content`         longtext COMMENT '文档内容',
    `create_by`       bigint               DEFAULT NULL COMMENT '创建人',
    `create_time`     datetime             DEFAULT NULL COMMENT '创建时间',
    `update_by`       bigint               DEFAULT NULL COMMENT '更新者',
    `update_time`     datetime             DEFAULT NULL COMMENT '更新时间',
    `remark`          varchar(500)         DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `idx_kname` (`knowledge_id`, `doc_name`) USING BTREE,
    KEY `idx_knowledge_id` (`knowledge_id`) USING BTREE,
    KEY `idx_doc_id` (`doc_id`) USING BTREE,
    KEY `idx_create_time` (`create_time`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库附件';

-- ----------------------------
-- Table structure for knowledge_fragment
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_fragment`;
CREATE TABLE `knowledge_fragment`
(
    `id`           bigint      NOT NULL AUTO_INCREMENT,
    `knowledge_id` varchar(50) NOT NULL COMMENT '知识库ID',
    `doc_id`       varchar(50)  DEFAULT NULL COMMENT '文档ID',
    `fid`          varchar(50) NOT NULL COMMENT '知识片段ID',
    `idx`          int         NOT NULL COMMENT '片段索引下标',
    `content`      text        NOT NULL COMMENT '文档内容',
    `create_by`    bigint       DEFAULT NULL COMMENT '创建人',
    `create_time`  datetime     DEFAULT NULL COMMENT '创建时间',
    `update_by`    bigint       DEFAULT NULL COMMENT '更新者',
    `update_time`  datetime     DEFAULT NULL COMMENT '更新时间',
    `remark`       varchar(500) DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_knowledge_id` (`knowledge_id`) USING BTREE,
    KEY `idx_doc_id` (`doc_id`) USING BTREE,
    KEY `idx_fid` (`fid`) USING BTREE,
    KEY `idx_create_time` (`create_time`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库知识片段';

-- ----------------------------
-- Table structure for knowledge_info
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_info`;
CREATE TABLE `knowledge_info`
(
    `id`                   bigint      NOT NULL AUTO_INCREMENT,
    `user_id`              bigint      NOT NULL DEFAULT 0 COMMENT '用户ID',
    `knowledge_id`         varchar(50) NOT NULL COMMENT '知识库ID',
    `knowledge_name`       varchar(50) NOT NULL COMMENT '知识库名称',
    `share`                tinyint(1)  NOT NULL DEFAULT 0 COMMENT '是否公开知识库:0否,1是',
    `description`          varchar(1000)        DEFAULT NULL COMMENT '描述',
    `knowledge_separator`  varchar(255)         DEFAULT NULL COMMENT '知识分隔符',
    `question_separator`   varchar(255)         DEFAULT NULL COMMENT '提问分隔符',
    `overlap_char`         int                  DEFAULT NULL COMMENT '重叠字符数',
    `retrieve_limit`       int                  DEFAULT NULL COMMENT '知识库中检索的条数',
    `text_block_size`      int                  DEFAULT NULL COMMENT '文本块大小',
    `vector_model_name`    varchar(50)          DEFAULT NULL COMMENT '向量库',
    `embedding_model_name` varchar(50)          DEFAULT NULL COMMENT '向量模型',
    `system_prompt`        varchar(255)         DEFAULT NULL COMMENT '系统提示词',
    `create_by`            bigint               DEFAULT NULL COMMENT '创建人',
    `create_time`          datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`            bigint               DEFAULT NULL COMMENT '更新者',
    `update_time`          datetime    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `remark`               varchar(500)         DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `idx_knowledge_id` (`knowledge_id`) USING BTREE,
    KEY `idx_user_id` (`user_id`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库';

-- ----------------------------
-- Table structure for knowledge_prompt_template
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_prompt_template`;
CREATE TABLE `knowledge_prompt_template`
(
    `id`               bigint       NOT NULL AUTO_INCREMENT COMMENT '主键',
    `template_name`    varchar(128) NOT NULL DEFAULT '' COMMENT '提示词模板名称',
    `template_content` text COMMENT '提示词模板内容',
    `category`         varchar(16)  NOT NULL DEFAULT 'knowledge' COMMENT '提示词分类:knowledge知识库类型,chat对话类型,draw绘画类型',
    `create_by`        bigint                DEFAULT NULL COMMENT '创建者',
    `create_time`      datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`        bigint                DEFAULT NULL COMMENT '更新者',
    `update_time`      datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `remark`           varchar(256)          DEFAULT NULL COMMENT '备注',
    `del_flag`         tinyint(1)   NOT NULL DEFAULT 0 COMMENT '删除标志:0存在,1删除',
    PRIMARY KEY (`id`),
    KEY `idx_category_del` (`category`, `del_flag`),
    KEY `idx_create_time` (`create_time`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库提示词模板表';

-- ----------------------------
-- Table structure for knowledge_schema_group
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_schema_group`;
CREATE TABLE `knowledge_schema_group`
(
    `id`          bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `name`        varchar(128) DEFAULT NULL COMMENT '分组名称',
    `code`        varchar(128) DEFAULT NULL COMMENT '分组编码',
    `icon`        varchar(100) DEFAULT NULL COMMENT '图标',
    `remark`      varchar(500) DEFAULT NULL COMMENT '备注',
    `del_flag`    tinyint(1)   DEFAULT 0 COMMENT '删除标志:0存在,1删除',
    `create_by`   bigint       DEFAULT NULL COMMENT '创建者',
    `create_time` datetime     DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`   bigint       DEFAULT NULL COMMENT '更新者',
    `update_time` datetime     DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_knowledge_schema_group_code` (`code`),
    KEY `idx_knowledge_schema_group_del_flag` (`del_flag`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库数据模型分组表';

-- ----------------------------
-- Table structure for knowledge_schema
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_schema`;
CREATE TABLE `knowledge_schema`
(
    `id`              bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `schema_group_id` bigint       DEFAULT NULL COMMENT '分组ID',
    `name`            varchar(128) DEFAULT NULL COMMENT '模型名称',
    `code`            varchar(128) DEFAULT NULL COMMENT '模型编码',
    `table_name`      varchar(128) DEFAULT NULL COMMENT '表名',
    `remark`          varchar(500) DEFAULT NULL COMMENT '备注',
    `del_flag`        tinyint(1)   DEFAULT 0 COMMENT '删除标志:0存在,1删除',
    `create_by`       bigint       DEFAULT NULL COMMENT '创建者',
    `create_time`     datetime     DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`       bigint       DEFAULT NULL COMMENT '更新者',
    `update_time`     datetime     DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_knowledge_schema_group_id` (`schema_group_id`),
    KEY `idx_knowledge_schema_code` (`code`),
    KEY `idx_knowledge_schema_table_name` (`table_name`),
    KEY `idx_knowledge_schema_del_flag` (`del_flag`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库数据模型表';

-- ----------------------------
-- Table structure for knowledge_schema_field
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_schema_field`;
CREATE TABLE `knowledge_schema_field`
(
    `id`            bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
    `schema_id`     bigint       DEFAULT NULL COMMENT '模型ID',
    `schema_name`   varchar(128) DEFAULT NULL COMMENT '模型名称',
    `name`          varchar(128) DEFAULT NULL COMMENT '字段名称',
    `code`          varchar(128) DEFAULT NULL COMMENT '字段编码',
    `type`          varchar(50)  DEFAULT NULL COMMENT '字段类型',
    `comment`       varchar(500) DEFAULT NULL COMMENT '字段注释',
    `is_pk`         tinyint(1)   DEFAULT 0 COMMENT '是否主键:0否,1是',
    `is_required`   tinyint(1)   DEFAULT 0 COMMENT '是否必填:0否,1是',
    `is_unique`     tinyint(1)   DEFAULT 0 COMMENT '是否唯一:0否,1是',
    `default_value` varchar(200) DEFAULT NULL COMMENT '默认值',
    `length`        int          DEFAULT NULL COMMENT '字段长度',
    `scale`         int          DEFAULT NULL COMMENT '小数位数',
    `is_list`       tinyint(1)   DEFAULT 0 COMMENT '是否列表显示:0否,1是',
    `is_query`      tinyint(1)   DEFAULT 0 COMMENT '是否查询字段:0否,1是',
    `is_insert`     tinyint(1)   DEFAULT 0 COMMENT '是否插入字段:0否,1是',
    `is_edit`       tinyint(1)   DEFAULT 0 COMMENT '是否编辑字段:0否,1是',
    `query_type`    varchar(200) DEFAULT NULL COMMENT '查询方式(EQ,NE,GT,LT,LIKE,BETWEEN)',
    `html_type`     varchar(200) DEFAULT 'input' COMMENT '显示类型(input,textarea,select,checkbox,radio,datetime,image,upload,editor)',
    `dict_type`     varchar(200) DEFAULT '' COMMENT '字典类型',
    `sort`          int          DEFAULT NULL COMMENT '排序',
    `del_flag`      tinyint(1)   DEFAULT 0 COMMENT '删除标志:0存在,1删除',
    `create_by`     bigint       DEFAULT NULL COMMENT '创建者',
    `create_time`   datetime     DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`     bigint       DEFAULT NULL COMMENT '更新者',
    `update_time`   datetime     DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `remark`        varchar(500) DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`),
    KEY `idx_knowledge_schema_field_schema_id` (`schema_id`),
    KEY `idx_knowledge_schema_field_code` (`code`),
    KEY `idx_knowledge_schema_field_del_flag` (`del_flag`),
    KEY `idx_knowledge_schema_field_sort` (`sort`)
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库数据模型字段表';

-- ----------------------------
-- Table structure for knowledge_role
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_role`;
CREATE TABLE `knowledge_role`
(
    `id`          bigint NOT NULL AUTO_INCREMENT COMMENT '知识库角色id',
    `name`        varchar(100) DEFAULT NULL COMMENT '知识库角色名称',
    `del_flag`    tinyint(1)   DEFAULT 0 COMMENT '删除标志:0存在,1删除',
    `create_by`   bigint       DEFAULT NULL COMMENT '创建者',
    `create_time` datetime     DEFAULT NULL COMMENT '创建时间',
    `update_by`   bigint       DEFAULT NULL COMMENT '更新者',
    `update_time` datetime     DEFAULT NULL COMMENT '更新时间',
    `remark`      varchar(500) DEFAULT NULL COMMENT '备注',
    `group_id`    bigint       DEFAULT NULL COMMENT '知识库角色组id',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_group_id` (`group_id`) USING BTREE,
    KEY `idx_del_flag` (`del_flag`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库角色表';

-- ----------------------------
-- Table structure for knowledge_role_group
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_role_group`;
CREATE TABLE `knowledge_role_group`
(
    `id`          bigint NOT NULL AUTO_INCREMENT COMMENT '知识库角色组id',
    `name`        varchar(100) DEFAULT NULL COMMENT '知识库角色组name',
    `del_flag`    tinyint(1)   DEFAULT 0 COMMENT '删除标志:0存在,1删除',
    `create_by`   bigint       DEFAULT NULL COMMENT '创建者',
    `create_time` datetime     DEFAULT NULL COMMENT '创建时间',
    `update_by`   bigint       DEFAULT NULL COMMENT '更新者',
    `update_time` datetime     DEFAULT NULL COMMENT '更新时间',
    `remark`      varchar(500) DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_del_flag` (`del_flag`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库角色组表';

-- ----------------------------
-- Table structure for knowledge_role_relation
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_role_relation`;
CREATE TABLE `knowledge_role_relation`
(
    `id`                bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
    `del_flag`          tinyint(1)   DEFAULT 0 COMMENT '删除标志:0存在,1删除',
    `create_by`         bigint       DEFAULT NULL COMMENT '创建者',
    `create_time`       datetime     DEFAULT NULL COMMENT '创建时间',
    `update_by`         bigint       DEFAULT NULL COMMENT '更新者',
    `update_time`       datetime     DEFAULT NULL COMMENT '更新时间',
    `remark`            varchar(500) DEFAULT NULL COMMENT '备注',
    `knowledge_role_id` bigint       DEFAULT NULL COMMENT '知识库角色id',
    `knowledge_id`      bigint       DEFAULT NULL COMMENT '知识库id',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_role_id` (`knowledge_role_id`) USING BTREE,
    KEY `idx_knowledge_id` (`knowledge_id`) USING BTREE,
    KEY `idx_del_flag` (`del_flag`) USING BTREE,
    UNIQUE KEY `uk_role_knowledge` (`knowledge_role_id`, `knowledge_id`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库角色与知识库关联表';

-- ----------------------------
-- Table structure for knowledge_vector
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_vector`;
CREATE TABLE `knowledge_vector`
(
    `id`           bigint       NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `knowledge_id` varchar(50)  NOT NULL COMMENT '知识库ID',
    `doc_id`       varchar(50)  NOT NULL COMMENT '文档ID',
    `fragment_id`  varchar(50)  NOT NULL COMMENT '知识片段ID',
    `vector_id`    varchar(100) NOT NULL COMMENT '向量唯一标识',
    `vector_data`  blob         NOT NULL COMMENT '向量数据',
    `dimension`    int          NOT NULL COMMENT '向量维度',
    `model_name`   varchar(50)  NOT NULL COMMENT '向量模型名称',
    `status`       tinyint(1)   NOT NULL DEFAULT 0 COMMENT '状态:0启用,1禁用',
    `create_by`    bigint                DEFAULT NULL COMMENT '创建人',
    `create_time`  datetime              DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`    bigint                DEFAULT NULL COMMENT '更新者',
    `update_time`  datetime              DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `remark`       varchar(500)          DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `idx_vector_id` (`vector_id`) USING BTREE,
    UNIQUE KEY `idx_fragment_unique` (`knowledge_id`, `doc_id`, `fragment_id`) USING BTREE,
    KEY `idx_knowledge_id` (`knowledge_id`) USING BTREE,
    KEY `idx_doc_id` (`doc_id`) USING BTREE,
    KEY `idx_fragment_id` (`fragment_id`) USING BTREE,
    KEY `idx_model_name` (`model_name`) USING BTREE,
    KEY `idx_status` (`status`) USING BTREE,
    KEY `idx_create_time` (`create_time`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识片段向量表';

-- ----------------------------
-- Table structure for knowledge_job
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_job`;
CREATE TABLE `knowledge_job`
(
    `id`              bigint      NOT NULL AUTO_INCREMENT COMMENT '任务ID',
    `job_id`          varchar(50) NOT NULL COMMENT '任务唯一标识',
    `job_type`        varchar(50) NOT NULL COMMENT '任务类型(upload,process,delete,export,embedding,sync)',
    `job_sub_type`    varchar(50)          DEFAULT NULL COMMENT '任务子类型',
    `knowledge_id`    varchar(50)          DEFAULT NULL COMMENT '知识库ID',
    `doc_id`          varchar(50)          DEFAULT NULL COMMENT '文档ID',
    `user_id`         bigint      NOT NULL COMMENT '用户ID',
    `status`          tinyint(1)  NOT NULL DEFAULT 0 COMMENT '任务状态:0等待,1进行中,2成功,3失败,4暂停',
    `progress`        int         NOT NULL DEFAULT 0 COMMENT '进度(0-100)',
    `total_items`     int                  DEFAULT 0 COMMENT '总项目数',
    `processed_items` int                  DEFAULT 0 COMMENT '已处理项目数',
    `success_items`   int                  DEFAULT 0 COMMENT '成功项目数',
    `failed_items`    int                  DEFAULT 0 COMMENT '失败项目数',
    `priority`        tinyint(1)  NOT NULL DEFAULT 1 COMMENT '优先级:1低,2中,3高',
    `retry_count`     int         NOT NULL DEFAULT 0 COMMENT '重试次数',
    `max_retry`       int         NOT NULL DEFAULT 3 COMMENT '最大重试次数',
    `start_time`      datetime             DEFAULT NULL COMMENT '开始时间',
    `end_time`        datetime             DEFAULT NULL COMMENT '结束时间',
    `timeout`         int                  DEFAULT 3600 COMMENT '超时时间(秒)',
    `error_message`   text COMMENT '错误信息',
    `error_stack`     text COMMENT '错误堆栈',
    `result_data`     text COMMENT '结果数据(JSON格式)',
    `notify_url`      varchar(500)         DEFAULT NULL COMMENT '通知URL',
    `notify_status`   tinyint(1)  NOT NULL DEFAULT 0 COMMENT '通知状态:0未通知,1已通知',
    `create_by`       bigint               DEFAULT NULL COMMENT '创建人',
    `create_time`     datetime             DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`       bigint               DEFAULT NULL COMMENT '更新者',
    `update_time`     datetime             DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `remark`          varchar(500)         DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `idx_job_id` (`job_id`) USING BTREE,
    KEY `idx_job_type` (`job_type`) USING BTREE,
    KEY `idx_knowledge_id` (`knowledge_id`) USING BTREE,
    KEY `idx_doc_id` (`doc_id`) USING BTREE,
    KEY `idx_user_id` (`user_id`) USING BTREE,
    KEY `idx_status` (`status`) USING BTREE,
    KEY `idx_priority` (`priority`) USING BTREE,
    KEY `idx_create_time` (`create_time`) USING BTREE,
    KEY `idx_status_create_time` (`status`, `create_time`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识库任务进度表';

-- ----------------------------
-- Table structure for knowledge_hit_log
-- ----------------------------
DROP TABLE IF EXISTS `knowledge_hit_log`;
CREATE TABLE `knowledge_hit_log`
(
    `id`               bigint         NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `session_id`       varchar(50)             DEFAULT NULL COMMENT '会话ID',
    `knowledge_id`     varchar(50)    NOT NULL COMMENT '知识库ID',
    `doc_id`           varchar(50)             DEFAULT NULL COMMENT '文档ID',
    `fragment_id`      varchar(50)    NOT NULL COMMENT '知识片段ID',
    `query_text`       text COMMENT '查询文本',
    `query_vector`     blob COMMENT '查询向量',
    `similarity_score` decimal(10, 6) NOT NULL COMMENT '相似度分数',
    `ranking`          int            NOT NULL COMMENT '排名位置',
    `model_name`       varchar(50)    NOT NULL COMMENT '向量模型名称',
    `search_params`    text COMMENT '搜索参数(JSON格式)',
    `response_time`    int                     DEFAULT 0 COMMENT '响应时间(毫秒)',
    `hit_count`        int            NOT NULL DEFAULT 1 COMMENT '命中次数',
    `create_by`        bigint                  DEFAULT NULL COMMENT '创建人',
    `create_time`      datetime                DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_by`        bigint                  DEFAULT NULL COMMENT '更新者',
    `update_time`      datetime                DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    `remark`           varchar(500)            DEFAULT NULL COMMENT '备注',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_session_id` (`session_id`) USING BTREE,
    KEY `idx_knowledge_id` (`knowledge_id`) USING BTREE,
    KEY `idx_doc_id` (`doc_id`) USING BTREE,
    KEY `idx_fragment_id` (`fragment_id`) USING BTREE,
    KEY `idx_score` (`similarity_score`) USING BTREE,
    KEY `idx_model_name` (`model_name`) USING BTREE,
    KEY `idx_create_time` (`create_time`) USING BTREE,
    KEY `idx_knowledge_fragment` (`knowledge_id`, `fragment_id`) USING BTREE
) ENGINE = InnoDB
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_general_ci COMMENT ='知识检索命中日志表';
