diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d344f86..19d7c9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,6 +148,9 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + # load:true (PR path) cannot export manifest lists. Provenance/SBOM + # attestations produce multi-artifact images, so only enable them on + # push where we publish to the registry instead of loading locally. - uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 id: build with: @@ -160,8 +163,8 @@ jobs: org.opencontainers.image.title=Muster org.opencontainers.image.description=Shared workspace for human and agent-driven security operations org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} - provenance: mode=max - sbom: true + provenance: ${{ github.event_name == 'push' && 'mode=max' || false }} + sbom: ${{ github.event_name == 'push' }} cache-from: type=gha cache-to: type=gha,mode=max - name: Scan built image with Trivy diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 13febb7..a79ec2e 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -67,17 +67,20 @@ jobs: scanners: vuln exit-code: "1" - uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0 + if: always() with: image: muster:security format: cyclonedx-json output-file: muster-sbom.cdx.json upload-artifact: false - name: Generate provenance metadata and checksums + if: always() run: | printf '{"commit":"%s","workflow":"%s","runId":"%s","image":"muster:security"}\n' \ "$GITHUB_SHA" "$GITHUB_WORKFLOW" "$GITHUB_RUN_ID" > provenance.json sha256sum muster-sbom.cdx.json provenance.json > SHA256SUMS - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + if: always() with: name: security-artifacts path: | @@ -85,3 +88,4 @@ jobs: provenance.json SHA256SUMS trivy.sarif + if-no-files-found: ignore diff --git a/apps/mcp-server/package.json b/apps/mcp-server/package.json new file mode 100644 index 0000000..764d143 --- /dev/null +++ b/apps/mcp-server/package.json @@ -0,0 +1,28 @@ +{ + "name": "@muster/mcp-server", + "version": "0.1.0", + "private": true, + "type": "module", + "scripts": { + "dev": "tsx watch src/index.ts", + "build": "tsc -p tsconfig.json", + "start": "node dist/index.js", + "typecheck": "tsc --noEmit", + "lint": "tsc --noEmit", + "test": "vitest run" + }, + "dependencies": { + "@modelcontextprotocol/sdk": "1.30.0", + "@muster/config": "workspace:*", + "@muster/database": "workspace:*", + "@muster/mcp": "workspace:*", + "drizzle-orm": "catalog:", + "zod": "4.4.3" + }, + "devDependencies": { + "@types/node": "^24.0.0", + "tsx": "^4.20.6", + "typescript": "catalog:", + "vitest": "4.1.10" + } +} diff --git a/apps/mcp-server/src/health.test.ts b/apps/mcp-server/src/health.test.ts new file mode 100644 index 0000000..e4dbfcd --- /dev/null +++ b/apps/mcp-server/src/health.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it } from "vitest"; +import { checkDatabaseHealth } from "./health.ts"; + +describe("checkDatabaseHealth", () => { + it("is ready when the database responds", async () => { + const db = { execute: async () => undefined } as never; + expect(await checkDatabaseHealth(db)).toBe(true); + }); + + it("is not ready when the database is unreachable", async () => { + const db = { + execute: async () => { + throw new Error("connection refused"); + }, + } as never; + expect(await checkDatabaseHealth(db)).toBe(false); + }); +}); diff --git a/apps/mcp-server/src/health.ts b/apps/mcp-server/src/health.ts new file mode 100644 index 0000000..a2fe677 --- /dev/null +++ b/apps/mcp-server/src/health.ts @@ -0,0 +1,18 @@ +import { sql } from "drizzle-orm"; +import type { database } from "@muster/database"; + +/** + * A real dependency-aware readiness check, not a static liveness stub: a + * Postgres outage must surface as a non-ready response, not a false-positive + * "ready" that orchestrators route traffic to anyway. + */ +export async function checkDatabaseHealth( + db: ReturnType, +): Promise { + try { + await db.execute(sql`select 1`); + return true; + } catch { + return false; + } +} diff --git a/apps/mcp-server/src/index.ts b/apps/mcp-server/src/index.ts new file mode 100644 index 0000000..1402e48 --- /dev/null +++ b/apps/mcp-server/src/index.ts @@ -0,0 +1,102 @@ +import { randomUUID } from "node:crypto"; +import { + createServer, + type IncomingMessage, + type ServerResponse, +} from "node:http"; +import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js"; +import type { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; +import { redactObservationText } from "@muster/config"; +import { closeDatabase, database } from "@muster/database"; +import { createMusterMcpServer, resolveInstallation } from "@muster/mcp"; +import { checkDatabaseHealth } from "./health.ts"; +import { gracefulShutdown } from "./shutdown.ts"; + +const db = database(); + +function bearerToken(header: string | undefined): string | null { + if (!header?.startsWith("Bearer ")) return null; + const token = header.slice("Bearer ".length).trim(); + return token.length > 0 ? token : null; +} + +function requestTraceId(request: IncomingMessage): string { + const header = request.headers["x-trace-id"]; + const value = Array.isArray(header) ? header[0] : header; + return redactObservationText(value ?? randomUUID(), { maxStringLength: 200 }); +} + +function respondJson(response: ServerResponse, status: number, body: unknown) { + response.writeHead(status, { "content-type": "application/json" }); + response.end(JSON.stringify(body)); +} + +const server = createServer(async (request, response) => { + const url = new URL(request.url ?? "/", "http://mcp-server.local"); + + if (request.method === "GET" && url.pathname === "/health") { + const healthy = await checkDatabaseHealth(db); + respondJson(response, healthy ? 200 : 503, { + status: healthy ? "ready" : "not_ready", + authority: "postgresql", + }); + return; + } + + if (url.pathname !== "/mcp") { + respondJson(response, 404, { error: "Not found" }); + return; + } + + // A missing, malformed, revoked, or cross-organisation credential all fail + // the same way here: a generic 401 that never reveals which case applied. + const token = bearerToken(request.headers.authorization); + const context = token ? await resolveInstallation(db, token) : null; + if (!context) { + respondJson(response, 401, { error: "Unauthorised" }); + return; + } + + const mcpServer = createMusterMcpServer({ + db, + context, + traceId: requestTraceId(request), + }); + // Omitting `sessionIdGenerator` (rather than setting it to `undefined`) + // selects stateless mode under `exactOptionalPropertyTypes`; every request + // is authorised independently by its own bearer token regardless. + const transport = new StreamableHTTPServerTransport({}); + response.on("close", () => void transport.close()); + try { + // The installed SDK's concrete transport class types `onclose`/`onerror` + // as `(() => void) | undefined` while `Transport` declares them as + // optional `() => void`; those are equivalent at runtime but disagree + // under `exactOptionalPropertyTypes`, hence the assertion. + await mcpServer.connect(transport as unknown as Transport); + await transport.handleRequest(request, response); + } catch (error) { + console.error( + "mcp.request.failed", + redactObservationText(error instanceof Error ? error.message : "unknown"), + ); + if (!response.headersSent) + respondJson(response, 500, { error: "Request failed" }); + } +}); + +// Kelpie tool calls poll for up to KELPIE_POLL_OPTIONS.timeoutMs (8s) inside +// the request; these bound the socket/request lifecycle around that with +// headroom, so a burst of concurrent bounded polls can't hold connections +// open indefinitely instead of being bounded like everything else here. +server.requestTimeout = 15_000; +server.headersTimeout = 12_000; +server.keepAliveTimeout = 5_000; + +server.listen(Number(process.env.MCP_SERVER_PORT ?? 3003), "0.0.0.0"); + +async function shutdown() { + await gracefulShutdown(server, closeDatabase); +} + +process.once("SIGINT", () => void shutdown()); +process.once("SIGTERM", () => void shutdown()); diff --git a/apps/mcp-server/src/shutdown.test.ts b/apps/mcp-server/src/shutdown.test.ts new file mode 100644 index 0000000..c206d14 --- /dev/null +++ b/apps/mcp-server/src/shutdown.test.ts @@ -0,0 +1,37 @@ +import { describe, expect, it } from "vitest"; +import { gracefulShutdown } from "./shutdown.ts"; + +describe("gracefulShutdown", () => { + it("closes the database only after the server finishes draining", async () => { + const events: string[] = []; + const server = { + close: (callback: (error?: Error) => void) => { + setTimeout(() => { + events.push("server.closed"); + callback(); + }, 10); + }, + }; + const closeDb = async () => { + events.push("db.closed"); + }; + await gracefulShutdown(server, closeDb); + expect(events).toEqual(["server.closed", "db.closed"]); + }); + + it("propagates a server close error instead of closing the database", async () => { + const server = { + close: (callback: (error?: Error) => void) => { + callback(new Error("close failed")); + }, + }; + let dbClosed = false; + const closeDb = async () => { + dbClosed = true; + }; + await expect(gracefulShutdown(server, closeDb)).rejects.toThrow( + "close failed", + ); + expect(dbClosed).toBe(false); + }); +}); diff --git a/apps/mcp-server/src/shutdown.ts b/apps/mcp-server/src/shutdown.ts new file mode 100644 index 0000000..8e8fba7 --- /dev/null +++ b/apps/mcp-server/src/shutdown.ts @@ -0,0 +1,20 @@ +export interface CloseableServer { + close(callback: (error?: Error) => void): unknown; +} + +/** + * `server.close()` is asynchronous: it stops accepting new connections but + * existing keep-alive requests continue until it emits its completion + * callback. Closing the database pool before that drain completes can tear + * it down under an in-flight MCP tool call (including its audit write), on + * every SIGTERM/rolling deploy. Await the callback first. + */ +export async function gracefulShutdown( + server: CloseableServer, + closeDb: () => Promise, +): Promise { + await new Promise((resolve, reject) => { + server.close((error) => (error ? reject(error) : resolve())); + }); + await closeDb(); +} diff --git a/apps/mcp-server/tsconfig.json b/apps/mcp-server/tsconfig.json new file mode 100644 index 0000000..2a33e2b --- /dev/null +++ b/apps/mcp-server/tsconfig.json @@ -0,0 +1,5 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { "rootDir": "src", "outDir": "dist" }, + "include": ["src/**/*.ts"] +} diff --git a/apps/web/components/room-view.tsx b/apps/web/components/room-view.tsx index 74779c8..6e5acb3 100644 --- a/apps/web/components/room-view.tsx +++ b/apps/web/components/room-view.tsx @@ -64,13 +64,13 @@ type TimelineItem = (typeof roomTimeline)[number]; type ThreadParent = TimelineItem | RoomMessageRecord; const persistedTimelineIds = new Set([ - "018f55d8-c4c7-7c3e-88ef-000000000701", - "018f55d8-c4c7-7c3e-88ef-000000000705", + "019e7a10-0000-7000-8000-000000000701", + "019e7a10-0000-7000-8000-000000000705", ]); const seededThreadMessageIds = new Set([ - "018f55d8-c4c7-7c3e-88ef-000000000702", - "018f55d8-c4c7-7c3e-88ef-000000000703", - "018f55d8-c4c7-7c3e-88ef-000000000704", + "019e7a10-0000-7000-8000-000000000702", + "019e7a10-0000-7000-8000-000000000703", + "019e7a10-0000-7000-8000-000000000704", ]); const actorIdentity: Record< string, diff --git a/docs/architecture/0005-remote-mcp-server.md b/docs/architecture/0005-remote-mcp-server.md new file mode 100644 index 0000000..c7454e3 --- /dev/null +++ b/docs/architecture/0005-remote-mcp-server.md @@ -0,0 +1,129 @@ +# ADR 0005: Remote Muster MCP server for Hermes + +Status: accepted + +## Context + +The product direction changed: Muster is no longer a conversational agent +harness or chat UI. Hermes owns sessions, models, memory, delegation, and +Slack delivery. Muster becomes the authenticated governed control plane +Hermes calls into. The first vertical slice must prove that boundary with a +real remote MCP endpoint, revocable server-side credentials scoped to one +organisation, and read-only Kelpie access routed through the existing +governed connector path — without restoring the retired agent runtime, chat +UI, or Slack gateway. + +## Decision + +`apps/mcp-server` is a new, minimal raw `node:http` app (the same shape as +`apps/agent-gateway`/`apps/worker`, not a second copy of either) that speaks +MCP Streamable HTTP (`@modelcontextprotocol/sdk`, already a pinned +dependency via `packages/agent-harness`). It is deliberately not folded into +`apps/agent-gateway`: that app is the Codex agent-run runtime this slice +must not touch, and folding the two together would blur exactly the +boundary this ADR exists to draw. + +`packages/mcp` holds the domain logic and has no HTTP framework dependency: + +- **Installation credentials** (`mcp_installations`, modelled on the + existing `slack_installations` shape): a random bearer token is hashed + (SHA-256) at rest; only the hash and a short non-secret prefix are stored. + Each row binds to exactly one organisation and one "policy subject" actor + whose `capabilityAssignments` are re-read fresh on every request — the + same `AuthorisationSubject`/`requireCapability` model every other domain + service already uses. Revocation sets `status`/`revokedAt` and is + effective on the next request; every failure path (unknown, malformed, + revoked, or organisation-mismatched token, or a deactivated bound actor) + returns the same generic denial, never distinguishing "does not exist" + from "not authorised." +- **Tool scope**: an installation additionally carries a `scopes` allow-list + of tool names, enforced independently of capability. No tool schema + accepts an organisation id, actor id, or capability — there is nothing + for a model-supplied argument to override. +- **Kelpie access reuses the existing governed connector path exactly**: + `packages/mcp/src/kelpie-gateway.ts` inserts the same + `integration_query_runs` row shape, the same audit event, and the same + outbox row (`queueName: "muster-integrations"`, + `eventType: "connector.query.queued"`) that + `apps/web/lib/connector-domain.ts`'s `queueQuery()` already writes. The + unmodified `apps/worker` BullMQ processor picks it up, decrypts the + connector credential, and calls the same `executeGovernedQuery` (DNS + pinning, SSRF/redirect denial, schema-validated request/response, + `redactUntrusted` before persistence) as every other connector. The MCP + tool call polls the authoritative row for a bounded window (8s) rather + than blocking indefinitely; a still-processing run returns a `timeout` + error, not a hang. No second execution path is introduced. +- **Output handling**: every Kelpie result is wrapped + `classification: "untrusted_evidence"`, bounded to 25 records, with + oversized strings truncated and secret-shaped keys/values redacted a + second time at the tool boundary (on top of the redaction the worker + already applies before persistence). +- **Invocation/audit records** reuse the existing hash-chained + `audit_events` table (`appendAuditEvent`) rather than a new table: one + `mcp.tool.invoked` event per call, carrying tool name, tool version, + installation id, outcome, a SHA-256 hash of the returned payload, and + evidence references (query run ids). No prompt, argument text, or model + reasoning is ever written to it. A failure to write that event is logged + (`mcp.audit.write_failed`), not silently swallowed, so an audit gap is + detectable rather than invisible. +- **Actor/organisation integrity for installation lifecycle mutations**: + `createInstallation`/`revokeInstallation` re-derive the acting actor's + organisation membership and `administration.manage` capability from the + database inside the same transaction as the mutation — never trusted from + the caller — and a composite foreign key + (`(actor_id, organisation_id) -> actors(id, organisation_id)`, backed by a + new `actors_id_organisation_unique` index) makes a cross-organisation actor + binding impossible at the schema level too, as defence in depth. + Provisioning a credential is still not gated behind a multi-party approval + record; see "Deferred" below. +- **Reliability hardening**: the HTTP server drains in-flight requests + (awaits `server.close()`'s callback) before closing the database pool on + shutdown; `/health` performs a real `select 1` against Postgres rather + than a static stub; `requestTimeout`/`headersTimeout`/`keepAliveTimeout` + are set explicitly (with headroom over the 8s Kelpie poll bound) so a + burst of concurrent bounded polls can't hold connections open + indefinitely; and `@muster/database`'s pool now has an `error` listener — + without one, an idle-client error (the database restarting) is an + unhandled Node `'error'` event that crashes the whole process, which is + exactly what a dependency-aware health check will provoke during any real + outage. + +## Deferred + +Two review findings described genuine architectural tensions rather than +bugs, and are deliberately not addressed by a larger protocol change in this +vertical slice: + +- **Kelpie tool calls poll inside the HTTP request handler for up to 8s.** + This is in tension with "keep long-running integration work out of + request handlers," but MCP's tool-call contract in this SDK is + synchronous request/response — returning immediately would mean either a + second "fetch the result" tool (expanding the four-tool contract this + issue specifies) or adopting the SDK's experimental async-tasks surface. + Both are a real protocol-shape decision for a later slice, not a small + fix. The request/socket timeouts above bound the resource cost in the + meantime. +- **The per-integration rate-limit check is a soft limit**, not a hard + concurrency-safe one: it now runs inside the same transaction and under + an advisory lock scoped to the integration (mirroring + `appendAuditEvent`'s org-scoped lock), which closes the read-then-insert + race that existed before. A determined caller opening many concurrent + connections could still contend on that lock rather than being rejected + outright; a dedicated token-bucket limiter would be a heavier addition + reserved for if Kelpie rate limits become an operational problem in + practice. + +## Consequences + +Hermes gets exactly four stable, schema-validated read-only tools +(`muster_get_status`, `muster_list_capabilities`, +`muster_search_kelpie_cases`, `muster_get_kelpie_case`) and a starter skill +(`skills/muster-soc-operations/SKILL.md`) describing how to use them safely. +Provisioning is deliberately not a chat- or UI-driven flow in this slice — +an operator runs `pnpm --filter @muster/mcp create-installation` / +`revoke-installation` directly, which is consistent with "no arbitrary MCP +registration from chat" and "no broad administration UI" for a first slice. +A future write/approval-bearing slice (tracker item 2) can extend +`packages/mcp` with additional tools and idempotency-keyed action requests +using the same installation/capability model, without changing this ADR's +credential or connector-routing decisions. diff --git a/docs/integrations/README.md b/docs/integrations/README.md index 0fdb633..3e17dab 100644 --- a/docs/integrations/README.md +++ b/docs/integrations/README.md @@ -3,6 +3,7 @@ Connector clients use stable HTTP APIs, scoped credentials, timeouts, retries, delivery records, idempotency keys, and signed MSEP webhooks. Webhooks are preferred; polling cursors provide recovery. - [Current Kelpie, Tawny, and Bower contracts](current-upstream-contracts.md) +- [Connecting Hermes to the remote Muster MCP endpoint](hermes-mcp.md) - **Kelpie:** case read/create/update, observables, evidence references, tasks, playbooks, and timeline. Kelpie remains authoritative. - **Tawny:** endpoint inventory, alerts, telemetry search, hunts, agent health, and approval-gated bounded response. Tawny remains authoritative for endpoint state. - **Bower:** collector/source coverage, queue pressure, policy decisions, delivery failures, canary evidence, and approval-gated policy publication. Bower remains authoritative for collection and delivery evidence. diff --git a/docs/integrations/hermes-mcp.md b/docs/integrations/hermes-mcp.md new file mode 100644 index 0000000..568b2df --- /dev/null +++ b/docs/integrations/hermes-mcp.md @@ -0,0 +1,112 @@ +# Connecting Hermes to the remote Muster MCP endpoint + +Muster exposes a remote [Streamable HTTP](https://modelcontextprotocol.io) +MCP endpoint at `apps/mcp-server`. It is the only way Hermes reaches Muster +in this slice: there is no chat UI, no Slack gateway, and no general +administration surface to connect to instead. + +```mermaid +flowchart LR + Slack --> Hermes + Hermes -- "Bearer \nStreamable HTTP" --> MusterMCP["Muster MCP endpoint"] + MusterMCP --> Postgres[(PostgreSQL)] + MusterMCP -- "governed connector path\n(queue -> worker -> Kelpie)" --> Kelpie +``` + +## What Muster stores, what Hermes never sees + +- Muster stores one row per installation credential (`mcp_installations`): + hashed token, the organisation it is bound to, the actor whose + capabilities govern it, and its tool scopes. The plaintext token is shown + once at creation time and is not recoverable. +- Muster stores Kelpie connector credentials encrypted at rest and never + returns them, or any header/field matching a secret-shaped key, in a tool + result. Kelpie itself remains authoritative for case content. +- Hermes never supplies an organisation id, actor id, or capability in a + tool call. Those fields do not exist in any of the four tool schemas; the + installation token is the only source of tenant identity, resolved + server-side on every request. + +## Provisioning an installation credential + +There is no chat- or UI-driven registration flow — an operator provisions a +credential directly against Muster's database. `--installed-by` (defaulting +to `--actor` if omitted) must be an actor holding `administration.manage` in +this organisation — re-checked server-side on every create/revoke call, not +merely at the CLI layer — and `--actor` (the credential's bound, policy +subject actor) must belong to the same organisation. Both are typically a +low-privilege service actor scoped only to the capabilities Hermes needs +(e.g. `kelpie.cases.read`), installed by a human administrator: + +```bash +pnpm --filter @muster/mcp create-installation \ + --org= \ + --actor= \ + --installed-by= \ + --name="Hermes production" +``` + +This prints the installation id and the plaintext token once. Store the +token in Hermes's secret storage immediately; Muster only ever stores its +SHA-256 hash afterward. + +To revoke a credential (immediate, fail-closed on the next call; `--actor` +here must likewise hold `administration.manage`): + +```bash +pnpm --filter @muster/mcp revoke-installation \ + --org= \ + --installation= \ + --actor= +``` + +## Configuring Hermes + +Configure Hermes's MCP client with the endpoint URL and the installation +token as a bearer credential. Placeholders only — never commit a real token: + +```json +{ + "mcpServers": { + "muster": { + "url": "https:///mcp", + "transport": "streamable-http", + "headers": { + "authorization": "Bearer " + } + } + } +} +``` + +`GET /health` on the same host is unauthenticated and reports readiness only +(no tenant data). + +## Tools + +- `muster_get_status` — organisation-scoped Muster and Kelpie connector + status. +- `muster_list_capabilities` — capabilities and tools authorised for this + installation. +- `muster_search_kelpie_cases` — bounded, classified Kelpie case search + through the governed connector path. +- `muster_get_kelpie_case` — one Kelpie case by id, same bounding and + classification. + +All four are read-only. There is no write, destructive, or +external-communication tool in this slice; see +[skills/muster-soc-operations/SKILL.md](../../skills/muster-soc-operations/SKILL.md) +for the Hermes-side usage contract, evidence handling rules, and refusal +boundaries. + +## Failure modes + +Missing, malformed, revoked, and cross-organisation credentials all fail +the same way: an unauthenticated `401` that never reveals which case +applied. Kelpie query results are bounded (25 records) and truncation is +reported in the response rather than silently dropped. + +Connector rule: Muster stores installation credentials, invocation/audit +records, and bounded Kelpie query results. Kelpie remains authoritative for +case lifecycle, evidence, and closure, exactly as described in +[current-upstream-contracts.md](current-upstream-contracts.md). diff --git a/packages/agent-harness/package.json b/packages/agent-harness/package.json index 566e38d..9df9104 100644 --- a/packages/agent-harness/package.json +++ b/packages/agent-harness/package.json @@ -43,7 +43,7 @@ "test": "vitest run" }, "dependencies": { - "@modelcontextprotocol/sdk": "1.29.0", + "@modelcontextprotocol/sdk": "1.30.0", "@muster/authz": "workspace:*", "@muster/config": "workspace:*", "@muster/contracts": "workspace:*", diff --git a/packages/database/migrations/0021_dazzling_living_mummy.sql b/packages/database/migrations/0021_dazzling_living_mummy.sql new file mode 100644 index 0000000..04f94e5 --- /dev/null +++ b/packages/database/migrations/0021_dazzling_living_mummy.sql @@ -0,0 +1,25 @@ +CREATE UNIQUE INDEX "actors_id_organisation_unique" ON "actors" USING btree ("id","organisation_id");--> statement-breakpoint +CREATE TABLE "mcp_installations" ( + "id" uuid PRIMARY KEY NOT NULL, + "organisation_id" uuid NOT NULL, + "name" text NOT NULL, + "token_hash" text NOT NULL, + "token_prefix" text NOT NULL, + "scopes" jsonb DEFAULT '[]'::jsonb NOT NULL, + "bound_actor_id" uuid NOT NULL, + "status" text DEFAULT 'active' NOT NULL, + "installed_by_actor_id" uuid NOT NULL, + "installed_at" timestamp with time zone DEFAULT now() NOT NULL, + "last_used_at" timestamp with time zone, + "revoked_at" timestamp with time zone, + "revoked_by_actor_id" uuid, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +ALTER TABLE "mcp_installations" ADD CONSTRAINT "mcp_installations_organisation_id_organisations_id_fk" FOREIGN KEY ("organisation_id") REFERENCES "public"."organisations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mcp_installations" ADD CONSTRAINT "mcp_installations_bound_actor_org_fk" FOREIGN KEY ("bound_actor_id","organisation_id") REFERENCES "public"."actors"("id","organisation_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mcp_installations" ADD CONSTRAINT "mcp_installations_installed_by_actor_org_fk" FOREIGN KEY ("installed_by_actor_id","organisation_id") REFERENCES "public"."actors"("id","organisation_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "mcp_installations" ADD CONSTRAINT "mcp_installations_revoked_by_actor_org_fk" FOREIGN KEY ("revoked_by_actor_id","organisation_id") REFERENCES "public"."actors"("id","organisation_id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE UNIQUE INDEX "mcp_installations_token_hash_unique" ON "mcp_installations" USING btree ("token_hash");--> statement-breakpoint +CREATE INDEX "mcp_installations_org_status_idx" ON "mcp_installations" USING btree ("organisation_id","status"); diff --git a/packages/database/migrations/meta/0021_snapshot.json b/packages/database/migrations/meta/0021_snapshot.json new file mode 100644 index 0000000..0c2e319 --- /dev/null +++ b/packages/database/migrations/meta/0021_snapshot.json @@ -0,0 +1,12790 @@ +{ + "id": "57e02959-32dd-44df-8620-ea69bd36ee22", + "prevId": "5a3f4b3d-0e42-4346-968e-c1b3220c872e", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.actors": { + "name": "actors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_type": { + "name": "actor_type", + "type": "actor_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avatar": { + "name": "avatar", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "identity_reference": { + "name": "identity_reference", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "capability_assignments": { + "name": "capability_assignments", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "actors_org_type_idx": { + "name": "actors_org_type_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "actors_org_identity_unique": { + "name": "actors_org_identity_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "identity_reference", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"actors\".\"identity_reference\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "actors_id_organisation_unique": { + "name": "actors_id_organisation_unique", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "actors_organisation_id_organisations_id_fk": { + "name": "actors_organisation_id_organisations_id_fk", + "tableFrom": "actors", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_definitions": { + "name": "agent_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avatar": { + "name": "avatar", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runtime": { + "name": "runtime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_actor_id": { + "name": "owner_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "system_prompt_version": { + "name": "system_prompt_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "allowed_tools": { + "name": "allowed_tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "allowed_rooms": { + "name": "allowed_rooms", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "capability_requirements": { + "name": "capability_requirements", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "maximum_runtime_seconds": { + "name": "maximum_runtime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 300 + }, + "maximum_token_budget": { + "name": "maximum_token_budget", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 20000 + }, + "maximum_cost_cents": { + "name": "maximum_cost_cents", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 500 + }, + "data_classification_allowance": { + "name": "data_classification_allowance", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"internal\"]'::jsonb" + }, + "approval_requirements": { + "name": "approval_requirements", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "requested_permission_mode": { + "name": "requested_permission_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'read_only'" + }, + "kill_switch": { + "name": "kill_switch", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_definitions_org_name_unique": { + "name": "agent_definitions_org_name_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_definitions_organisation_id_organisations_id_fk": { + "name": "agent_definitions_organisation_id_organisations_id_fk", + "tableFrom": "agent_definitions", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_definitions_owner_actor_id_actors_id_fk": { + "name": "agent_definitions_owner_actor_id_actors_id_fk", + "tableFrom": "agent_definitions", + "tableTo": "actors", + "columnsFrom": [ + "owner_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "agent_definitions_requested_permission_check": { + "name": "agent_definitions_requested_permission_check", + "value": "\"agent_definitions\".\"requested_permission_mode\" in ('read_only','approval_gated')" + } + }, + "isRLSEnabled": false + }, + "public.agent_memories": { + "name": "agent_memories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source_run_id": { + "name": "source_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "evidence_references": { + "name": "evidence_references", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "confidence": { + "name": "confidence", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "classification": { + "name": "classification", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'internal'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "supersedes_memory_id": { + "name": "supersedes_memory_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reviewed_by_actor_id": { + "name": "reviewed_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_memories_org_agent_idx": { + "name": "agent_memories_org_agent_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_memories_organisation_id_organisations_id_fk": { + "name": "agent_memories_organisation_id_organisations_id_fk", + "tableFrom": "agent_memories", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_memories_agent_id_agent_definitions_id_fk": { + "name": "agent_memories_agent_id_agent_definitions_id_fk", + "tableFrom": "agent_memories", + "tableTo": "agent_definitions", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_memories_source_run_id_agent_runs_id_fk": { + "name": "agent_memories_source_run_id_agent_runs_id_fk", + "tableFrom": "agent_memories", + "tableTo": "agent_runs", + "columnsFrom": [ + "source_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_memories_reviewed_by_actor_id_actors_id_fk": { + "name": "agent_memories_reviewed_by_actor_id_actors_id_fk", + "tableFrom": "agent_memories", + "tableTo": "actors", + "columnsFrom": [ + "reviewed_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "agent_memories_kind_check": { + "name": "agent_memories_kind_check", + "value": "\"agent_memories\".\"kind\" in ('fact','preference','lesson','failure','procedure_hint')" + }, + "agent_memories_status_check": { + "name": "agent_memories_status_check", + "value": "\"agent_memories\".\"status\" in ('active','superseded','expired','rejected')" + }, + "agent_memories_confidence_check": { + "name": "agent_memories_confidence_check", + "value": "\"agent_memories\".\"confidence\" between 0 and 100" + } + }, + "isRLSEnabled": false + }, + "public.agent_readiness_snapshots": { + "name": "agent_readiness_snapshots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "process_identity": { + "name": "process_identity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gateway_state": { + "name": "gateway_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authentication_state": { + "name": "authentication_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "observer_state": { + "name": "observer_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lifecycle_evidence_state": { + "name": "lifecycle_evidence_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lifecycle_state": { + "name": "lifecycle_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "capability_state": { + "name": "capability_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool_state": { + "name": "tool_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "permission_state": { + "name": "permission_state", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reported_runtime": { + "name": "reported_runtime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reported_provider": { + "name": "reported_provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reported_model": { + "name": "reported_model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_capabilities": { + "name": "input_capabilities", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "output_capabilities": { + "name": "output_capabilities", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "available_commands": { + "name": "available_commands", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "tool_sources": { + "name": "tool_sources", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "tool_risk_classes": { + "name": "tool_risk_classes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "requested_permission_mode": { + "name": "requested_permission_mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "effective_permission_mode": { + "name": "effective_permission_mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "limitations": { + "name": "limitations", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "heartbeat_at": { + "name": "heartbeat_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "verified_at": { + "name": "verified_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_readiness_org_agent_verified_idx": { + "name": "agent_readiness_org_agent_verified_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "verified_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_readiness_org_process_verified_idx": { + "name": "agent_readiness_org_process_verified_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "process_identity", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "verified_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_readiness_snapshots_organisation_id_organisations_id_fk": { + "name": "agent_readiness_snapshots_organisation_id_organisations_id_fk", + "tableFrom": "agent_readiness_snapshots", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_readiness_snapshots_agent_id_agent_definitions_id_fk": { + "name": "agent_readiness_snapshots_agent_id_agent_definitions_id_fk", + "tableFrom": "agent_readiness_snapshots", + "tableTo": "agent_definitions", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "agent_readiness_evidence_states_check": { + "name": "agent_readiness_evidence_states_check", + "value": "\"agent_readiness_snapshots\".\"gateway_state\" in ('reported','unavailable','unknown')\n and \"agent_readiness_snapshots\".\"authentication_state\" in ('reported','unavailable','unknown')\n and \"agent_readiness_snapshots\".\"observer_state\" in ('reported','unavailable','unknown')\n and \"agent_readiness_snapshots\".\"lifecycle_evidence_state\" in ('reported','unavailable','unknown')\n and \"agent_readiness_snapshots\".\"capability_state\" in ('reported','unavailable','unknown')\n and \"agent_readiness_snapshots\".\"tool_state\" in ('reported','unavailable','unknown')\n and \"agent_readiness_snapshots\".\"permission_state\" in ('reported','unavailable','unknown')" + }, + "agent_readiness_lifecycle_state_check": { + "name": "agent_readiness_lifecycle_state_check", + "value": "\"agent_readiness_snapshots\".\"lifecycle_state\" in ('idle','running','stopped','failed','unknown')" + }, + "agent_readiness_permission_modes_check": { + "name": "agent_readiness_permission_modes_check", + "value": "\"agent_readiness_snapshots\".\"requested_permission_mode\" in ('read_only','approval_gated','unknown')\n and \"agent_readiness_snapshots\".\"effective_permission_mode\" in ('read_only','approval_gated','unknown')" + } + }, + "isRLSEnabled": false + }, + "public.agent_run_events": { + "name": "agent_run_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_run_events_org_run_idx": { + "name": "agent_run_events_org_run_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_run_events_organisation_id_organisations_id_fk": { + "name": "agent_run_events_organisation_id_organisations_id_fk", + "tableFrom": "agent_run_events", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_run_events_run_id_agent_runs_id_fk": { + "name": "agent_run_events_run_id_agent_runs_id_fk", + "tableFrom": "agent_run_events", + "tableTo": "agent_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_run_sources": { + "name": "agent_run_sources", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source_type": { + "name": "source_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_id": { + "name": "source_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "classification": { + "name": "classification", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'internal'" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_run_sources_org_run_unique": { + "name": "agent_run_sources_org_run_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_run_sources_org_run_idx": { + "name": "agent_run_sources_org_run_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_run_sources_organisation_id_organisations_id_fk": { + "name": "agent_run_sources_organisation_id_organisations_id_fk", + "tableFrom": "agent_run_sources", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_run_sources_run_id_agent_runs_id_fk": { + "name": "agent_run_sources_run_id_agent_runs_id_fk", + "tableFrom": "agent_run_sources", + "tableTo": "agent_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_runs": { + "name": "agent_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "investigation_id": { + "name": "investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "workflow_run_id": { + "name": "workflow_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "requested_by_actor_id": { + "name": "requested_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "request": { + "name": "request", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "progress": { + "name": "progress", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "heartbeat_at": { + "name": "heartbeat_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "lease_expires_at": { + "name": "lease_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deadline_at": { + "name": "deadline_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "cancellation_requested_at": { + "name": "cancellation_requested_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "worker_id": { + "name": "worker_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attempt_count": { + "name": "attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "input_hash": { + "name": "input_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt_hash": { + "name": "prompt_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output_hash": { + "name": "output_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output_schema": { + "name": "output_schema", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt_version": { + "name": "prompt_version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "runtime": { + "name": "runtime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "maximum_runtime_seconds": { + "name": "maximum_runtime_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 300 + }, + "maximum_token_budget": { + "name": "maximum_token_budget", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 20000 + }, + "maximum_cost_cents": { + "name": "maximum_cost_cents", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 500 + }, + "token_usage": { + "name": "token_usage", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "estimated_cost_cents": { + "name": "estimated_cost_cents", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "tool_call_count": { + "name": "tool_call_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "diagnostics": { + "name": "diagnostics", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "failure_code": { + "name": "failure_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "cancellation_reason": { + "name": "cancellation_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "structured_output": { + "name": "structured_output", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "agent_runs_org_idempotency_unique": { + "name": "agent_runs_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_runs_org_status_idx": { + "name": "agent_runs_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_runs_recovery_idx": { + "name": "agent_runs_recovery_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lease_expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_runs_agent_id_agent_definitions_id_fk": { + "name": "agent_runs_agent_id_agent_definitions_id_fk", + "tableFrom": "agent_runs", + "tableTo": "agent_definitions", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_runs_organisation_id_organisations_id_fk": { + "name": "agent_runs_organisation_id_organisations_id_fk", + "tableFrom": "agent_runs", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_runs_room_id_rooms_id_fk": { + "name": "agent_runs_room_id_rooms_id_fk", + "tableFrom": "agent_runs", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_runs_investigation_id_investigations_id_fk": { + "name": "agent_runs_investigation_id_investigations_id_fk", + "tableFrom": "agent_runs", + "tableTo": "investigations", + "columnsFrom": [ + "investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_runs_requested_by_actor_id_actors_id_fk": { + "name": "agent_runs_requested_by_actor_id_actors_id_fk", + "tableFrom": "agent_runs", + "tableTo": "actors", + "columnsFrom": [ + "requested_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_skill_evaluations": { + "name": "agent_skill_evaluations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "skill_version_id": { + "name": "skill_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "evaluator_actor_id": { + "name": "evaluator_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "suite": { + "name": "suite", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "passed": { + "name": "passed", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "score": { + "name": "score", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "baseline_score": { + "name": "baseline_score", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "regressions": { + "name": "regressions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_skill_evaluations_version_idx": { + "name": "agent_skill_evaluations_version_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "skill_version_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_skill_evaluations_organisation_id_organisations_id_fk": { + "name": "agent_skill_evaluations_organisation_id_organisations_id_fk", + "tableFrom": "agent_skill_evaluations", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_skill_evaluations_skill_version_id_agent_skill_versions_id_fk": { + "name": "agent_skill_evaluations_skill_version_id_agent_skill_versions_id_fk", + "tableFrom": "agent_skill_evaluations", + "tableTo": "agent_skill_versions", + "columnsFrom": [ + "skill_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_skill_evaluations_evaluator_actor_id_actors_id_fk": { + "name": "agent_skill_evaluations_evaluator_actor_id_actors_id_fk", + "tableFrom": "agent_skill_evaluations", + "tableTo": "actors", + "columnsFrom": [ + "evaluator_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "agent_skill_evaluations_score_check": { + "name": "agent_skill_evaluations_score_check", + "value": "\"agent_skill_evaluations\".\"score\" between 0 and 100" + } + }, + "isRLSEnabled": false + }, + "public.agent_skill_versions": { + "name": "agent_skill_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "skill_id": { + "name": "skill_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "source_run_id": { + "name": "source_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "based_on_version_id": { + "name": "based_on_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "change_rationale": { + "name": "change_rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "evidence_references": { + "name": "evidence_references", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "required_capabilities": { + "name": "required_capabilities", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "allowed_tools": { + "name": "allowed_tools", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'proposed'" + }, + "approved_by_actor_id": { + "name": "approved_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_skill_versions_skill_version_unique": { + "name": "agent_skill_versions_skill_version_unique", + "columns": [ + { + "expression": "skill_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_skill_versions_content_hash_unique": { + "name": "agent_skill_versions_content_hash_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "content_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_skill_versions_organisation_id_organisations_id_fk": { + "name": "agent_skill_versions_organisation_id_organisations_id_fk", + "tableFrom": "agent_skill_versions", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_skill_versions_skill_id_agent_skills_id_fk": { + "name": "agent_skill_versions_skill_id_agent_skills_id_fk", + "tableFrom": "agent_skill_versions", + "tableTo": "agent_skills", + "columnsFrom": [ + "skill_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_skill_versions_source_run_id_agent_runs_id_fk": { + "name": "agent_skill_versions_source_run_id_agent_runs_id_fk", + "tableFrom": "agent_skill_versions", + "tableTo": "agent_runs", + "columnsFrom": [ + "source_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_skill_versions_approved_by_actor_id_actors_id_fk": { + "name": "agent_skill_versions_approved_by_actor_id_actors_id_fk", + "tableFrom": "agent_skill_versions", + "tableTo": "actors", + "columnsFrom": [ + "approved_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "agent_skill_versions_state_check": { + "name": "agent_skill_versions_state_check", + "value": "\"agent_skill_versions\".\"state\" in ('proposed','evaluating','approved','rejected','published','rolled_back')" + } + }, + "isRLSEnabled": false + }, + "public.agent_skills": { + "name": "agent_skills", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "skill_key": { + "name": "skill_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "active_version_id": { + "name": "active_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_skills_org_agent_key_unique": { + "name": "agent_skills_org_agent_key_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "skill_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_skills_organisation_id_organisations_id_fk": { + "name": "agent_skills_organisation_id_organisations_id_fk", + "tableFrom": "agent_skills", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_skills_agent_id_agent_definitions_id_fk": { + "name": "agent_skills_agent_id_agent_definitions_id_fk", + "tableFrom": "agent_skills", + "tableTo": "agent_definitions", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_skills_created_by_actor_id_actors_id_fk": { + "name": "agent_skills_created_by_actor_id_actors_id_fk", + "tableFrom": "agent_skills", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "agent_skills_status_check": { + "name": "agent_skills_status_check", + "value": "\"agent_skills\".\"status\" in ('draft','evaluating','published','retired')" + } + }, + "isRLSEnabled": false + }, + "public.agent_tool_calls": { + "name": "agent_tool_calls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "tool_name": { + "name": "tool_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "capability": { + "name": "capability", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "classification": { + "name": "classification", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "arguments_hash": { + "name": "arguments_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_hash": { + "name": "result_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "approval_id": { + "name": "approval_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_tool_calls_org_run_idx": { + "name": "agent_tool_calls_org_run_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_tool_calls_organisation_id_organisations_id_fk": { + "name": "agent_tool_calls_organisation_id_organisations_id_fk", + "tableFrom": "agent_tool_calls", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_tool_calls_run_id_agent_runs_id_fk": { + "name": "agent_tool_calls_run_id_agent_runs_id_fk", + "tableFrom": "agent_tool_calls", + "tableTo": "agent_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "agent_tool_calls_approval_id_approvals_id_fk": { + "name": "agent_tool_calls_approval_id_approvals_id_fk", + "tableFrom": "agent_tool_calls", + "tableTo": "approvals", + "columnsFrom": [ + "approval_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.alerts": { + "name": "alerts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source_product": { + "name": "source_product", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_instance": { + "name": "source_instance", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_reference": { + "name": "external_reference", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "severity": { + "name": "severity", + "type": "severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "alert_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'new'" + }, + "rule_name": { + "name": "rule_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rule_id": { + "name": "rule_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "assigned_actor_id": { + "name": "assigned_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "entities": { + "name": "entities", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "observables": { + "name": "observables", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "raw_reference_metadata": { + "name": "raw_reference_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "investigation_id": { + "name": "investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kelpie_case_id": { + "name": "kelpie_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "correlation_key": { + "name": "correlation_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + } + }, + "indexes": { + "alerts_org_source_ref_unique": { + "name": "alerts_org_source_ref_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_product", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_instance", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_reference", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "alerts_org_dedupe_unique": { + "name": "alerts_org_dedupe_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "dedupe_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "alerts_org_queue_idx": { + "name": "alerts_org_queue_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "severity", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "alerts_search_idx": { + "name": "alerts_search_idx", + "columns": [ + { + "expression": "to_tsvector('english', \"title\" || ' ' || \"description\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "alerts_organisation_id_organisations_id_fk": { + "name": "alerts_organisation_id_organisations_id_fk", + "tableFrom": "alerts", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "alerts_assigned_actor_id_actors_id_fk": { + "name": "alerts_assigned_actor_id_actors_id_fk", + "tableFrom": "alerts", + "tableTo": "actors", + "columnsFrom": [ + "assigned_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "alerts_room_id_rooms_id_fk": { + "name": "alerts_room_id_rooms_id_fk", + "tableFrom": "alerts", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.approvals": { + "name": "approvals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requesting_actor_id": { + "name": "requesting_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "action_type": { + "name": "action_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "risk_summary": { + "name": "risk_summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "requested_at": { + "name": "requested_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "required_capability": { + "name": "required_capability", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "required_approval_count": { + "name": "required_approval_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "status": { + "name": "status", + "type": "approval_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "decisions": { + "name": "decisions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "decision_at": { + "name": "decision_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "executed_at": { + "name": "executed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "approvals_org_idempotency_unique": { + "name": "approvals_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "approvals_org_status_idx": { + "name": "approvals_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "approvals_organisation_id_organisations_id_fk": { + "name": "approvals_organisation_id_organisations_id_fk", + "tableFrom": "approvals", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "approvals_requesting_actor_id_actors_id_fk": { + "name": "approvals_requesting_actor_id_actors_id_fk", + "tableFrom": "approvals", + "tableTo": "actors", + "columnsFrom": [ + "requesting_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.audit_events": { + "name": "audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "sequence": { + "name": "sequence", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_type": { + "name": "actor_type", + "type": "actor_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_type": { + "name": "target_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_id": { + "name": "target_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "previous_hash": { + "name": "previous_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_hash": { + "name": "event_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "audit_org_sequence_unique": { + "name": "audit_org_sequence_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sequence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_org_hash_unique": { + "name": "audit_org_hash_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "audit_org_target_idx": { + "name": "audit_org_target_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "target_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "audit_events_organisation_id_organisations_id_fk": { + "name": "audit_events_organisation_id_organisations_id_fk", + "tableFrom": "audit_events", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "audit_events_actor_id_actors_id_fk": { + "name": "audit_events_actor_id_actors_id_fk", + "tableFrom": "audit_events", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_account": { + "name": "auth_account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_accounts_user_idx": { + "name": "auth_accounts_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "auth_accounts_provider_unique": { + "name": "auth_accounts_provider_unique", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "account_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "auth_account_user_id_auth_user_id_fk": { + "name": "auth_account_user_id_auth_user_id_fk", + "tableFrom": "auth_account", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_passkey": { + "name": "auth_passkey", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "device_type": { + "name": "device_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "backed_up": { + "name": "backed_up", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "transports": { + "name": "transports", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "aaguid": { + "name": "aaguid", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "auth_passkey_user_idx": { + "name": "auth_passkey_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "auth_passkey_user_id_auth_user_id_fk": { + "name": "auth_passkey_user_id_auth_user_id_fk", + "tableFrom": "auth_passkey", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "auth_passkey_credential_id_unique": { + "name": "auth_passkey_credential_id_unique", + "nullsNotDistinct": false, + "columns": [ + "credential_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_session": { + "name": "auth_session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_sessions_user_idx": { + "name": "auth_sessions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "auth_session_user_id_auth_user_id_fk": { + "name": "auth_session_user_id_auth_user_id_fk", + "tableFrom": "auth_session", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "auth_session_token_unique": { + "name": "auth_session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_two_factor": { + "name": "auth_two_factor", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "backup_codes": { + "name": "backup_codes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "failed_verification_count": { + "name": "failed_verification_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "locked_until": { + "name": "locked_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "auth_two_factor_user_unique": { + "name": "auth_two_factor_user_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "auth_two_factor_user_id_auth_user_id_fk": { + "name": "auth_two_factor_user_id_auth_user_id_fk", + "tableFrom": "auth_two_factor", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_user": { + "name": "auth_user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "two_factor_enabled": { + "name": "two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "auth_user_email_unique": { + "name": "auth_user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.auth_verification": { + "name": "auth_verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "auth_verification_identifier_idx": { + "name": "auth_verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "decision": { + "name": "decision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "decision_maker_actor_id": { + "name": "decision_maker_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "alternatives_considered": { + "name": "alternatives_considered", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "evidence_references": { + "name": "evidence_references", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "related_investigation_id": { + "name": "related_investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "related_case_id": { + "name": "related_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "related_workflow_run_id": { + "name": "related_workflow_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approval_id": { + "name": "approval_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "decisions_org_investigation_idx": { + "name": "decisions_org_investigation_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "related_investigation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "decisions_organisation_id_organisations_id_fk": { + "name": "decisions_organisation_id_organisations_id_fk", + "tableFrom": "decisions", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "decisions_decision_maker_actor_id_actors_id_fk": { + "name": "decisions_decision_maker_actor_id_actors_id_fk", + "tableFrom": "decisions", + "tableTo": "actors", + "columnsFrom": [ + "decision_maker_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "decisions_related_investigation_id_investigations_id_fk": { + "name": "decisions_related_investigation_id_investigations_id_fk", + "tableFrom": "decisions", + "tableTo": "investigations", + "columnsFrom": [ + "related_investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.evidence": { + "name": "evidence", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uploaded_by_actor_id": { + "name": "uploaded_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "classification": { + "name": "classification", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "related_room_id": { + "name": "related_room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "related_investigation_id": { + "name": "related_investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "related_case_id": { + "name": "related_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "original_timestamp": { + "name": "original_timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scan_state": { + "name": "scan_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "retention_state": { + "name": "retention_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "legal_hold": { + "name": "legal_hold", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "object_lock_metadata": { + "name": "object_lock_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "evidence_org_hash_unique": { + "name": "evidence_org_hash_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "evidence_search_idx": { + "name": "evidence_search_idx", + "columns": [ + { + "expression": "to_tsvector('english', \"file_name\" || ' ' || \"source\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "evidence_organisation_id_organisations_id_fk": { + "name": "evidence_organisation_id_organisations_id_fk", + "tableFrom": "evidence", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "evidence_uploaded_by_actor_id_actors_id_fk": { + "name": "evidence_uploaded_by_actor_id_actors_id_fk", + "tableFrom": "evidence", + "tableTo": "actors", + "columnsFrom": [ + "uploaded_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "evidence_related_room_id_rooms_id_fk": { + "name": "evidence_related_room_id_rooms_id_fk", + "tableFrom": "evidence", + "tableTo": "rooms", + "columnsFrom": [ + "related_room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "evidence_related_investigation_id_investigations_id_fk": { + "name": "evidence_related_investigation_id_investigations_id_fk", + "tableFrom": "evidence", + "tableTo": "investigations", + "columnsFrom": [ + "related_investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.findings": { + "name": "findings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "investigation_id": { + "name": "investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "confidence": { + "name": "confidence", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "severity": { + "name": "severity", + "type": "severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "supporting_evidence": { + "name": "supporting_evidence", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "related_entities": { + "name": "related_entities", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "related_observables": { + "name": "related_observables", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "recommended_action": { + "name": "recommended_action", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_provenance": { + "name": "agent_provenance", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "human_reviewed_at": { + "name": "human_reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "superseded_at": { + "name": "superseded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "findings_org_investigation_idx": { + "name": "findings_org_investigation_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "investigation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "findings_search_idx": { + "name": "findings_search_idx", + "columns": [ + { + "expression": "to_tsvector('english', \"title\" || ' ' || \"summary\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "findings_organisation_id_organisations_id_fk": { + "name": "findings_organisation_id_organisations_id_fk", + "tableFrom": "findings", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "findings_investigation_id_investigations_id_fk": { + "name": "findings_investigation_id_investigations_id_fk", + "tableFrom": "findings", + "tableTo": "investigations", + "columnsFrom": [ + "investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "findings_created_by_actor_id_actors_id_fk": { + "name": "findings_created_by_actor_id_actors_id_fk", + "tableFrom": "findings", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hunt_queries": { + "name": "hunt_queries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "hunt_id": { + "name": "hunt_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "integration_id": { + "name": "integration_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "query_run_id": { + "name": "query_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source_key": { + "name": "source_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sequence": { + "name": "sequence", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "hunt_queries_org_query_run_unique": { + "name": "hunt_queries_org_query_run_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "query_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hunt_queries_org_hunt_sequence_unique": { + "name": "hunt_queries_org_hunt_sequence_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "hunt_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sequence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hunt_queries_org_hunt_idx": { + "name": "hunt_queries_org_hunt_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "hunt_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sequence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hunt_queries_organisation_id_organisations_id_fk": { + "name": "hunt_queries_organisation_id_organisations_id_fk", + "tableFrom": "hunt_queries", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_queries_hunt_id_hunt_runs_id_fk": { + "name": "hunt_queries_hunt_id_hunt_runs_id_fk", + "tableFrom": "hunt_queries", + "tableTo": "hunt_runs", + "columnsFrom": [ + "hunt_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_queries_integration_id_integration_records_id_fk": { + "name": "hunt_queries_integration_id_integration_records_id_fk", + "tableFrom": "hunt_queries", + "tableTo": "integration_records", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_queries_template_id_integration_query_templates_id_fk": { + "name": "hunt_queries_template_id_integration_query_templates_id_fk", + "tableFrom": "hunt_queries", + "tableTo": "integration_query_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_queries_query_run_id_integration_query_runs_id_fk": { + "name": "hunt_queries_query_run_id_integration_query_runs_id_fk", + "tableFrom": "hunt_queries", + "tableTo": "integration_query_runs", + "columnsFrom": [ + "query_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hunt_runs": { + "name": "hunt_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_run_id": { + "name": "agent_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source_message_id": { + "name": "source_message_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "linked_case_id": { + "name": "linked_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requested_by_actor_id": { + "name": "requested_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "question": { + "name": "question", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "training_mode": { + "name": "training_mode", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "plan": { + "name": "plan", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'planned'" + }, + "approval_id": { + "name": "approval_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "failure_code": { + "name": "failure_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "hunt_runs_org_idempotency_unique": { + "name": "hunt_runs_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hunt_runs_org_agent_run_unique": { + "name": "hunt_runs_org_agent_run_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "hunt_runs_org_status_idx": { + "name": "hunt_runs_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hunt_runs_organisation_id_organisations_id_fk": { + "name": "hunt_runs_organisation_id_organisations_id_fk", + "tableFrom": "hunt_runs", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_runs_agent_run_id_agent_runs_id_fk": { + "name": "hunt_runs_agent_run_id_agent_runs_id_fk", + "tableFrom": "hunt_runs", + "tableTo": "agent_runs", + "columnsFrom": [ + "agent_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_runs_task_id_tasks_id_fk": { + "name": "hunt_runs_task_id_tasks_id_fk", + "tableFrom": "hunt_runs", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_runs_source_message_id_messages_id_fk": { + "name": "hunt_runs_source_message_id_messages_id_fk", + "tableFrom": "hunt_runs", + "tableTo": "messages", + "columnsFrom": [ + "source_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_runs_room_id_rooms_id_fk": { + "name": "hunt_runs_room_id_rooms_id_fk", + "tableFrom": "hunt_runs", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_runs_requested_by_actor_id_actors_id_fk": { + "name": "hunt_runs_requested_by_actor_id_actors_id_fk", + "tableFrom": "hunt_runs", + "tableTo": "actors", + "columnsFrom": [ + "requested_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hunt_runs_approval_id_approvals_id_fk": { + "name": "hunt_runs_approval_id_approvals_id_fk", + "tableFrom": "hunt_runs", + "tableTo": "approvals", + "columnsFrom": [ + "approval_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "hunt_runs_status_check": { + "name": "hunt_runs_status_check", + "value": "\"hunt_runs\".\"status\" in ('planned','awaiting_approval','querying','analysing','completed','failed','cancelled')" + } + }, + "isRLSEnabled": false + }, + "public.hypotheses": { + "name": "hypotheses", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "investigation_id": { + "name": "investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "statement": { + "name": "statement", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'unverified'" + }, + "confidence": { + "name": "confidence", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 50 + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "supporting_finding_ids": { + "name": "supporting_finding_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "contradicting_finding_ids": { + "name": "contradicting_finding_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "resolved_at": { + "name": "resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "hypotheses_org_investigation_idx": { + "name": "hypotheses_org_investigation_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "investigation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hypotheses_organisation_id_organisations_id_fk": { + "name": "hypotheses_organisation_id_organisations_id_fk", + "tableFrom": "hypotheses", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hypotheses_investigation_id_investigations_id_fk": { + "name": "hypotheses_investigation_id_investigations_id_fk", + "tableFrom": "hypotheses", + "tableTo": "investigations", + "columnsFrom": [ + "investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hypotheses_created_by_actor_id_actors_id_fk": { + "name": "hypotheses_created_by_actor_id_actors_id_fk", + "tableFrom": "hypotheses", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.idempotency_records": { + "name": "idempotency_records", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "request_hash": { + "name": "request_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_status": { + "name": "response_status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "response_body": { + "name": "response_body", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "idempotency_expiry_idx": { + "name": "idempotency_expiry_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "idempotency_records_organisation_id_organisations_id_fk": { + "name": "idempotency_records_organisation_id_organisations_id_fk", + "tableFrom": "idempotency_records", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "idempotency_records_organisation_id_scope_key_pk": { + "name": "idempotency_records_organisation_id_scope_key_pk", + "columns": [ + "organisation_id", + "scope", + "key" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_connector_credentials": { + "name": "integration_connector_credentials", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "integration_id": { + "name": "integration_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "encrypted_credential": { + "name": "encrypted_credential", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "envelope_version": { + "name": "envelope_version", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'v1'" + }, + "rotation_version": { + "name": "rotation_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "rotated_by_actor_id": { + "name": "rotated_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "rotated_at": { + "name": "rotated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_credentials_org_idx": { + "name": "integration_credentials_org_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "integration_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_connector_credentials_organisation_id_organisations_id_fk": { + "name": "integration_connector_credentials_organisation_id_organisations_id_fk", + "tableFrom": "integration_connector_credentials", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_connector_credentials_integration_id_integration_records_id_fk": { + "name": "integration_connector_credentials_integration_id_integration_records_id_fk", + "tableFrom": "integration_connector_credentials", + "tableTo": "integration_records", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_connector_credentials_rotated_by_actor_id_actors_id_fk": { + "name": "integration_connector_credentials_rotated_by_actor_id_actors_id_fk", + "tableFrom": "integration_connector_credentials", + "tableTo": "actors", + "columnsFrom": [ + "rotated_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_deliveries": { + "name": "integration_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "integration_id": { + "name": "integration_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "direction": { + "name": "direction", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "operation": { + "name": "operation", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attempt_count": { + "name": "attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "request_metadata": { + "name": "request_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "response_metadata": { + "name": "response_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_delivery_org_idempotency_unique": { + "name": "integration_delivery_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_deliveries_organisation_id_organisations_id_fk": { + "name": "integration_deliveries_organisation_id_organisations_id_fk", + "tableFrom": "integration_deliveries", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_deliveries_integration_id_integration_records_id_fk": { + "name": "integration_deliveries_integration_id_integration_records_id_fk", + "tableFrom": "integration_deliveries", + "tableTo": "integration_records", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_entities": { + "name": "integration_entities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "integration_id": { + "name": "integration_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "entity_type": { + "name": "entity_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "posture": { + "name": "posture", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "integration_entities_org_external_unique": { + "name": "integration_entities_org_external_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "integration_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "entity_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_entities_organisation_id_organisations_id_fk": { + "name": "integration_entities_organisation_id_organisations_id_fk", + "tableFrom": "integration_entities", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_entities_integration_id_integration_records_id_fk": { + "name": "integration_entities_integration_id_integration_records_id_fk", + "tableFrom": "integration_entities", + "tableTo": "integration_records", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_query_runs": { + "name": "integration_query_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "integration_id": { + "name": "integration_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requested_by_actor_id": { + "name": "requested_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "input": { + "name": "input", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "request_metadata": { + "name": "request_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "response_metadata": { + "name": "response_metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_query_runs_org_idempotency_unique": { + "name": "integration_query_runs_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "integration_query_runs_org_status_idx": { + "name": "integration_query_runs_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_query_runs_organisation_id_organisations_id_fk": { + "name": "integration_query_runs_organisation_id_organisations_id_fk", + "tableFrom": "integration_query_runs", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_query_runs_integration_id_integration_records_id_fk": { + "name": "integration_query_runs_integration_id_integration_records_id_fk", + "tableFrom": "integration_query_runs", + "tableTo": "integration_records", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_query_runs_template_id_integration_query_templates_id_fk": { + "name": "integration_query_runs_template_id_integration_query_templates_id_fk", + "tableFrom": "integration_query_runs", + "tableTo": "integration_query_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_query_runs_requested_by_actor_id_actors_id_fk": { + "name": "integration_query_runs_requested_by_actor_id_actors_id_fk", + "tableFrom": "integration_query_runs", + "tableTo": "actors", + "columnsFrom": [ + "requested_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_query_templates": { + "name": "integration_query_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "integration_id": { + "name": "integration_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "template_key": { + "name": "template_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "definition": { + "name": "definition", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integration_templates_org_key_version_unique": { + "name": "integration_templates_org_key_version_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "integration_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "template_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_query_templates_organisation_id_organisations_id_fk": { + "name": "integration_query_templates_organisation_id_organisations_id_fk", + "tableFrom": "integration_query_templates", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_query_templates_integration_id_integration_records_id_fk": { + "name": "integration_query_templates_integration_id_integration_records_id_fk", + "tableFrom": "integration_query_templates", + "tableTo": "integration_records", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "integration_query_templates_created_by_actor_id_actors_id_fk": { + "name": "integration_query_templates_created_by_actor_id_actors_id_fk", + "tableFrom": "integration_query_templates", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integration_records": { + "name": "integration_records", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "product": { + "name": "product", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "instance_id": { + "name": "instance_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mock": { + "name": "mock", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "configuration": { + "name": "configuration", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "health": { + "name": "health", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "cursor": { + "name": "cursor", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "integrations_org_product_instance_unique": { + "name": "integrations_org_product_instance_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "product", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "instance_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "integration_records_organisation_id_organisations_id_fk": { + "name": "integration_records_organisation_id_organisations_id_fk", + "tableFrom": "integration_records", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.investigations": { + "name": "investigations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "investigation_number": { + "name": "investigation_number", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "status": { + "name": "status", + "type": "investigation_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "severity": { + "name": "severity", + "type": "severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "lead_actor_id": { + "name": "lead_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "closed_at": { + "name": "closed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "recommendation": { + "name": "recommendation", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disposition": { + "name": "disposition", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "promotion_decision": { + "name": "promotion_decision", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "linked_kelpie_case_id": { + "name": "linked_kelpie_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + } + }, + "indexes": { + "investigations_org_number_unique": { + "name": "investigations_org_number_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "investigation_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "investigations_org_queue_idx": { + "name": "investigations_org_queue_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "severity", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "last_activity_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "investigations_search_idx": { + "name": "investigations_search_idx", + "columns": [ + { + "expression": "to_tsvector('english', \"title\" || ' ' || \"summary\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "investigations_organisation_id_organisations_id_fk": { + "name": "investigations_organisation_id_organisations_id_fk", + "tableFrom": "investigations", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "investigations_lead_actor_id_actors_id_fk": { + "name": "investigations_lead_actor_id_actors_id_fk", + "tableFrom": "investigations", + "tableTo": "actors", + "columnsFrom": [ + "lead_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "investigations_room_id_rooms_id_fk": { + "name": "investigations_room_id_rooms_id_fk", + "tableFrom": "investigations", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mcp_installations": { + "name": "mcp_installations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token_prefix": { + "name": "token_prefix", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "bound_actor_id": { + "name": "bound_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "installed_by_actor_id": { + "name": "installed_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "installed_at": { + "name": "installed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revoked_by_actor_id": { + "name": "revoked_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mcp_installations_token_hash_unique": { + "name": "mcp_installations_token_hash_unique", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mcp_installations_org_status_idx": { + "name": "mcp_installations_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mcp_installations_organisation_id_organisations_id_fk": { + "name": "mcp_installations_organisation_id_organisations_id_fk", + "tableFrom": "mcp_installations", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "mcp_installations_bound_actor_org_fk": { + "name": "mcp_installations_bound_actor_org_fk", + "tableFrom": "mcp_installations", + "tableTo": "actors", + "columnsFrom": [ + "bound_actor_id", + "organisation_id" + ], + "columnsTo": [ + "id", + "organisation_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "mcp_installations_installed_by_actor_org_fk": { + "name": "mcp_installations_installed_by_actor_org_fk", + "tableFrom": "mcp_installations", + "tableTo": "actors", + "columnsFrom": [ + "installed_by_actor_id", + "organisation_id" + ], + "columnsTo": [ + "id", + "organisation_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "mcp_installations_revoked_by_actor_org_fk": { + "name": "mcp_installations_revoked_by_actor_org_fk", + "tableFrom": "mcp_installations", + "tableTo": "actors", + "columnsFrom": [ + "revoked_by_actor_id", + "organisation_id" + ], + "columnsTo": [ + "id", + "organisation_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.message_mentions": { + "name": "message_mentions", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "mentioned_actor_id": { + "name": "mentioned_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "mention_type": { + "name": "mention_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mention_key": { + "name": "mention_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "message_mentions_org_actor_idx": { + "name": "message_mentions_org_actor_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "mentioned_actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "message_mentions_organisation_id_organisations_id_fk": { + "name": "message_mentions_organisation_id_organisations_id_fk", + "tableFrom": "message_mentions", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_mentions_message_id_messages_id_fk": { + "name": "message_mentions_message_id_messages_id_fk", + "tableFrom": "message_mentions", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_mentions_mentioned_actor_id_actors_id_fk": { + "name": "message_mentions_mentioned_actor_id_actors_id_fk", + "tableFrom": "message_mentions", + "tableTo": "actors", + "columnsFrom": [ + "mentioned_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "message_mentions_message_id_mention_type_mention_key_pk": { + "name": "message_mentions_message_id_mention_type_mention_key_pk", + "columns": [ + "message_id", + "mention_type", + "mention_key" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "message_mention_type_check": { + "name": "message_mention_type_check", + "value": "\"message_mentions\".\"mention_type\" in ('actor','room','everyone')" + } + }, + "isRLSEnabled": false + }, + "public.message_pins": { + "name": "message_pins", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pinned_by_actor_id": { + "name": "pinned_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "message_pins_org_room_idx": { + "name": "message_pins_org_room_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "message_pins_organisation_id_organisations_id_fk": { + "name": "message_pins_organisation_id_organisations_id_fk", + "tableFrom": "message_pins", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_pins_room_id_rooms_id_fk": { + "name": "message_pins_room_id_rooms_id_fk", + "tableFrom": "message_pins", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_pins_message_id_messages_id_fk": { + "name": "message_pins_message_id_messages_id_fk", + "tableFrom": "message_pins", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_pins_pinned_by_actor_id_actors_id_fk": { + "name": "message_pins_pinned_by_actor_id_actors_id_fk", + "tableFrom": "message_pins", + "tableTo": "actors", + "columnsFrom": [ + "pinned_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "message_pins_room_id_message_id_pk": { + "name": "message_pins_room_id_message_id_pk", + "columns": [ + "room_id", + "message_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.message_revisions": { + "name": "message_revisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "revision_type": { + "name": "revision_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "previous_document": { + "name": "previous_document", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "previous_plain_text": { + "name": "previous_plain_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_document": { + "name": "next_document", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "next_plain_text": { + "name": "next_plain_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "message_revisions_org_message_idx": { + "name": "message_revisions_org_message_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "message_revisions_org_idempotency_unique": { + "name": "message_revisions_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "message_revisions_organisation_id_organisations_id_fk": { + "name": "message_revisions_organisation_id_organisations_id_fk", + "tableFrom": "message_revisions", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_revisions_message_id_messages_id_fk": { + "name": "message_revisions_message_id_messages_id_fk", + "tableFrom": "message_revisions", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_revisions_actor_id_actors_id_fk": { + "name": "message_revisions_actor_id_actors_id_fk", + "tableFrom": "message_revisions", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "message_revision_type_check": { + "name": "message_revision_type_check", + "value": "\"message_revisions\".\"revision_type\" in ('edit','delete')" + } + }, + "isRLSEnabled": false + }, + "public.message_saves": { + "name": "message_saves", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "message_saves_org_actor_idx": { + "name": "message_saves_org_actor_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "message_saves_organisation_id_organisations_id_fk": { + "name": "message_saves_organisation_id_organisations_id_fk", + "tableFrom": "message_saves", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_saves_message_id_messages_id_fk": { + "name": "message_saves_message_id_messages_id_fk", + "tableFrom": "message_saves", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "message_saves_actor_id_actors_id_fk": { + "name": "message_saves_actor_id_actors_id_fk", + "tableFrom": "message_saves", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "message_saves_message_id_actor_id_pk": { + "name": "message_saves_message_id_actor_id_pk", + "columns": [ + "message_id", + "actor_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.messages": { + "name": "messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "thread_parent_id": { + "name": "thread_parent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_actor_id": { + "name": "author_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_type": { + "name": "message_type", + "type": "message_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "document": { + "name": "document", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "plain_text": { + "name": "plain_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "edited_at": { + "name": "edited_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "data_classification": { + "name": "data_classification", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'internal'" + }, + "related_alert_id": { + "name": "related_alert_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "related_investigation_id": { + "name": "related_investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "related_case_id": { + "name": "related_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "related_agent_run_id": { + "name": "related_agent_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "related_workflow_run_id": { + "name": "related_workflow_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "messages_org_room_time_idx": { + "name": "messages_org_room_time_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "messages_thread_idx": { + "name": "messages_thread_idx", + "columns": [ + { + "expression": "thread_parent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "messages_org_idempotency_unique": { + "name": "messages_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"messages\".\"idempotency_key\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "messages_search_idx": { + "name": "messages_search_idx", + "columns": [ + { + "expression": "to_tsvector('english', \"plain_text\")", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "messages_organisation_id_organisations_id_fk": { + "name": "messages_organisation_id_organisations_id_fk", + "tableFrom": "messages", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "messages_room_id_rooms_id_fk": { + "name": "messages_room_id_rooms_id_fk", + "tableFrom": "messages", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "messages_author_actor_id_actors_id_fk": { + "name": "messages_author_actor_id_actors_id_fk", + "tableFrom": "messages", + "tableTo": "actors", + "columnsFrom": [ + "author_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "messages_related_alert_id_alerts_id_fk": { + "name": "messages_related_alert_id_alerts_id_fk", + "tableFrom": "messages", + "tableTo": "alerts", + "columnsFrom": [ + "related_alert_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "messages_related_investigation_id_investigations_id_fk": { + "name": "messages_related_investigation_id_investigations_id_fk", + "tableFrom": "messages", + "tableTo": "investigations", + "columnsFrom": [ + "related_investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "safe_preview": { + "name": "safe_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target": { + "name": "target", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "notifications_org_actor_read_idx": { + "name": "notifications_org_actor_read_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "read_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_organisation_id_organisations_id_fk": { + "name": "notifications_organisation_id_organisations_id_fk", + "tableFrom": "notifications", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "notifications_actor_id_actors_id_fk": { + "name": "notifications_actor_id_actors_id_fk", + "tableFrom": "notifications", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organisations": { + "name": "organisations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "data_region": { + "name": "data_region", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'australia'" + }, + "default_timezone": { + "name": "default_timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Australia/Sydney'" + }, + "retention_policy": { + "name": "retention_policy", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "authentication_policy": { + "name": "authentication_policy", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "organisations_slug_unique": { + "name": "organisations_slug_unique", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "organisations_status_check": { + "name": "organisations_status_check", + "value": "\"organisations\".\"status\" in ('active','suspended')" + } + }, + "isRLSEnabled": false + }, + "public.outbox_events": { + "name": "outbox_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "aggregate_type": { + "name": "aggregate_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "aggregate_id": { + "name": "aggregate_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "queue_name": { + "name": "queue_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "available_at": { + "name": "available_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "dispatched_at": { + "name": "dispatched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "outbox_idempotency_unique": { + "name": "outbox_idempotency_unique", + "columns": [ + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "outbox_pending_idx": { + "name": "outbox_pending_idx", + "columns": [ + { + "expression": "available_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"outbox_events\".\"dispatched_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "outbox_events_organisation_id_organisations_id_fk": { + "name": "outbox_events_organisation_id_organisations_id_fk", + "tableFrom": "outbox_events", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reaction_operations": { + "name": "reaction_operations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "emoji": { + "name": "emoji", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "result_count": { + "name": "result_count", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reaction_operations_org_idempotency_unique": { + "name": "reaction_operations_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reaction_operations_org_message_idx": { + "name": "reaction_operations_org_message_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reaction_operations_organisation_id_organisations_id_fk": { + "name": "reaction_operations_organisation_id_organisations_id_fk", + "tableFrom": "reaction_operations", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reaction_operations_message_id_messages_id_fk": { + "name": "reaction_operations_message_id_messages_id_fk", + "tableFrom": "reaction_operations", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reaction_operations_actor_id_actors_id_fk": { + "name": "reaction_operations_actor_id_actors_id_fk", + "tableFrom": "reaction_operations", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reaction_pack_assets": { + "name": "reaction_pack_assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "revision_id": { + "name": "revision_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "alt_text": { + "name": "alt_text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "byte_size": { + "name": "byte_size", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "frame_count": { + "name": "frame_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "sha256": { + "name": "sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verification_state": { + "name": "verification_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'verified'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reaction_pack_assets_org_revision_name_unique": { + "name": "reaction_pack_assets_org_revision_name_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "revision_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reaction_pack_assets_org_digest_idx": { + "name": "reaction_pack_assets_org_digest_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sha256", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reaction_pack_assets_organisation_id_organisations_id_fk": { + "name": "reaction_pack_assets_organisation_id_organisations_id_fk", + "tableFrom": "reaction_pack_assets", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reaction_pack_assets_revision_id_reaction_pack_revisions_id_fk": { + "name": "reaction_pack_assets_revision_id_reaction_pack_revisions_id_fk", + "tableFrom": "reaction_pack_assets", + "tableTo": "reaction_pack_revisions", + "columnsFrom": [ + "revision_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reaction_pack_assets_verification_check": { + "name": "reaction_pack_assets_verification_check", + "value": "\"reaction_pack_assets\".\"verification_state\" in ('verified','missing','mismatch')" + }, + "reaction_pack_assets_dimensions_check": { + "name": "reaction_pack_assets_dimensions_check", + "value": "\"reaction_pack_assets\".\"width\" > 0 and \"reaction_pack_assets\".\"height\" > 0 and \"reaction_pack_assets\".\"frame_count\" > 0 and \"reaction_pack_assets\".\"byte_size\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reaction_pack_revisions": { + "name": "reaction_pack_revisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pack_id": { + "name": "pack_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "revision": { + "name": "revision", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "approval_id": { + "name": "approval_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_by_actor_id": { + "name": "approved_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "approved_at": { + "name": "approved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "superseded_at": { + "name": "superseded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reaction_pack_revisions_org_pack_revision_unique": { + "name": "reaction_pack_revisions_org_pack_revision_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "pack_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "revision", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reaction_pack_revisions_org_status_idx": { + "name": "reaction_pack_revisions_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reaction_pack_revisions_organisation_id_organisations_id_fk": { + "name": "reaction_pack_revisions_organisation_id_organisations_id_fk", + "tableFrom": "reaction_pack_revisions", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reaction_pack_revisions_pack_id_reaction_packs_id_fk": { + "name": "reaction_pack_revisions_pack_id_reaction_packs_id_fk", + "tableFrom": "reaction_pack_revisions", + "tableTo": "reaction_packs", + "columnsFrom": [ + "pack_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reaction_pack_revisions_approved_by_actor_id_actors_id_fk": { + "name": "reaction_pack_revisions_approved_by_actor_id_actors_id_fk", + "tableFrom": "reaction_pack_revisions", + "tableTo": "actors", + "columnsFrom": [ + "approved_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reaction_pack_revisions_created_by_actor_id_actors_id_fk": { + "name": "reaction_pack_revisions_created_by_actor_id_actors_id_fk", + "tableFrom": "reaction_pack_revisions", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reaction_pack_revisions_status_check": { + "name": "reaction_pack_revisions_status_check", + "value": "\"reaction_pack_revisions\".\"status\" in ('draft','approved','superseded','removed')" + }, + "reaction_pack_revisions_revision_check": { + "name": "reaction_pack_revisions_revision_check", + "value": "\"reaction_pack_revisions\".\"revision\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.reaction_packs": { + "name": "reaction_packs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lifecycle": { + "name": "lifecycle", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "removed_by_actor_id": { + "name": "removed_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reaction_packs_org_slug_unique": { + "name": "reaction_packs_org_slug_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "reaction_packs_org_lifecycle_idx": { + "name": "reaction_packs_org_lifecycle_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "lifecycle", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "reaction_packs_organisation_id_organisations_id_fk": { + "name": "reaction_packs_organisation_id_organisations_id_fk", + "tableFrom": "reaction_packs", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reaction_packs_created_by_actor_id_actors_id_fk": { + "name": "reaction_packs_created_by_actor_id_actors_id_fk", + "tableFrom": "reaction_packs", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reaction_packs_removed_by_actor_id_actors_id_fk": { + "name": "reaction_packs_removed_by_actor_id_actors_id_fk", + "tableFrom": "reaction_packs", + "tableTo": "actors", + "columnsFrom": [ + "removed_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "reaction_packs_lifecycle_check": { + "name": "reaction_packs_lifecycle_check", + "value": "\"reaction_packs\".\"lifecycle\" in ('active','removed')" + } + }, + "isRLSEnabled": false + }, + "public.reactions": { + "name": "reactions", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "emoji": { + "name": "emoji", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "reactions_organisation_id_organisations_id_fk": { + "name": "reactions_organisation_id_organisations_id_fk", + "tableFrom": "reactions", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reactions_message_id_messages_id_fk": { + "name": "reactions_message_id_messages_id_fk", + "tableFrom": "reactions", + "tableTo": "messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "reactions_actor_id_actors_id_fk": { + "name": "reactions_actor_id_actors_id_fk", + "tableFrom": "reactions", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "reactions_message_id_actor_id_emoji_pk": { + "name": "reactions_message_id_actor_id_emoji_pk", + "columns": [ + "message_id", + "actor_id", + "emoji" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.report_deliveries": { + "name": "report_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "report_id": { + "name": "report_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "approval_id": { + "name": "approval_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requested_by_actor_id": { + "name": "requested_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recipient": { + "name": "recipient", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'awaiting_approval'" + }, + "result": { + "name": "result", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "delivered_at": { + "name": "delivered_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "report_deliveries_org_idempotency_unique": { + "name": "report_deliveries_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "report_deliveries_org_report_status_idx": { + "name": "report_deliveries_org_report_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "report_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_deliveries_organisation_id_organisations_id_fk": { + "name": "report_deliveries_organisation_id_organisations_id_fk", + "tableFrom": "report_deliveries", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_deliveries_report_id_report_manifests_id_fk": { + "name": "report_deliveries_report_id_report_manifests_id_fk", + "tableFrom": "report_deliveries", + "tableTo": "report_manifests", + "columnsFrom": [ + "report_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_deliveries_approval_id_approvals_id_fk": { + "name": "report_deliveries_approval_id_approvals_id_fk", + "tableFrom": "report_deliveries", + "tableTo": "approvals", + "columnsFrom": [ + "approval_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_deliveries_requested_by_actor_id_actors_id_fk": { + "name": "report_deliveries_requested_by_actor_id_actors_id_fk", + "tableFrom": "report_deliveries", + "tableTo": "actors", + "columnsFrom": [ + "requested_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "report_deliveries_status_check": { + "name": "report_deliveries_status_check", + "value": "\"report_deliveries\".\"status\" in ('awaiting_approval','queued','delivered','failed','cancelled')" + } + }, + "isRLSEnabled": false + }, + "public.report_manifests": { + "name": "report_manifests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_run_id": { + "name": "agent_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requested_by_actor_id": { + "name": "requested_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "manifest": { + "name": "manifest", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "classification": { + "name": "classification", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'internal'" + }, + "review_note": { + "name": "review_note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "posted_message_id": { + "name": "posted_message_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "report_manifests_org_idempotency_unique": { + "name": "report_manifests_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "report_manifests_org_room_status_idx": { + "name": "report_manifests_org_room_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_manifests_organisation_id_organisations_id_fk": { + "name": "report_manifests_organisation_id_organisations_id_fk", + "tableFrom": "report_manifests", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_manifests_agent_run_id_agent_runs_id_fk": { + "name": "report_manifests_agent_run_id_agent_runs_id_fk", + "tableFrom": "report_manifests", + "tableTo": "agent_runs", + "columnsFrom": [ + "agent_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_manifests_task_id_tasks_id_fk": { + "name": "report_manifests_task_id_tasks_id_fk", + "tableFrom": "report_manifests", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_manifests_room_id_rooms_id_fk": { + "name": "report_manifests_room_id_rooms_id_fk", + "tableFrom": "report_manifests", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_manifests_requested_by_actor_id_actors_id_fk": { + "name": "report_manifests_requested_by_actor_id_actors_id_fk", + "tableFrom": "report_manifests", + "tableTo": "actors", + "columnsFrom": [ + "requested_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_manifests_posted_message_id_messages_id_fk": { + "name": "report_manifests_posted_message_id_messages_id_fk", + "tableFrom": "report_manifests", + "tableTo": "messages", + "columnsFrom": [ + "posted_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "report_manifests_status_check": { + "name": "report_manifests_status_check", + "value": "\"report_manifests\".\"status\" in ('draft','reviewed','posted','superseded')" + }, + "report_manifests_version_check": { + "name": "report_manifests_version_check", + "value": "\"report_manifests\".\"version\" > 0" + } + }, + "isRLSEnabled": false + }, + "public.report_schedules": { + "name": "report_schedules", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "cadence": { + "name": "cadence", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "audience": { + "name": "audience", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'leadership'" + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "last_run_at": { + "name": "last_run_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "report_schedules_org_idempotency_unique": { + "name": "report_schedules_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "report_schedules_org_due_idx": { + "name": "report_schedules_org_due_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "report_schedules_organisation_id_organisations_id_fk": { + "name": "report_schedules_organisation_id_organisations_id_fk", + "tableFrom": "report_schedules", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_schedules_room_id_rooms_id_fk": { + "name": "report_schedules_room_id_rooms_id_fk", + "tableFrom": "report_schedules", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "report_schedules_created_by_actor_id_actors_id_fk": { + "name": "report_schedules_created_by_actor_id_actors_id_fk", + "tableFrom": "report_schedules", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "report_schedules_cadence_check": { + "name": "report_schedules_cadence_check", + "value": "\"report_schedules\".\"cadence\" in ('weekly','monthly')" + }, + "report_schedules_audience_check": { + "name": "report_schedules_audience_check", + "value": "\"report_schedules\".\"audience\" in ('analyst','leadership','executive')" + } + }, + "isRLSEnabled": false + }, + "public.research_items": { + "name": "research_items", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "watchlist_id": { + "name": "watchlist_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "research_run_id": { + "name": "research_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "fingerprint": { + "name": "fingerprint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_published_at": { + "name": "source_published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "root_message_id": { + "name": "root_message_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "latest_message_id": { + "name": "latest_message_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "brief": { + "name": "brief", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "feedback": { + "name": "feedback", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "feedback_by_actor_id": { + "name": "feedback_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "feedback_at": { + "name": "feedback_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "research_items_org_fingerprint_unique": { + "name": "research_items_org_fingerprint_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "fingerprint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "research_items_org_watchlist_idx": { + "name": "research_items_org_watchlist_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "watchlist_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "research_items_organisation_id_organisations_id_fk": { + "name": "research_items_organisation_id_organisations_id_fk", + "tableFrom": "research_items", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_items_watchlist_id_research_watchlists_id_fk": { + "name": "research_items_watchlist_id_research_watchlists_id_fk", + "tableFrom": "research_items", + "tableTo": "research_watchlists", + "columnsFrom": [ + "watchlist_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_items_research_run_id_research_runs_id_fk": { + "name": "research_items_research_run_id_research_runs_id_fk", + "tableFrom": "research_items", + "tableTo": "research_runs", + "columnsFrom": [ + "research_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_items_root_message_id_messages_id_fk": { + "name": "research_items_root_message_id_messages_id_fk", + "tableFrom": "research_items", + "tableTo": "messages", + "columnsFrom": [ + "root_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_items_latest_message_id_messages_id_fk": { + "name": "research_items_latest_message_id_messages_id_fk", + "tableFrom": "research_items", + "tableTo": "messages", + "columnsFrom": [ + "latest_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_items_feedback_by_actor_id_actors_id_fk": { + "name": "research_items_feedback_by_actor_id_actors_id_fk", + "tableFrom": "research_items", + "tableTo": "actors", + "columnsFrom": [ + "feedback_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.research_runs": { + "name": "research_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "watchlist_id": { + "name": "watchlist_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_run_id": { + "name": "agent_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "source_limit": { + "name": "source_limit", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "token_budget": { + "name": "token_budget", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "cost_limit_cents": { + "name": "cost_limit_cents", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "time_limit_seconds": { + "name": "time_limit_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "research_runs_org_idempotency_unique": { + "name": "research_runs_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "research_runs_org_agent_unique": { + "name": "research_runs_org_agent_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "research_runs_org_status_idx": { + "name": "research_runs_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "research_runs_organisation_id_organisations_id_fk": { + "name": "research_runs_organisation_id_organisations_id_fk", + "tableFrom": "research_runs", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_runs_watchlist_id_research_watchlists_id_fk": { + "name": "research_runs_watchlist_id_research_watchlists_id_fk", + "tableFrom": "research_runs", + "tableTo": "research_watchlists", + "columnsFrom": [ + "watchlist_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_runs_agent_run_id_agent_runs_id_fk": { + "name": "research_runs_agent_run_id_agent_runs_id_fk", + "tableFrom": "research_runs", + "tableTo": "agent_runs", + "columnsFrom": [ + "agent_run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "research_runs_status_check": { + "name": "research_runs_status_check", + "value": "\"research_runs\".\"status\" in ('queued','running','completed','failed')" + } + }, + "isRLSEnabled": false + }, + "public.research_watchlists": { + "name": "research_watchlists", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "vendors": { + "name": "vendors", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "technologies": { + "name": "technologies", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "sources": { + "name": "sources", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "cadence_minutes": { + "name": "cadence_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 240 + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "last_run_at": { + "name": "last_run_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "research_watchlists_org_name_unique": { + "name": "research_watchlists_org_name_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "research_watchlists_due_idx": { + "name": "research_watchlists_due_idx", + "columns": [ + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "research_watchlists_organisation_id_organisations_id_fk": { + "name": "research_watchlists_organisation_id_organisations_id_fk", + "tableFrom": "research_watchlists", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_watchlists_room_id_rooms_id_fk": { + "name": "research_watchlists_room_id_rooms_id_fk", + "tableFrom": "research_watchlists", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "research_watchlists_created_by_actor_id_actors_id_fk": { + "name": "research_watchlists_created_by_actor_id_actors_id_fk", + "tableFrom": "research_watchlists", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "research_watchlists_cadence_check": { + "name": "research_watchlists_cadence_check", + "value": "\"research_watchlists\".\"cadence_minutes\" between 15 and 10080" + } + }, + "isRLSEnabled": false + }, + "public.room_integration_bindings": { + "name": "room_integration_bindings", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "integration_id": { + "name": "integration_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "room_integration_bindings_org_room_idx": { + "name": "room_integration_bindings_org_room_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "room_integration_bindings_organisation_id_organisations_id_fk": { + "name": "room_integration_bindings_organisation_id_organisations_id_fk", + "tableFrom": "room_integration_bindings", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "room_integration_bindings_room_id_rooms_id_fk": { + "name": "room_integration_bindings_room_id_rooms_id_fk", + "tableFrom": "room_integration_bindings", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "room_integration_bindings_integration_id_integration_records_id_fk": { + "name": "room_integration_bindings_integration_id_integration_records_id_fk", + "tableFrom": "room_integration_bindings", + "tableTo": "integration_records", + "columnsFrom": [ + "integration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "room_integration_bindings_created_by_actor_id_actors_id_fk": { + "name": "room_integration_bindings_created_by_actor_id_actors_id_fk", + "tableFrom": "room_integration_bindings", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "room_integration_bindings_room_id_integration_id_pk": { + "name": "room_integration_bindings_room_id_integration_id_pk", + "columns": [ + "room_id", + "integration_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.room_invitations": { + "name": "room_invitations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "invited_actor_id": { + "name": "invited_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "membership_role": { + "name": "membership_role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_expires_at": { + "name": "access_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by_actor_id": { + "name": "invited_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "responded_at": { + "name": "responded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "room_invitations_org_idempotency_unique": { + "name": "room_invitations_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "room_invitations_org_room_status_idx": { + "name": "room_invitations_org_room_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "room_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "room_invitations_organisation_id_organisations_id_fk": { + "name": "room_invitations_organisation_id_organisations_id_fk", + "tableFrom": "room_invitations", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "room_invitations_room_id_rooms_id_fk": { + "name": "room_invitations_room_id_rooms_id_fk", + "tableFrom": "room_invitations", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "room_invitations_invited_actor_id_actors_id_fk": { + "name": "room_invitations_invited_actor_id_actors_id_fk", + "tableFrom": "room_invitations", + "tableTo": "actors", + "columnsFrom": [ + "invited_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "room_invitations_invited_by_actor_id_actors_id_fk": { + "name": "room_invitations_invited_by_actor_id_actors_id_fk", + "tableFrom": "room_invitations", + "tableTo": "actors", + "columnsFrom": [ + "invited_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "room_invitation_role_check": { + "name": "room_invitation_role_check", + "value": "\"room_invitations\".\"membership_role\" in ('moderator','member','guest','agent_member')" + }, + "room_invitation_status_check": { + "name": "room_invitation_status_check", + "value": "\"room_invitations\".\"status\" in ('pending','accepted','revoked','expired')" + } + }, + "isRLSEnabled": false + }, + "public.room_memberships": { + "name": "room_memberships", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "membership_role": { + "name": "membership_role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "notification_level": { + "name": "notification_level", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'all'" + }, + "notify_replies": { + "name": "notify_replies", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "notify_followed_threads": { + "name": "notify_followed_threads", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_read_event_id": { + "name": "last_read_event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "muted": { + "name": "muted", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "favourite": { + "name": "favourite", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "sidebar_position": { + "name": "sidebar_position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "sidebar_group": { + "name": "sidebar_group", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_expires_at": { + "name": "access_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "room_memberships_org_actor_idx": { + "name": "room_memberships_org_actor_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "room_memberships_organisation_id_organisations_id_fk": { + "name": "room_memberships_organisation_id_organisations_id_fk", + "tableFrom": "room_memberships", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "room_memberships_room_id_rooms_id_fk": { + "name": "room_memberships_room_id_rooms_id_fk", + "tableFrom": "room_memberships", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "room_memberships_actor_id_actors_id_fk": { + "name": "room_memberships_actor_id_actors_id_fk", + "tableFrom": "room_memberships", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "room_memberships_room_id_actor_id_pk": { + "name": "room_memberships_room_id_actor_id_pk", + "columns": [ + "room_id", + "actor_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "room_membership_role_check": { + "name": "room_membership_role_check", + "value": "\"room_memberships\".\"membership_role\" in ('owner','moderator','member','guest','agent_member')" + } + }, + "isRLSEnabled": false + }, + "public.rooms": { + "name": "rooms", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "room_type": { + "name": "room_type", + "type": "room_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'organisation'" + }, + "topic": { + "name": "topic", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "policies": { + "name": "policies", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "direct_fingerprint": { + "name": "direct_fingerprint", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "linked_investigation_id": { + "name": "linked_investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "linked_kelpie_case_id": { + "name": "linked_kelpie_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "default_severity": { + "name": "default_severity", + "type": "severity", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "tlp": { + "name": "tlp", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'amber'" + }, + "retention_policy": { + "name": "retention_policy", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": { + "rooms_org_slug_unique": { + "name": "rooms_org_slug_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "rooms_org_direct_fingerprint_unique": { + "name": "rooms_org_direct_fingerprint_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "direct_fingerprint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"rooms\".\"direct_fingerprint\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "rooms_org_type_idx": { + "name": "rooms_org_type_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "room_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "rooms_organisation_id_organisations_id_fk": { + "name": "rooms_organisation_id_organisations_id_fk", + "tableFrom": "rooms", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "rooms_created_by_actor_id_actors_id_fk": { + "name": "rooms_created_by_actor_id_actors_id_fk", + "tableFrom": "rooms", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_agent_exposures": { + "name": "slack_agent_exposures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "installation_id": { + "name": "installation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "agent_id": { + "name": "agent_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "allowed_channel_ids": { + "name": "allowed_channel_ids", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "allow_direct_messages": { + "name": "allow_direct_messages", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "allow_thread_context": { + "name": "allow_thread_context", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updated_by_actor_id": { + "name": "updated_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "slack_exposures_installation_agent_unique": { + "name": "slack_exposures_installation_agent_unique", + "columns": [ + { + "expression": "installation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_exposures_org_enabled_idx": { + "name": "slack_exposures_org_enabled_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "enabled", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "slack_agent_exposures_organisation_id_organisations_id_fk": { + "name": "slack_agent_exposures_organisation_id_organisations_id_fk", + "tableFrom": "slack_agent_exposures", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_agent_exposures_installation_id_slack_installations_id_fk": { + "name": "slack_agent_exposures_installation_id_slack_installations_id_fk", + "tableFrom": "slack_agent_exposures", + "tableTo": "slack_installations", + "columnsFrom": [ + "installation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_agent_exposures_agent_id_agent_definitions_id_fk": { + "name": "slack_agent_exposures_agent_id_agent_definitions_id_fk", + "tableFrom": "slack_agent_exposures", + "tableTo": "agent_definitions", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_agent_exposures_updated_by_actor_id_actors_id_fk": { + "name": "slack_agent_exposures_updated_by_actor_id_actors_id_fk", + "tableFrom": "slack_agent_exposures", + "tableTo": "actors", + "columnsFrom": [ + "updated_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_identity_mappings": { + "name": "slack_identity_mappings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "installation_id": { + "name": "installation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "slack_user_id": { + "name": "slack_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "slack_identity_installation_user_unique": { + "name": "slack_identity_installation_user_unique", + "columns": [ + { + "expression": "installation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slack_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_identity_org_actor_unique": { + "name": "slack_identity_org_actor_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "slack_identity_mappings_organisation_id_organisations_id_fk": { + "name": "slack_identity_mappings_organisation_id_organisations_id_fk", + "tableFrom": "slack_identity_mappings", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_identity_mappings_installation_id_slack_installations_id_fk": { + "name": "slack_identity_mappings_installation_id_slack_installations_id_fk", + "tableFrom": "slack_identity_mappings", + "tableTo": "slack_installations", + "columnsFrom": [ + "installation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_identity_mappings_actor_id_actors_id_fk": { + "name": "slack_identity_mappings_actor_id_actors_id_fk", + "tableFrom": "slack_identity_mappings", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_identity_mappings_created_by_actor_id_actors_id_fk": { + "name": "slack_identity_mappings_created_by_actor_id_actors_id_fk", + "tableFrom": "slack_identity_mappings", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_inbox_events": { + "name": "slack_inbox_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "installation_id": { + "name": "installation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload_hash": { + "name": "payload_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_payload": { + "name": "encrypted_payload", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "received_at": { + "name": "received_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "slack_inbox_installation_event_unique": { + "name": "slack_inbox_installation_event_unique", + "columns": [ + { + "expression": "installation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_inbox_org_status_idx": { + "name": "slack_inbox_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "received_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "slack_inbox_events_organisation_id_organisations_id_fk": { + "name": "slack_inbox_events_organisation_id_organisations_id_fk", + "tableFrom": "slack_inbox_events", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_inbox_events_installation_id_slack_installations_id_fk": { + "name": "slack_inbox_events_installation_id_slack_installations_id_fk", + "tableFrom": "slack_inbox_events", + "tableTo": "slack_installations", + "columnsFrom": [ + "installation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_installations": { + "name": "slack_installations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "team_name": { + "name": "team_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "enterprise_id": { + "name": "enterprise_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "encrypted_bot_token": { + "name": "encrypted_bot_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_app_token": { + "name": "encrypted_app_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "installed_by_actor_id": { + "name": "installed_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "installed_at": { + "name": "installed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_health_at": { + "name": "last_health_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_delivery_at": { + "name": "last_delivery_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "slack_installations_team_unique": { + "name": "slack_installations_team_unique", + "columns": [ + { + "expression": "team_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_installations_org_status_idx": { + "name": "slack_installations_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "slack_installations_organisation_id_organisations_id_fk": { + "name": "slack_installations_organisation_id_organisations_id_fk", + "tableFrom": "slack_installations", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_installations_installed_by_actor_id_actors_id_fk": { + "name": "slack_installations_installed_by_actor_id_actors_id_fk", + "tableFrom": "slack_installations", + "tableTo": "actors", + "columnsFrom": [ + "installed_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_run_deliveries": { + "name": "slack_run_deliveries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "installation_id": { + "name": "installation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "run_id": { + "name": "run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "inbox_event_id": { + "name": "inbox_event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_ts": { + "name": "thread_ts", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "progress_message_ts": { + "name": "progress_message_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "result_message_ts": { + "name": "result_message_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "last_progress": { + "name": "last_progress", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "attempt_count": { + "name": "attempt_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "slack_delivery_installation_run_unique": { + "name": "slack_delivery_installation_run_unique", + "columns": [ + { + "expression": "installation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_delivery_org_status_idx": { + "name": "slack_delivery_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "slack_run_deliveries_organisation_id_organisations_id_fk": { + "name": "slack_run_deliveries_organisation_id_organisations_id_fk", + "tableFrom": "slack_run_deliveries", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_run_deliveries_installation_id_slack_installations_id_fk": { + "name": "slack_run_deliveries_installation_id_slack_installations_id_fk", + "tableFrom": "slack_run_deliveries", + "tableTo": "slack_installations", + "columnsFrom": [ + "installation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_run_deliveries_run_id_agent_runs_id_fk": { + "name": "slack_run_deliveries_run_id_agent_runs_id_fk", + "tableFrom": "slack_run_deliveries", + "tableTo": "agent_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "slack_run_deliveries_inbox_event_id_slack_inbox_events_id_fk": { + "name": "slack_run_deliveries_inbox_event_id_slack_inbox_events_id_fk", + "tableFrom": "slack_run_deliveries", + "tableTo": "slack_inbox_events", + "columnsFrom": [ + "inbox_event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.synthetic_artifact_provenance": { + "name": "synthetic_artifact_provenance", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "artifact_table": { + "name": "artifact_table", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "artifact_id": { + "name": "artifact_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source_kind": { + "name": "source_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_reference": { + "name": "source_reference", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "recorded_by_actor_id": { + "name": "recorded_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "recorded_at": { + "name": "recorded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "synthetic_artifact_provenance_artifact_unique": { + "name": "synthetic_artifact_provenance_artifact_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "artifact_table", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "artifact_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "synthetic_artifact_provenance_organisation_id_organisations_id_fk": { + "name": "synthetic_artifact_provenance_organisation_id_organisations_id_fk", + "tableFrom": "synthetic_artifact_provenance", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "synthetic_artifact_provenance_recorded_by_actor_id_actors_id_fk": { + "name": "synthetic_artifact_provenance_recorded_by_actor_id_actors_id_fk", + "tableFrom": "synthetic_artifact_provenance", + "tableTo": "actors", + "columnsFrom": [ + "recorded_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "synthetic_artifact_provenance_table_check": { + "name": "synthetic_artifact_provenance_table_check", + "value": "\"synthetic_artifact_provenance\".\"artifact_table\" in ('rooms','tasks','hunts','integrations','researchWatchlists','reportManifests','reportSchedules','messages','evidence','agentMemories','actors')" + }, + "synthetic_artifact_provenance_source_check": { + "name": "synthetic_artifact_provenance_source_check", + "value": "\"synthetic_artifact_provenance\".\"source_kind\" in ('seed_fixture','mock_runtime','test_fixture','legacy_live_proof')" + } + }, + "isRLSEnabled": false + }, + "public.synthetic_cleanup_object_deletion_attempts": { + "name": "synthetic_cleanup_object_deletion_attempts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "manifest_id": { + "name": "manifest_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "evidence_id": { + "name": "evidence_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version_id": { + "name": "version_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "authorization_approval_id": { + "name": "authorization_approval_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "error_code": { + "name": "error_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "attempted_by_actor_id": { + "name": "attempted_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attempted_at": { + "name": "attempted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "synthetic_cleanup_object_attempts_manifest_idx": { + "name": "synthetic_cleanup_object_attempts_manifest_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "manifest_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "attempted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "synthetic_cleanup_object_deletion_attempts_manifest_id_synthetic_cleanup_receipts_manifest_id_fk": { + "name": "synthetic_cleanup_object_deletion_attempts_manifest_id_synthetic_cleanup_receipts_manifest_id_fk", + "tableFrom": "synthetic_cleanup_object_deletion_attempts", + "tableTo": "synthetic_cleanup_receipts", + "columnsFrom": [ + "manifest_id" + ], + "columnsTo": [ + "manifest_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "synthetic_cleanup_object_deletion_attempts_organisation_id_organisations_id_fk": { + "name": "synthetic_cleanup_object_deletion_attempts_organisation_id_organisations_id_fk", + "tableFrom": "synthetic_cleanup_object_deletion_attempts", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "synthetic_cleanup_object_deletion_attempts_authorization_approval_id_approvals_id_fk": { + "name": "synthetic_cleanup_object_deletion_attempts_authorization_approval_id_approvals_id_fk", + "tableFrom": "synthetic_cleanup_object_deletion_attempts", + "tableTo": "approvals", + "columnsFrom": [ + "authorization_approval_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "synthetic_cleanup_object_deletion_attempts_attempted_by_actor_id_actors_id_fk": { + "name": "synthetic_cleanup_object_deletion_attempts_attempted_by_actor_id_actors_id_fk", + "tableFrom": "synthetic_cleanup_object_deletion_attempts", + "tableTo": "actors", + "columnsFrom": [ + "attempted_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "synthetic_cleanup_object_attempts_result_check": { + "name": "synthetic_cleanup_object_attempts_result_check", + "value": "\"synthetic_cleanup_object_deletion_attempts\".\"result\" in ('started','succeeded','failed','observed_missing')" + } + }, + "isRLSEnabled": false + }, + "public.synthetic_cleanup_receipts": { + "name": "synthetic_cleanup_receipts", + "schema": "", + "columns": { + "manifest_id": { + "name": "manifest_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "approval_id": { + "name": "approval_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "maintenance_actor_id": { + "name": "maintenance_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "manifest_digest": { + "name": "manifest_digest", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "manifest": { + "name": "manifest", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "candidate_counts": { + "name": "candidate_counts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "pre_digests": { + "name": "pre_digests", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "post_digests": { + "name": "post_digests", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "object_storage_objects": { + "name": "object_storage_objects", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "trace_id": { + "name": "trace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "applied_at": { + "name": "applied_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "synthetic_cleanup_receipts_approval_unique": { + "name": "synthetic_cleanup_receipts_approval_unique", + "columns": [ + { + "expression": "approval_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "synthetic_cleanup_receipts_org_digest_unique": { + "name": "synthetic_cleanup_receipts_org_digest_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "manifest_digest", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "synthetic_cleanup_receipts_organisation_id_organisations_id_fk": { + "name": "synthetic_cleanup_receipts_organisation_id_organisations_id_fk", + "tableFrom": "synthetic_cleanup_receipts", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "synthetic_cleanup_receipts_approval_id_approvals_id_fk": { + "name": "synthetic_cleanup_receipts_approval_id_approvals_id_fk", + "tableFrom": "synthetic_cleanup_receipts", + "tableTo": "approvals", + "columnsFrom": [ + "approval_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "synthetic_cleanup_receipts_maintenance_actor_id_actors_id_fk": { + "name": "synthetic_cleanup_receipts_maintenance_actor_id_actors_id_fk", + "tableFrom": "synthetic_cleanup_receipts", + "tableTo": "actors", + "columnsFrom": [ + "maintenance_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "status": { + "name": "status", + "type": "task_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'backlog'" + }, + "priority": { + "name": "priority", + "type": "task_priority", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'normal'" + }, + "assigned_actor_id": { + "name": "assigned_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_by_actor_id": { + "name": "created_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "investigation_id": { + "name": "investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "related_case_id": { + "name": "related_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approval_required": { + "name": "approval_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "due_at": { + "name": "due_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "agent_run_id": { + "name": "agent_run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_run_status": { + "name": "agent_run_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tasks_org_status_idx": { + "name": "tasks_org_status_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tasks_org_assignee_idx": { + "name": "tasks_org_assignee_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "assigned_actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tasks_org_idempotency_unique": { + "name": "tasks_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tasks_organisation_id_organisations_id_fk": { + "name": "tasks_organisation_id_organisations_id_fk", + "tableFrom": "tasks", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_assigned_actor_id_actors_id_fk": { + "name": "tasks_assigned_actor_id_actors_id_fk", + "tableFrom": "tasks", + "tableTo": "actors", + "columnsFrom": [ + "assigned_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_created_by_actor_id_actors_id_fk": { + "name": "tasks_created_by_actor_id_actors_id_fk", + "tableFrom": "tasks", + "tableTo": "actors", + "columnsFrom": [ + "created_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_room_id_rooms_id_fk": { + "name": "tasks_room_id_rooms_id_fk", + "tableFrom": "tasks", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tasks_investigation_id_investigations_id_fk": { + "name": "tasks_investigation_id_investigations_id_fk", + "tableFrom": "tasks", + "tableTo": "investigations", + "columnsFrom": [ + "investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.thread_follows": { + "name": "thread_follows", + "schema": "", + "columns": { + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "root_message_id": { + "name": "root_message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "thread_follows_org_actor_idx": { + "name": "thread_follows_org_actor_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "actor_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "thread_follows_organisation_id_organisations_id_fk": { + "name": "thread_follows_organisation_id_organisations_id_fk", + "tableFrom": "thread_follows", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "thread_follows_root_message_id_messages_id_fk": { + "name": "thread_follows_root_message_id_messages_id_fk", + "tableFrom": "thread_follows", + "tableTo": "messages", + "columnsFrom": [ + "root_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "thread_follows_actor_id_actors_id_fk": { + "name": "thread_follows_actor_id_actors_id_fk", + "tableFrom": "thread_follows", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "thread_follows_root_message_id_actor_id_pk": { + "name": "thread_follows_root_message_id_actor_id_pk", + "columns": [ + "root_message_id", + "actor_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.timeline_events": { + "name": "timeline_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "investigation_id": { + "name": "investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "external_case_id": { + "name": "external_case_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "occurred_at": { + "name": "occurred_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "timeline_org_investigation_time_idx": { + "name": "timeline_org_investigation_time_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "investigation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "occurred_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "timeline_events_organisation_id_organisations_id_fk": { + "name": "timeline_events_organisation_id_organisations_id_fk", + "tableFrom": "timeline_events", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "timeline_events_investigation_id_investigations_id_fk": { + "name": "timeline_events_investigation_id_investigations_id_fk", + "tableFrom": "timeline_events", + "tableTo": "investigations", + "columnsFrom": [ + "investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "timeline_events_room_id_rooms_id_fk": { + "name": "timeline_events_room_id_rooms_id_fk", + "tableFrom": "timeline_events", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "timeline_events_actor_id_actors_id_fk": { + "name": "timeline_events_actor_id_actors_id_fk", + "tableFrom": "timeline_events", + "tableTo": "actors", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "better_auth_user_id": { + "name": "better_auth_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avatar": { + "name": "avatar", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "job_title": { + "name": "job_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "team": { + "name": "team", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "presence_state": { + "name": "presence_state", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'offline'" + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Australia/Sydney'" + }, + "notification_preferences": { + "name": "notification_preferences", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_active_at": { + "name": "last_active_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_org_email_unique": { + "name": "users_org_email_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_better_auth_unique": { + "name": "users_better_auth_unique", + "columns": [ + { + "expression": "better_auth_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_org_idx": { + "name": "users_org_idx", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_organisation_id_organisations_id_fk": { + "name": "users_organisation_id_organisations_id_fk", + "tableFrom": "users", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_better_auth_user_id_auth_user_id_fk": { + "name": "users_better_auth_user_id_auth_user_id_fk", + "tableFrom": "users", + "tableTo": "auth_user", + "columnsFrom": [ + "better_auth_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_definitions": { + "name": "workflow_definitions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workflow_key": { + "name": "workflow_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "yaml": { + "name": "yaml", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "parsed": { + "name": "parsed", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "owner_actor_id": { + "name": "owner_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workflow_defs_org_key_version_unique": { + "name": "workflow_defs_org_key_version_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "workflow_key", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "version", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_definitions_organisation_id_organisations_id_fk": { + "name": "workflow_definitions_organisation_id_organisations_id_fk", + "tableFrom": "workflow_definitions", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workflow_definitions_owner_actor_id_actors_id_fk": { + "name": "workflow_definitions_owner_actor_id_actors_id_fk", + "tableFrom": "workflow_definitions", + "tableTo": "actors", + "columnsFrom": [ + "owner_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workflow_runs": { + "name": "workflow_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "organisation_id": { + "name": "organisation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workflow_definition_id": { + "name": "workflow_definition_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "trigger_event_id": { + "name": "trigger_event_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "room_id": { + "name": "room_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "investigation_id": { + "name": "investigation_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "requested_by_actor_id": { + "name": "requested_by_actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workflow_runs_org_idempotency_unique": { + "name": "workflow_runs_org_idempotency_unique", + "columns": [ + { + "expression": "organisation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workflow_runs_organisation_id_organisations_id_fk": { + "name": "workflow_runs_organisation_id_organisations_id_fk", + "tableFrom": "workflow_runs", + "tableTo": "organisations", + "columnsFrom": [ + "organisation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workflow_runs_workflow_definition_id_workflow_definitions_id_fk": { + "name": "workflow_runs_workflow_definition_id_workflow_definitions_id_fk", + "tableFrom": "workflow_runs", + "tableTo": "workflow_definitions", + "columnsFrom": [ + "workflow_definition_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workflow_runs_room_id_rooms_id_fk": { + "name": "workflow_runs_room_id_rooms_id_fk", + "tableFrom": "workflow_runs", + "tableTo": "rooms", + "columnsFrom": [ + "room_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workflow_runs_investigation_id_investigations_id_fk": { + "name": "workflow_runs_investigation_id_investigations_id_fk", + "tableFrom": "workflow_runs", + "tableTo": "investigations", + "columnsFrom": [ + "investigation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "workflow_runs_requested_by_actor_id_actors_id_fk": { + "name": "workflow_runs_requested_by_actor_id_actors_id_fk", + "tableFrom": "workflow_runs", + "tableTo": "actors", + "columnsFrom": [ + "requested_by_actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.actor_type": { + "name": "actor_type", + "schema": "public", + "values": [ + "human", + "agent", + "product", + "service", + "system" + ] + }, + "public.alert_status": { + "name": "alert_status", + "schema": "public", + "values": [ + "new", + "acknowledged", + "investigating", + "dismissed", + "promoted", + "closed" + ] + }, + "public.approval_status": { + "name": "approval_status", + "schema": "public", + "values": [ + "pending", + "approved", + "rejected", + "expired", + "cancelled", + "executed", + "failed" + ] + }, + "public.investigation_status": { + "name": "investigation_status", + "schema": "public", + "values": [ + "open", + "triaging", + "investigating", + "awaiting_approval", + "promoted", + "closed" + ] + }, + "public.message_type": { + "name": "message_type", + "schema": "public", + "values": [ + "text", + "system", + "alert", + "finding", + "decision", + "approval", + "workflow", + "agent-status", + "query-result", + "evidence", + "case-event", + "response-action" + ] + }, + "public.room_type": { + "name": "room_type", + "schema": "public", + "values": [ + "operations", + "incident", + "investigation", + "hunt", + "engineering", + "private", + "direct", + "system" + ] + }, + "public.severity": { + "name": "severity", + "schema": "public", + "values": [ + "critical", + "high", + "medium", + "low", + "informational" + ] + }, + "public.task_priority": { + "name": "task_priority", + "schema": "public", + "values": [ + "urgent", + "high", + "normal", + "low" + ] + }, + "public.task_status": { + "name": "task_status", + "schema": "public", + "values": [ + "backlog", + "ready", + "in_progress", + "review", + "done" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.json index 2deb543..1512e28 100644 --- a/packages/database/migrations/meta/_journal.json +++ b/packages/database/migrations/meta/_journal.json @@ -148,6 +148,13 @@ "when": 1785130091064, "tag": "0020_ancient_carnage", "breakpoints": true + }, + { + "idx": 21, + "version": "7", + "when": 1785212240489, + "tag": "0021_dazzling_living_mummy", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/database/src/index.ts b/packages/database/src/index.ts index fd85b3f..5e4fe54 100644 --- a/packages/database/src/index.ts +++ b/packages/database/src/index.ts @@ -5,14 +5,23 @@ import * as schema from "./schema.ts"; let pool: Pool | undefined; export function database() { - pool ??= new Pool({ - connectionString: - process.env.DATABASE_URL ?? - "postgresql://muster:muster@localhost:5432/muster", - max: Number(process.env.DATABASE_POOL_SIZE ?? 20), - statement_timeout: 15_000, - application_name: "muster", - }); + if (!pool) { + pool = new Pool({ + connectionString: + process.env.DATABASE_URL ?? + "postgresql://muster:muster@localhost:5432/muster", + max: Number(process.env.DATABASE_POOL_SIZE ?? 20), + statement_timeout: 15_000, + application_name: "muster", + }); + // node-postgres requires an error listener on the pool: an idle client + // error (a database restart, a network blip) is otherwise an unhandled + // 'error' event, which crashes the entire process rather than letting a + // health check or the next query simply fail. + pool.on("error", (error) => { + console.error("pg.pool.error", error.message); + }); + } return drizzle(pool, { schema }); } diff --git a/packages/database/src/schema.ts b/packages/database/src/schema.ts index 5c91d01..0c13bd7 100644 --- a/packages/database/src/schema.ts +++ b/packages/database/src/schema.ts @@ -3,6 +3,7 @@ import { bigint, boolean, check, + foreignKey, index, integer, jsonb, @@ -242,6 +243,12 @@ export const actors = pgTable( uniqueIndex("actors_org_identity_unique") .on(table.organisationId, table.identityReference) .where(sql`${table.identityReference} is not null`), + // Lets other tables declare a composite FK on (actorId, organisationId) + // so Postgres itself rejects a cross-organisation actor reference. + uniqueIndex("actors_id_organisation_unique").on( + table.id, + table.organisationId, + ), ], ); @@ -1283,8 +1290,12 @@ export const slackAgentExposures = pgTable( enabled: boolean("enabled").notNull().default(true), isDefault: boolean("is_default").notNull().default(false), allowedChannelIds: jsonb("allowed_channel_ids").notNull().default([]), - allowDirectMessages: boolean("allow_direct_messages").notNull().default(true), - allowThreadContext: boolean("allow_thread_context").notNull().default(false), + allowDirectMessages: boolean("allow_direct_messages") + .notNull() + .default(true), + allowThreadContext: boolean("allow_thread_context") + .notNull() + .default(false), updatedByActorId: uuid("updated_by_actor_id") .notNull() .references(() => actors.id), @@ -1983,6 +1994,55 @@ export const integrationConnectorCredentials = pgTable( ], ); +export const mcpInstallations = pgTable( + "mcp_installations", + { + id: uuid("id").primaryKey(), + organisationId: uuid("organisation_id") + .notNull() + .references(() => organisations.id), + name: text("name").notNull(), + tokenHash: text("token_hash").notNull(), + tokenPrefix: text("token_prefix").notNull(), + scopes: jsonb("scopes").notNull().default([]), + boundActorId: uuid("bound_actor_id").notNull(), + status: text("status").notNull().default("active"), + installedByActorId: uuid("installed_by_actor_id").notNull(), + installedAt: timestamp("installed_at", { withTimezone: true }) + .defaultNow() + .notNull(), + lastUsedAt: timestamp("last_used_at", { withTimezone: true }), + revokedAt: timestamp("revoked_at", { withTimezone: true }), + revokedByActorId: uuid("revoked_by_actor_id"), + ...timestamps, + }, + (table) => [ + uniqueIndex("mcp_installations_token_hash_unique").on(table.tokenHash), + index("mcp_installations_org_status_idx").on( + table.organisationId, + table.status, + ), + // Composite FKs (actorId, organisationId) -> actors(id, organisationId) + // so Postgres itself rejects binding, installing, or revoking with an + // actor from a different organisation, on top of the application check. + foreignKey({ + name: "mcp_installations_bound_actor_org_fk", + columns: [table.boundActorId, table.organisationId], + foreignColumns: [actors.id, actors.organisationId], + }), + foreignKey({ + name: "mcp_installations_installed_by_actor_org_fk", + columns: [table.installedByActorId, table.organisationId], + foreignColumns: [actors.id, actors.organisationId], + }), + foreignKey({ + name: "mcp_installations_revoked_by_actor_org_fk", + columns: [table.revokedByActorId, table.organisationId], + foreignColumns: [actors.id, actors.organisationId], + }), + ], +); + export const integrationQueryTemplates = pgTable( "integration_query_templates", { diff --git a/packages/database/src/seed.ts b/packages/database/src/seed.ts index 94cc238..3beb3e3 100644 --- a/packages/database/src/seed.ts +++ b/packages/database/src/seed.ts @@ -1,5 +1,5 @@ import { database, closeDatabase, schema } from "./index.ts"; -import { demoDirectRoomSeeds, demoIds } from "./seed-data.ts"; +import { demoDirectRoomSeeds, demoIds, starterIds } from "./seed-data.ts"; import { sql } from "drizzle-orm"; if (process.env.MUSTER_DEMO_MODE !== "true") { @@ -9,6 +9,25 @@ if (process.env.MUSTER_DEMO_MODE !== "true") { } const db = database(); + +// Demo mode is intentionally seeded on top of the clean-install bootstrap used +// by release CI. The browser tests and demo UI use the demonstration workspace, +// so remove the two bootstrap identifiers that would otherwise collide with the +// demo fixtures when tests look up the authenticated admin actor or the default +// SOC room by their public identifiers. +await db + .update(schema.actors) + .set({ identityReference: "starter-admin@muster.local" }) + .where(sql`${schema.actors.id} = ${starterIds.actors.jordan}`); +await db + .update(schema.rooms) + .set({ + name: "starter-soc-operations", + slug: "starter-soc-operations", + displayName: "Starter SOC operations", + }) + .where(sql`${schema.rooms.id} = ${starterIds.rooms.soc}`); + const allCapabilities = [ "administration.manage", "rooms.read", diff --git a/packages/database/src/verify-clean-install.ts b/packages/database/src/verify-clean-install.ts index 15940e7..6d7bd3b 100644 --- a/packages/database/src/verify-clean-install.ts +++ b/packages/database/src/verify-clean-install.ts @@ -43,6 +43,7 @@ const operationalTables = { idempotencyRecords: schema.idempotencyRecords, outboxEvents: schema.outboxEvents, auditEvents: schema.auditEvents, + mcpInstallations: schema.mcpInstallations, } as const; const db = database(); diff --git a/packages/mcp/package.json b/packages/mcp/package.json new file mode 100644 index 0000000..43359b4 --- /dev/null +++ b/packages/mcp/package.json @@ -0,0 +1,38 @@ +{ + "name": "@muster/mcp", + "version": "0.1.0", + "private": true, + "type": "module", + "exports": { + ".": { + "types": "./src/index.ts", + "development": "./src/index.ts", + "default": "./dist/index.js" + } + }, + "scripts": { + "build": "tsc -p tsconfig.json", + "typecheck": "tsc -p tsconfig.json --noEmit", + "lint": "tsc -p tsconfig.json --noEmit", + "test": "vitest run", + "create-installation": "tsx src/cli-create-installation.ts", + "revoke-installation": "tsx src/cli-revoke-installation.ts" + }, + "dependencies": { + "@modelcontextprotocol/sdk": "1.30.0", + "@muster/audit": "workspace:*", + "@muster/authz": "workspace:*", + "@muster/config": "workspace:*", + "@muster/contracts": "workspace:*", + "@muster/database": "workspace:*", + "@muster/integrations": "workspace:*", + "drizzle-orm": "catalog:", + "zod": "4.4.3" + }, + "devDependencies": { + "@types/node": "^24.0.0", + "tsx": "^4.20.6", + "typescript": "catalog:", + "vitest": "4.1.10" + } +} diff --git a/packages/mcp/src/audit.ts b/packages/mcp/src/audit.ts new file mode 100644 index 0000000..405d568 --- /dev/null +++ b/packages/mcp/src/audit.ts @@ -0,0 +1,53 @@ +import { createHash } from "node:crypto"; +import { appendAuditEvent, database } from "@muster/database"; +import { MCP_TOOL_VERSIONS, type McpToolName } from "./constants.ts"; +import type { InstallationContext } from "./installation.ts"; + +type Database = ReturnType; + +export type InvocationOutcome = "success" | "denied" | "error"; + +/** + * Persists one organisation-scoped invocation/audit record per tool call: + * tool + version, installation/actor, outcome, a hash of the returned + * payload, and evidence references. Never the model's reasoning or prompt. + */ +export async function recordInvocation( + db: Database, + context: InstallationContext, + input: { + tool: McpToolName; + outcome: InvocationOutcome; + resultPayload?: unknown; + errorCode?: string | undefined; + evidenceRefs?: readonly string[] | undefined; + traceId: string; + }, +): Promise { + const resultHash = + input.resultPayload === undefined + ? undefined + : createHash("sha256") + .update(JSON.stringify(input.resultPayload)) + .digest("hex"); + await db.transaction(async (tx) => { + await appendAuditEvent(tx, { + organisationId: context.subject.organisationId, + actorId: context.subject.actorId, + actorType: context.actorType, + action: "mcp.tool.invoked", + targetType: "mcp_tool", + targetId: input.tool, + metadata: { + tool: input.tool, + toolVersion: MCP_TOOL_VERSIONS[input.tool], + installationId: context.installationId, + outcome: input.outcome, + ...(resultHash ? { resultHash } : {}), + evidenceRefs: input.evidenceRefs ?? [], + ...(input.errorCode ? { errorCode: input.errorCode } : {}), + }, + traceId: input.traceId, + }); + }); +} diff --git a/packages/mcp/src/cli-create-installation.ts b/packages/mcp/src/cli-create-installation.ts new file mode 100644 index 0000000..9bb9e9e --- /dev/null +++ b/packages/mcp/src/cli-create-installation.ts @@ -0,0 +1,53 @@ +import { randomUUID } from "node:crypto"; +import { closeDatabase, database } from "@muster/database"; +import { createInstallation } from "./installation.ts"; + +function arg(name: string): string | undefined { + const prefix = `--${name}=`; + return process.argv + .find((value) => value.startsWith(prefix)) + ?.slice(prefix.length); +} + +async function main() { + const organisationId = arg("org"); + const boundActorId = arg("actor"); + const name = arg("name") ?? "Hermes MCP installation"; + const installedByActorId = arg("installed-by") ?? boundActorId; + if (!organisationId || !boundActorId || !installedByActorId) { + console.error( + "Usage: pnpm --filter @muster/mcp create-installation --org= --actor= [--name=