feat(store): add incidents, notification channels and delivery outbox
At most one open incident per monitor is enforced by a partial unique index. Refs #15, #16 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
4b4e134bfd
commit
ffef63e586
9 files changed
+770
-11
No files matched your search
@@ -1,11 +1,11 @@
|
||||
-- name: CreateMonitor :one
|
||||
INSERT INTO monitors (org_id, name, type, target, interval_seconds, timeout_ms, config, enabled)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
INSERT INTO monitors (org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, confirmations)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateMonitor :one
|
||||
UPDATE monitors SET name = $2, type = $3, target = $4, interval_seconds = $5,
|
||||
timeout_ms = $6, config = $7, enabled = $8, updated_at = now()
|
||||
timeout_ms = $6, config = $7, enabled = $8, confirmations = $9, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
||||
|
||||
@@ -45,3 +45,12 @@ GROUP BY m.id, m.interval_seconds;
|
||||
SELECT m.* FROM monitors m
|
||||
JOIN monitor_regions r ON r.monitor_id = m.id AND r.region = sqlc.arg(region)
|
||||
WHERE m.id = ANY (sqlc.arg(ids)::uuid[]) AND m.enabled;
|
||||
|
||||
-- name: MonitorsForResults :many
|
||||
-- System scope: monitors a checker of region may report, with every region
|
||||
-- they are assigned to, for evaluation.
|
||||
SELECT m.id, m.org_id, m.name, m.target, m.interval_seconds, m.confirmations,
|
||||
(SELECT array_agg(r2.region ORDER BY r2.region) FROM monitor_regions r2 WHERE r2.monitor_id = m.id)::text[] AS regions
|
||||
FROM monitors m
|
||||
JOIN monitor_regions r ON r.monitor_id = m.id AND r.region = sqlc.arg(region)
|
||||
WHERE m.id = ANY (sqlc.arg(ids)::uuid[]) AND m.enabled;
|
||||
Reference in new issue
Block a user