Files
affiliate_dash/backend/internal/database/migrations/004_alert_channels.sql
T
yml2213 ca58c2bcaa 余额告警独立页面与多渠道通知:钉钉/飞书/企业微信/Bark,支持通知频率策略
- 告警设置拆分为独立页面,支持钉钉/飞书/企业微信/Bark/通用Webhook 多渠道
- 通知策略:低于阈值后按间隔重复提醒,达到最大次数停止,余额恢复自动重置
- 旧 webhook 配置自动迁移为通用渠道,渠道支持测试发送
- 优化告警话术:去商户ID展示、数字千分位格式化
2026-08-04 13:56:26 +08:00

25 lines
1.1 KiB
SQL
Raw 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.
-- ============================================================================
-- 余额告警通知渠道(支持钉钉 / 飞书 / 企业微信 / Bark / 通用 Webhook
-- ============================================================================
CREATE TABLE IF NOT EXISTS alert_notify_channels (
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
deleted_at TIMESTAMPTZ,
merchant_id BIGINT NOT NULL,
channel_type VARCHAR(32) NOT NULL,
name VARCHAR(64) NOT NULL DEFAULT '',
config TEXT NOT NULL DEFAULT '{}',
enabled BOOLEAN NOT NULL DEFAULT true
);
CREATE INDEX IF NOT EXISTS idx_alert_notify_channels_merchant ON alert_notify_channels (merchant_id);
-- 历史 merchant_alert_configs.webhook_url 迁移为通用 webhook 渠道
INSERT INTO alert_notify_channels (merchant_id, channel_type, name, config, enabled)
SELECT merchant_id, 'webhook', '原 Webhook', json_build_object('webhook_url', webhook_url), true
FROM merchant_alert_configs
WHERE webhook_url <> ''
ON CONFLICT DO NOTHING;