-- 系统设置表

CREATE TABLE settings (
    key         text PRIMARY KEY,
    value       jsonb NOT NULL,
    updated_at  timestamptz NOT NULL DEFAULT now()
);

CREATE TRIGGER trg_settings_updated_at
BEFORE UPDATE ON settings
FOR EACH ROW EXECUTE FUNCTION touch_updated_at();

-- 初始化 Telegram 配置
INSERT INTO settings (key, value) VALUES ('telegram', '{
    "enabled": false,
    "bot_token": "",
    "admin_ids": [],
    "notify_chat_id": "",
    "test_interval_minutes": 60,
    "alert_threshold_percent": 50,
    "test_url": "https://httpbin.org/ip",
    "test_timeout_ms": 5000
}'::jsonb);
