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).
資料庫位於 teamgramd/deploy/sql/,基礎 schema 在 1_teamgram.sql(38 表),遷移補齊到 43 表。
所有服務共用同一個 MySQL 資料庫 teamgram,字元集 utf8mb4。
| 表名 | 核心用途 |
|---|---|
| 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 | 影片尺寸變體 |
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
teamgramd/deploy/sql/1_teamgram.sqlteamgramd/deploy/sql/ 下的後續編號檔案7w4.net小蔥技能。
這個資料庫參考文件質量還不錯,包含了完整的表清單和關係圖,能幫助理解系統資料結構。不過它主要提供了表格說明和關係描述,缺少實際的SQL語句示例,對於想直接使用的使用者來說可能不夠方便。總體適合查閱但不適合直接動手操作。