0026_incidents.sql29 lines · main
| 1 | -- 0026_incidents — operator-published platform incident log. |
| 2 | -- Replaces the hand-curated apps/docs/src/lib/incidents.ts array. An |
| 3 | -- admin opens an incident via /dashboard/admin/incidents when something |
| 4 | -- customer-impacting starts, edits the narrative as the situation |
| 5 | -- unfolds, and resolves it when restored. Status page + RSS feed will |
| 6 | -- read from this table in a follow-up consumer turn. |
| 7 | |
| 8 | CREATE TABLE IF NOT EXISTS "incidents" ( |
| 9 | "id" text PRIMARY KEY NOT NULL, |
| 10 | "started_at" timestamp with time zone NOT NULL, |
| 11 | "resolved_at" timestamp with time zone, |
| 12 | "severity" text NOT NULL, |
| 13 | "services" jsonb NOT NULL, |
| 14 | "summary" text NOT NULL, |
| 15 | "postmortem" text DEFAULT '' NOT NULL, |
| 16 | "created_by" text, |
| 17 | "created_at" timestamp with time zone DEFAULT now() NOT NULL, |
| 18 | "updated_at" timestamp with time zone DEFAULT now() NOT NULL, |
| 19 | CONSTRAINT "incidents_created_by_fk" |
| 20 | FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE SET NULL |
| 21 | ); |
| 22 | |
| 23 | CREATE INDEX IF NOT EXISTS "incidents_started_idx" |
| 24 | ON "incidents" USING btree ("started_at"); |
| 25 | |
| 26 | -- Hot path for the public status page: "is anything ongoing right now?" |
| 27 | CREATE INDEX IF NOT EXISTS "incidents_active_idx" |
| 28 | ON "incidents" USING btree ("started_at") |
| 29 | WHERE "resolved_at" IS NULL; |