Files
incidentops/migrations/0003_notification_tables.sql
minhtrannhat 0d99ba0b31 feat: project skeleton
- infra (k8s, kind, helm, docker) backbone is implemented
- security: implementation + unit tests are done
2026-01-21 03:14:09 -05:00

26 lines
882 B
SQL

-- Notification system tables
-- Stores notification targets and delivery attempts
CREATE TABLE notification_targets (
id UUID PRIMARY KEY,
org_id UUID NOT NULL REFERENCES orgs(id),
name TEXT NOT NULL,
target_type TEXT NOT NULL CHECK (target_type IN ('webhook', 'email', 'slack')),
webhook_url TEXT,
enabled BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX idx_notification_targets_org ON notification_targets(org_id);
CREATE TABLE notification_attempts (
id UUID PRIMARY KEY,
incident_id UUID NOT NULL REFERENCES incidents(id),
target_id UUID NOT NULL REFERENCES notification_targets(id),
status TEXT NOT NULL CHECK (status IN ('pending', 'sent', 'failed')),
error TEXT,
sent_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
UNIQUE (incident_id, target_id)
);