feat: own incident statuses with a color; incidents before maintenance
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 9m38s
ci / test (pull_request) Successful in 14m21s
ci / build (pull_request) Successful in 16m36s
ci / image (pull_request) Successful in 3m37s

Organizations add statuses of their own, with a name and a color, next
to the built-in ones (Settings, incident statuses; API under
/org/incident-statuses, managed with org.manage). Updates pick them by
ID; the console and status pages show them in their color. Renaming or
recoloring carries into the history; a status in use cannot be deleted
(409 status_in_use). API responses give status "custom" with status_id,
status_name and status_color.

Status pages now list recent incidents before planned maintenance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-23 23:49:58 +01:00
1 parent 43a04e99b1
commit 2409a919c3
26 files changed
+1257 -238

No files matched your search

@@ -0,0 +1,48 @@
-- +goose Up
-- Organizations add statuses of their own, with a color, next to the
-- built-in ones. A status in use cannot be deleted: the history would lose
-- its meaning.
CREATE TABLE incident_statuses (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
org_id uuid NOT NULL REFERENCES orgs (id) ON DELETE CASCADE,
name text NOT NULL CHECK (length(name) BETWEEN 1 AND 40),
color text NOT NULL CHECK (color ~ '^#[0-9a-f]{6}$'),
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (org_id, name)
);
ALTER TABLE incident_statuses ENABLE ROW LEVEL SECURITY;
ALTER TABLE incident_statuses FORCE ROW LEVEL SECURITY;
CREATE POLICY incident_statuses_tenant ON incident_statuses FOR ALL
USING (app_scope_system() OR org_id = app_org_id())
WITH CHECK (app_scope_system() OR org_id = app_org_id());
-- status is a built-in status or 'custom' with status_id naming it.
ALTER TABLE incident_updates DROP CONSTRAINT incident_updates_status_check;
ALTER TABLE incident_updates ADD CONSTRAINT incident_updates_status_check
CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved', 'custom'));
ALTER TABLE incident_updates ADD COLUMN status_id uuid REFERENCES incident_statuses (id) ON DELETE RESTRICT;
ALTER TABLE incident_updates ADD CONSTRAINT incident_updates_custom_status
CHECK ((status = 'custom') = (status_id IS NOT NULL));
ALTER TABLE incidents DROP CONSTRAINT incidents_status_check;
ALTER TABLE incidents ADD CONSTRAINT incidents_status_check
CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved', 'custom'));
ALTER TABLE incidents ADD COLUMN status_id uuid REFERENCES incident_statuses (id) ON DELETE RESTRICT;
ALTER TABLE incidents ADD CONSTRAINT incidents_custom_status
CHECK ((status = 'custom') = (status_id IS NOT NULL));
-- +goose Down
DELETE FROM incident_updates WHERE status = 'custom';
UPDATE incidents SET status = NULL WHERE status = 'custom';
ALTER TABLE incidents DROP CONSTRAINT incidents_custom_status;
ALTER TABLE incidents DROP COLUMN status_id;
ALTER TABLE incidents DROP CONSTRAINT incidents_status_check;
ALTER TABLE incidents ADD CONSTRAINT incidents_status_check
CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved'));
ALTER TABLE incident_updates DROP CONSTRAINT incident_updates_custom_status;
ALTER TABLE incident_updates DROP COLUMN status_id;
ALTER TABLE incident_updates DROP CONSTRAINT incident_updates_status_check;
ALTER TABLE incident_updates ADD CONSTRAINT incident_updates_status_check
CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved'));
DROP TABLE incident_statuses;