live-forum/server/webapi/LiveForum/DatabaseScripts/AddMessageFields.sql
2026-03-24 11:27:37 +08:00

24 lines
771 B
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.

-- 为 T_Messages 表添加新字段
-- 用于支持消息系统异步化改造
-- 添加消息标题字段
ALTER TABLE T_Messages ADD MessageTitle NVARCHAR(200) NULL;
-- 添加发送者用户信息JSON快照字段
ALTER TABLE T_Messages ADD SenderInfo NVARCHAR(MAX) NULL;
-- 添加事件唯一ID字段用于幂等性检查
ALTER TABLE T_Messages ADD EventId NVARCHAR(50) NULL;
-- 添加关联内容快照JSON字段
ALTER TABLE T_Messages ADD ContentSnapshot NVARCHAR(MAX) NULL;
-- 为 EventId 添加索引以提升幂等性查询性能
CREATE INDEX IX_T_Messages_EventId ON T_Messages(EventId);
-- 说明:
-- 1. 这些字段允许NULL以兼容旧数据
-- 2. EventId索引用于快速查询避免重复消息
-- 3. 执行此脚本前请备份数据库