Teamgram Database Schema
by @zhihang9978
Complete database schema reference for Teamgram Server with all 43 tables, ER relationships, and key table structure explanations for the MySQL teamgram data...
clawhub install teamgram-database-schema📖 About This Skill
name: teamgram-database-schema description: Complete database schema reference for Teamgram Server with all 43 tables, ER relationships, and key table structure explanations for the MySQL teamgram database. compatibility: Documentation/knowledge skill only. No executable code. Reference material for Teamgram Server developers. metadata: author: zhihang9978 version: "1.0.0" source: https://github.com/teamgram/teamgram-server homepage: https://github.com/teamgram/teamgram-server openclaw: requires: env: [] bins: [] securityNotes: | Documentation-only skill. Contains no executable code, no network calls, no credential handling. Table names and schema are from the public teamgram-server SQL files. All content references the open-source teamgram-server project (Apache-2.0).
数据库 Schema(43 张表)与核心关系
概述
数据库位于 teamgramd/deploy/sql/,基础 schema 在 1_teamgram.sql(38 表),迁移补齐到 43 表。
所有服务共用同一个 MySQL 数据库 teamgram,字符集 utf8mb4。
43 张表完整列表
| 表名 | 核心用途 | |---|---| | auth_key_infos | auth_key 元信息 | | auth_keys | auth_key 存储(加密密钥) | | auth_seq_updates | 每个 auth_key 的 updates 序列号 | | auth_users | auth_key ↔ user 绑定关系 | | auths | 授权记录 | | bot_commands | Bot 命令列表 | | bots | Bot 信息 | | chat_invite_participants | 通过邀请链接加入的成员 | | chat_invites | 聊天邀请链接 | | chat_participants | 群成员关系 | | chats | 群组信息 | | default_history_ttl | 默认历史消息 TTL | | devices | 推送设备/token | | dialog_filters | 对话文件夹 | | dialogs | 对话列表(每用户每对等方一行) | | documents | 文件/文档元数据 | | drafts | 消息草稿 | | encrypted_files | 加密文件 | | hash_tags | 消息 hashtag 索引 | | imported_contacts | 导入的联系人 | | message_read_outbox | 消息已读状态(outbox 侧) | | messages | 消息存储(核心表) | | phone_books | 通讯录 | | photo_sizes | 照片尺寸变体 | | photos | 照片元数据 | | popular_contacts | 热门联系人 | | predefined_users | 预定义用户 | | saved_dialogs | 保存的消息对话 | | unregistered_contacts | 未注册联系人 | | user_contacts | 用户联系人关系 | | user_global_privacy_settings | 全局隐私设置 | | user_notify_settings | 通知设置 | | user_peer_blocks | 屏蔽关系 | | user_peer_settings | 对等方设置 | | user_presences | 用户最后上线时间 | | user_privacies | 隐私规则 | | user_profile_photos | 用户头像 | | user_pts_updates | 每用户 pts 更新序列 | | user_saved_music | 保存的音乐 | | user_settings | 用户设置 | | username | 用户名 | | users | 用户信息(核心表) | | video_sizes | 视频尺寸变体 |
核心 ER 关系
users (user_id)
|\
| \-- auth_users (auth_key_id -> user_id) # 登录设备/授权关系
| \-- devices (auth_key_id, user_id) # push token / device
| \-- user_presences (user_id) # last seen
| \-- user_profile_photos (user_id -> photo_id)
| \-- user_settings / user_privacies / user_notify_settings
|
\-- dialogs (user_id, peer_type, peer_id) # 会话列表
|
\-- messages (user_id, peer_type, peer_id, dialog_id1/2, dialog_message_id)
|
\-- documents/photos/encrypted_files (+ photo_sizes/video_sizes)chats (chat_id)
\-- chat_participants (chat_id, user_id)
\-- chat_invites / chat_invite_participants
关键表结构说明
users 表
messages 表
dialogs 表
auth_keys / auth_users 表
chat_participants 表
SQL 文件路径
teamgramd/deploy/sql/1_teamgram.sqlteamgramd/deploy/sql/ 下的后续编号文件