Files
plates-server/sql-scripts/2025-01-18-medication-ai-summaries-table.sql

21 lines
1.2 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 用药 AI 总结表创建脚本
-- 创建时间: 2025-01-18
-- 说明: 按天存储用户的用药AI总结避免重复调用大模型
CREATE TABLE IF NOT EXISTS `t_medication_ai_summaries` (
`id` varchar(50) NOT NULL COMMENT '唯一标识',
`user_id` varchar(50) NOT NULL COMMENT '用户ID',
`summary_date` date NOT NULL COMMENT '统计日期YYYY-MM-DD',
`medication_analysis` json NOT NULL COMMENT '用药计划与进度统计',
`key_insights` text NOT NULL COMMENT 'AI重点解读',
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uq_user_date` (`user_id`, `summary_date`),
KEY `idx_user_date` (`user_id`, `summary_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用药AI总结表按天缓存';
-- 使用说明:
-- 1) 每位用户每日最多一条记录用于缓存当天的用药AI总结。
-- 2) medication_analysis 字段存储 JSON 数组medicationAnalysis 列表key_insights 存储生成的重点解读文本。