Files
2025-12-03 15:48:44 +08:00

25 lines
1.1 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.
-- 消息记录表 SQL
-- 创建数据库(如果不存在)
CREATE DATABASE IF NOT EXISTS wechat_bot DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE wechat_bot;
-- 消息表
CREATE TABLE IF NOT EXISTS messages (
id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '消息ID',
sender_wxid VARCHAR(100) NOT NULL COMMENT '发送者wxid',
nickname VARCHAR(100) DEFAULT '' COMMENT '发送者昵称',
avatar_url VARCHAR(500) DEFAULT '' COMMENT '发送者头像URL',
content TEXT COMMENT '消息内容',
msg_type VARCHAR(20) NOT NULL COMMENT '消息类型: text/image/voice/video/file',
is_group TINYINT(1) DEFAULT 0 COMMENT '是否群聊: 0=私聊, 1=群聊',
group_id VARCHAR(100) DEFAULT NULL COMMENT '群组ID群聊时有值',
create_time DATETIME NOT NULL COMMENT '消息时间',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '记录创建时间',
INDEX idx_sender (sender_wxid),
INDEX idx_group (group_id),
INDEX idx_time (create_time),
INDEX idx_type (msg_type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='微信消息记录表';