feat(store): add nested monitor groups
A trigger rejects cycles and nesting deeper than eight levels; composite foreign keys keep groups and their monitors in one organization. Refs #57 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
6e2f8d0626
commit
2d7f326d38
7 files changed
+306
-11
No files matched your search
@@ -0,0 +1,29 @@
|
||||
-- name: CreateGroup :one
|
||||
INSERT INTO monitor_groups (org_id, parent_id, name) VALUES ($1, $2, $3)
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateGroup :one
|
||||
UPDATE monitor_groups SET name = $2, parent_id = $3, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetGroup :one
|
||||
SELECT * FROM monitor_groups WHERE id = $1;
|
||||
|
||||
-- name: ListGroups :many
|
||||
SELECT * FROM monitor_groups ORDER BY name;
|
||||
|
||||
-- name: ReparentGroups :exec
|
||||
-- Moves the subgroups of a group that is about to be deleted.
|
||||
UPDATE monitor_groups SET parent_id = sqlc.narg(new_parent), updated_at = now()
|
||||
WHERE parent_id = sqlc.arg(old_parent);
|
||||
|
||||
-- name: RegroupMonitors :exec
|
||||
UPDATE monitors SET group_id = sqlc.narg(new_group), updated_at = now()
|
||||
WHERE group_id = sqlc.arg(old_group);
|
||||
|
||||
-- name: DeleteGroup :execrows
|
||||
DELETE FROM monitor_groups WHERE id = $1;
|
||||
|
||||
-- name: DeleteAssignmentsForResource :exec
|
||||
DELETE FROM role_assignments WHERE resource_type = $1 AND resource_id = $2;
|
||||
@@ -1,11 +1,11 @@
|
||||
-- name: CreateMonitor :one
|
||||
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)
|
||||
INSERT INTO monitors (org_id, name, type, target, interval_seconds, timeout_ms, config, enabled, confirmations, group_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateMonitor :one
|
||||
UPDATE monitors SET name = $2, type = $3, target = $4, interval_seconds = $5,
|
||||
timeout_ms = $6, config = $7, enabled = $8, confirmations = $9, updated_at = now()
|
||||
timeout_ms = $6, config = $7, enabled = $8, confirmations = $9, group_id = $10, updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
||||
|
||||
|
||||
Reference in new issue
Block a user