feat(db): migration 014 — telegram_users 表
EventRouter 改走 DB 路徑查 admin chat_id, 取代 .env TELEGRAM_CHAT_IDS 硬編碼。 種子: -1003940688311 (EwoooC_Admin_Group, is_admin=true) 已在 188 momo_analytics 執行建表 + 種子植入。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
21
migrations/014_telegram_users.sql
Normal file
21
migrations/014_telegram_users.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- Migration 014: telegram_users 表
|
||||
-- EventRouter 用於查詢 is_admin=true 的推播對象,取代 .env 硬編碼
|
||||
-- 建立日期:2026-04-19
|
||||
|
||||
CREATE TABLE IF NOT EXISTS telegram_users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
telegram_id BIGINT NOT NULL UNIQUE, -- Telegram chat_id(群組為負數)
|
||||
username VARCHAR(100), -- 顯示名稱(方便辨識)
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
is_admin BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
note TEXT,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_tg_users_admin_active ON telegram_users(is_admin, is_active);
|
||||
|
||||
-- 種子:EwoooC 管理群組(從 .env OPENCLAW_GROUP_ID 遷移)
|
||||
INSERT INTO telegram_users (telegram_id, username, is_active, is_admin, note)
|
||||
VALUES (-1003940688311, 'EwoooC_Admin_Group', true, true, '主要告警群組,原 OPENCLAW_GROUP_ID')
|
||||
ON CONFLICT (telegram_id) DO NOTHING;
|
||||
Reference in New Issue
Block a user