The admin panel lists every published status page, and every suspended page, organization or account, with the organization and owner behind it, searchable by title, address, organization or email. Each can be suspended with a reason, reinstated, or deleted. A suspended page is not served; status page servers drop it when they next ask. A suspended organization's monitors leave the schedule, its pages go offline, heartbeat pings and Alertmanager webhooks are no longer recorded, and its members and API tokens get 403 org_suspended; the console explains why. Reinstating restarts heartbeat waits so they do not fire at once. A suspended account is signed out everywhere and can neither sign in nor use its tokens; only someone who knows the password learns of the suspension. Platform admins cannot be suspended or deleted. Account deletion shares its logic with the GDPR erasure, including the refusal while the account owns shared organizations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
96 lines
3.1 KiB
SQL
96 lines
3.1 KiB
SQL
-- name: CreateStatusPage :one
|
|
INSERT INTO status_pages (org_id, slug, title, description, published, show_component_details, domain_token, theme)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
RETURNING *;
|
|
|
|
-- name: UpdateStatusPage :one
|
|
UPDATE status_pages
|
|
SET slug = $2,
|
|
title = $3,
|
|
description = $4,
|
|
published = $5,
|
|
show_component_details = $6,
|
|
theme = $7,
|
|
updated_at = now()
|
|
WHERE id = $1
|
|
RETURNING *;
|
|
|
|
-- name: SetStatusPageDomain :one
|
|
-- Changing the domain drops a previous verification.
|
|
UPDATE status_pages SET
|
|
custom_domain = sqlc.narg(custom_domain),
|
|
domain_verified_at = CASE WHEN custom_domain IS NOT DISTINCT FROM sqlc.narg(custom_domain) THEN domain_verified_at END,
|
|
updated_at = now()
|
|
WHERE id = sqlc.arg(id)
|
|
RETURNING *;
|
|
|
|
-- name: MarkDomainVerified :exec
|
|
UPDATE status_pages SET domain_verified_at = now() WHERE id = $1;
|
|
|
|
-- name: GetStatusPage :one
|
|
SELECT * FROM status_pages WHERE id = $1;
|
|
|
|
-- name: ListStatusPages :many
|
|
SELECT * FROM status_pages ORDER BY title;
|
|
|
|
-- name: DeleteStatusPage :execrows
|
|
DELETE FROM status_pages WHERE id = $1;
|
|
|
|
-- name: StatusPageMonitors :many
|
|
SELECT spm.monitor_id, spm.section, spm.group_id, spm.label, spm.position,
|
|
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id
|
|
FROM status_page_monitors spm
|
|
JOIN monitors m ON m.id = spm.monitor_id
|
|
WHERE spm.page_id = $1
|
|
ORDER BY spm.position, m.name;
|
|
|
|
-- name: ClearStatusPageMonitors :exec
|
|
DELETE FROM status_page_monitors WHERE page_id = $1;
|
|
|
|
-- name: AddStatusPageMonitor :exec
|
|
INSERT INTO status_page_monitors (page_id, monitor_id, org_id, section, group_id, label, position)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7);
|
|
|
|
-- name: SetStatusPageMonitorGroup :exec
|
|
UPDATE status_page_monitors SET group_id = $3, section = $4
|
|
WHERE page_id = $1 AND monitor_id = $2;
|
|
|
|
-- name: ListStatusPageGroups :many
|
|
SELECT * FROM status_page_groups
|
|
WHERE page_id = $1
|
|
ORDER BY position, name, id;
|
|
|
|
-- name: CreateStatusPageGroup :one
|
|
INSERT INTO status_page_groups (page_id, org_id, parent_id, name, position)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
RETURNING *;
|
|
|
|
-- name: UpdateStatusPageGroup :one
|
|
UPDATE status_page_groups
|
|
SET name = $3, parent_id = $4, position = $5, updated_at = now()
|
|
WHERE id = $1 AND page_id = $2
|
|
RETURNING *;
|
|
|
|
-- name: ReparentStatusPageGroupChildren :exec
|
|
UPDATE status_page_groups SET parent_id = $3, updated_at = now()
|
|
WHERE page_id = $1 AND parent_id = $2;
|
|
|
|
-- name: ReparentStatusPageGroupMonitors :exec
|
|
UPDATE status_page_monitors SET group_id = $3
|
|
WHERE page_id = $1 AND group_id = $2;
|
|
|
|
-- name: DeleteStatusPageGroup :execrows
|
|
DELETE FROM status_page_groups WHERE id = $1 AND page_id = $2;
|
|
|
|
-- name: ClearStatusPageGroups :exec
|
|
DELETE FROM status_page_groups WHERE page_id = $1;
|
|
|
|
-- name: FindPublishedPage :one
|
|
-- System scope: resolves a request to a page by verified custom domain or
|
|
-- by slug.
|
|
SELECT * FROM status_pages
|
|
WHERE published AND suspended_at IS NULL
|
|
AND NOT EXISTS (SELECT 1 FROM orgs o WHERE o.id = status_pages.org_id AND o.suspended_at IS NOT NULL)
|
|
AND ((sqlc.narg(host)::citext IS NOT NULL AND custom_domain = sqlc.narg(host) AND domain_verified_at IS NOT NULL)
|
|
OR (sqlc.narg(slug)::citext IS NOT NULL AND slug = sqlc.narg(slug)));
|