| | |
| | | `user_id` bigint(20) NOT NULL COMMENT '用户 ID', |
| | | `tenant_id` bigint(20) DEFAULT NULL COMMENT '租户', |
| | | `last_message_time` datetime DEFAULT NULL COMMENT '最后消息时间', |
| | | `pinned` tinyint(1) DEFAULT '0' COMMENT '是否置顶', |
| | | `status` int(11) DEFAULT '1' COMMENT '状态', |
| | | `deleted` int(11) DEFAULT '0' COMMENT '删除标记', |
| | | `create_time` datetime DEFAULT NULL COMMENT '创建时间', |
| | |
| | | EXECUTE builtin_code_stmt; |
| | | DEALLOCATE PREPARE builtin_code_stmt; |
| | | |
| | | SET @chat_session_pinned_exists := ( |
| | | SELECT COUNT(1) |
| | | FROM `information_schema`.`COLUMNS` |
| | | WHERE `TABLE_SCHEMA` = DATABASE() |
| | | AND `TABLE_NAME` = 'sys_ai_chat_session' |
| | | AND `COLUMN_NAME` = 'pinned' |
| | | ); |
| | | SET @chat_session_pinned_sql := IF( |
| | | @chat_session_pinned_exists = 0, |
| | | 'ALTER TABLE `sys_ai_chat_session` ADD COLUMN `pinned` tinyint(1) DEFAULT ''0'' COMMENT ''是否置顶'' AFTER `last_message_time`', |
| | | 'SELECT 1' |
| | | ); |
| | | PREPARE chat_session_pinned_stmt FROM @chat_session_pinned_sql; |
| | | EXECUTE chat_session_pinned_stmt; |
| | | DEALLOCATE PREPARE chat_session_pinned_stmt; |
| | | |
| | | BEGIN; |
| | | INSERT INTO `sys_ai_prompt` |
| | | (`id`, `name`, `code`, `scene`, `system_prompt`, `user_prompt_template`, `tenant_id`, `status`, `deleted`, `create_time`, `create_by`, `update_time`, `update_by`, `memo`) |