0026_incidents.sql 1.2 KB

1234567891011121314151617181920212223242526272829
  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. CREATE TABLE IF NOT EXISTS "incidents" (
  8. "id" text PRIMARY KEY NOT NULL,
  9. "started_at" timestamp with time zone NOT NULL,
  10. "resolved_at" timestamp with time zone,
  11. "severity" text NOT NULL,
  12. "services" jsonb NOT NULL,
  13. "summary" text NOT NULL,
  14. "postmortem" text DEFAULT '' NOT NULL,
  15. "created_by" text,
  16. "created_at" timestamp with time zone DEFAULT now() NOT NULL,
  17. "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
  18. CONSTRAINT "incidents_created_by_fk"
  19. FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE SET NULL
  20. );
  21. CREATE INDEX IF NOT EXISTS "incidents_started_idx"
  22. ON "incidents" USING btree ("started_at");
  23. -- Hot path for the public status page: "is anything ongoing right now?"
  24. CREATE INDEX IF NOT EXISTS "incidents_active_idx"
  25. ON "incidents" USING btree ("started_at")
  26. WHERE "resolved_at" IS NULL;