chore: initial import
This commit is contained in:
17
tech/migrations/000002_add_notification_logs.up.sql
Normal file
17
tech/migrations/000002_add_notification_logs.up.sql
Normal file
@@ -0,0 +1,17 @@
|
||||
-- 通知日志表
|
||||
CREATE TABLE IF NOT EXISTS ai_ops_notification_logs (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
event_id UUID NOT NULL REFERENCES ai_ops_alerts(id) ON DELETE CASCADE,
|
||||
channel_id UUID NOT NULL REFERENCES ai_ops_channels(id) ON DELETE CASCADE,
|
||||
channel_type VARCHAR(32) NOT NULL,
|
||||
status VARCHAR(16) NOT NULL DEFAULT 'pending'
|
||||
CHECK (status IN ('pending', 'sent', 'failed', 'retrying')),
|
||||
retry_count INT NOT NULL DEFAULT 0,
|
||||
error_message TEXT NULL,
|
||||
sent_at TIMESTAMPTZ NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_notification_logs_event ON ai_ops_notification_logs(event_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_notification_logs_status ON ai_ops_notification_logs(status);
|
||||
CREATE INDEX IF NOT EXISTS idx_notification_logs_created ON ai_ops_notification_logs(created_at DESC);
|
||||
Reference in New Issue
Block a user