-- 会话备注字段（个人级别）
ALTER TABLE chat_participants ADD COLUMN remark VARCHAR(128) DEFAULT '' AFTER last_read_at;

-- 快捷回复表
CREATE TABLE IF NOT EXISTS chat_quick_replies (
    id BIGINT PRIMARY KEY AUTO_INCREMENT,
    admin_user_id BIGINT NOT NULL DEFAULT 0 COMMENT '0=全局, >0=个人',
    title VARCHAR(64) NOT NULL COMMENT '快捷回复标题',
    content TEXT NOT NULL COMMENT '回复内容',
    sort_order INT NOT NULL DEFAULT 0 COMMENT '排序',
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    INDEX idx_admin_user_id (admin_user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='快捷回复模板';

-- 建群自动话术配置
INSERT INTO system_configs (`key`, `value`, description) VALUES
('chat.auto_welcome_message', '欢迎加入订单群聊！如有任何问题，请随时沟通。', '建群后自动发送的欢迎话术')
ON DUPLICATE KEY UPDATE description = VALUES(description);
