/**
Source Server Version: 8.0.31
Source Database: backendsys
Date: 2023/05/23 17:09:22
*/

DROP TABLE IF EXISTS `ai_chat_history`;
CREATE TABLE `ai_chat_history` (
    PRIMARY KEY (`id`),
    `id` BIGINT AUTO_INCREMENT COMMENT 'ID',
    `history_code` VARCHAR(36) NOT NULL COMMENT '对话历史记录ID',
    `user_id` BIGINT NOT NULL COMMENT '用户ID',
    `robot_code` VARCHAR(255) COMMENT '机器人CODE',
    `last_prompt` VARCHAR(255) NOT NULL COMMENT '最后一次的对话内容',
    `del_flag` TINYINT(1) DEFAULT '-1' COMMENT '删除标志 (-1未删除, 1删除)',
    `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    UNIQUE KEY `uk_history_code` (`history_code`),
    INDEX `idx_user_id` (`user_id`),
    INDEX `idx_robot_code` (`robot_code`)
) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='AI对话历史记录表';

# INSERT INTO ai_chat_history(history_code, user_id, robot_code, last_content) VALUES
#     ('5670822e-f0f7-4635-b766-c9c61edef0fa', 1, '102348821', '生成一条关于制作蛋糕的文案，适用于家用，用料是纯天然无添加剂，主打绿色健康美味的理念'),
#     ('3e69922c-f0e7-4f82-905d-0b375e09409c', 1, '102348822', '你好'),
#     ('bd55b4e6-9a4b-4904-99cc-b474bc0a86e4', 2, '102020014', 'Hello')
# ;
