From 6299154b409a26096d719eb23c07a0de66672137 Mon Sep 17 00:00:00 2001 From: Yousef Abdelhadi Date: Sat, 26 Sep 2026 00:58:40 -0400 Subject: [PATCH] Enforce Gen 2 workspace limits and cleanup --- apps/web/app/gen2/[workspaceId]/page.tsx | 7 +- apps/web/app/gen2/gen2.css | 17 + apps/web/app/gen2/page.tsx | 3 + .../gen2/create-workspace-form.test.tsx | 15 + .../components/gen2/create-workspace-form.tsx | 15 +- .../components/gen2/workspace-list.test.tsx | 73 + apps/web/components/gen2/workspace-list.tsx | 56 +- apps/web/components/gen2/workspace-room.tsx | 1 + apps/web/lib/gen2/constants.ts | 2 + apps/web/lib/gen2/instance-lifecycle.test.ts | 12 + apps/web/lib/gen2/workspaces.test.ts | 228 +- apps/web/lib/gen2/workspaces.ts | 131 +- apps/web/lib/runtime/fake-guest.ts | 3 + docs/gen2-workspace.md | 15 +- packages/contracts/src/gen2.ts | 1 + packages/db/drizzle/0054_long_gressill.sql | 1 + packages/db/drizzle/meta/0054_snapshot.json | 9254 +++++++++++++++++ packages/db/drizzle/meta/_journal.json | 9 +- packages/db/src/schema.ts | 1 + .../orchestrator/src/backend/firecracker.rs | 3 +- 20 files changed, 9774 insertions(+), 73 deletions(-) create mode 100644 apps/web/components/gen2/workspace-list.test.tsx create mode 100644 apps/web/lib/gen2/constants.ts create mode 100644 packages/db/drizzle/0054_long_gressill.sql create mode 100644 packages/db/drizzle/meta/0054_snapshot.json diff --git a/apps/web/app/gen2/[workspaceId]/page.tsx b/apps/web/app/gen2/[workspaceId]/page.tsx index 59e0635d4..f712ce7f3 100644 --- a/apps/web/app/gen2/[workspaceId]/page.tsx +++ b/apps/web/app/gen2/[workspaceId]/page.tsx @@ -1,10 +1,10 @@ import type { Metadata } from "next"; -import { notFound } from "next/navigation"; +import { notFound, redirect } from "next/navigation"; import { Gen2WorkspaceRoom } from "@/components/gen2/workspace-room"; import { AppChrome } from "@/components/shell/app-chrome"; import { requireUser } from "@/lib/auth/session"; -import { Gen2AccessError } from "@/lib/gen2/errors"; +import { Gen2AccessError, Gen2LifecycleError } from "@/lib/gen2/errors"; import { getGen2WorkspaceDetail } from "@/lib/gen2/workspaces"; export const metadata: Metadata = { title: "Workspace" }; @@ -21,6 +21,9 @@ export default async function Gen2WorkspacePage({ workspace = await getGen2WorkspaceDetail(workspaceId, user.id); } catch (error) { if (error instanceof Gen2AccessError) notFound(); + if (error instanceof Gen2LifecycleError && error.status === 409) { + redirect("/gen2"); + } throw error; } diff --git a/apps/web/app/gen2/gen2.css b/apps/web/app/gen2/gen2.css index 05cf28abb..df8573cc3 100644 --- a/apps/web/app/gen2/gen2.css +++ b/apps/web/app/gen2/gen2.css @@ -107,6 +107,11 @@ border-color: var(--line-strong); } +.gen2-card-pending { + cursor: default; + opacity: 0.72; +} + .gen2-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; @@ -168,6 +173,14 @@ color: var(--muted); } +.gen2-create-limit { + flex-basis: 100%; + margin: 0; + color: var(--muted); + font-size: 0.875rem; + line-height: 1.5; +} + .gen2-room-header { display: flex; flex-wrap: wrap; @@ -204,6 +217,10 @@ background: #ef4444; } +.gen2-status-deleting .gen2-status-dot { + background: #ef4444; +} + .gen2-note { margin: 0; color: var(--muted); diff --git a/apps/web/app/gen2/page.tsx b/apps/web/app/gen2/page.tsx index 1a12a37cd..66e46d768 100644 --- a/apps/web/app/gen2/page.tsx +++ b/apps/web/app/gen2/page.tsx @@ -29,6 +29,9 @@ export default async function Gen2WorkspacesPage() {

workspace.role === "owner").length + } appSlug={process.env.GITHUB_APP_SLUG} connectGitHub={connectGitHubAccount.bind(null, "/gen2")} /> diff --git a/apps/web/components/gen2/create-workspace-form.test.tsx b/apps/web/components/gen2/create-workspace-form.test.tsx index 58f15a54d..7169c0dbc 100644 --- a/apps/web/components/gen2/create-workspace-form.test.tsx +++ b/apps/web/components/gen2/create-workspace-form.test.tsx @@ -50,6 +50,21 @@ describe("CreateGen2WorkspaceForm", () => { ); }); + it("blocks workspace creation when the owner limit is reached", () => { + render( + , + ); + expect( + screen.getByRole("button", { name: /Blank workspace/ }), + ).toBeDisabled(); + expect(screen.getByRole("status")).toHaveTextContent( + "You own 2 of 2 Gen 2 workspaces. Delete one to create another.", + ); + }); + it("offers GitHub when it is not connected yet", () => { render(); expect( diff --git a/apps/web/components/gen2/create-workspace-form.tsx b/apps/web/components/gen2/create-workspace-form.tsx index eb3f6b7e5..febeafdb0 100644 --- a/apps/web/components/gen2/create-workspace-form.tsx +++ b/apps/web/components/gen2/create-workspace-form.tsx @@ -5,6 +5,7 @@ import { useRouter } from "next/navigation"; import { Plus, Search } from "lucide-react"; import { GithubMark } from "@/components/settings/github-mark"; +import { GEN2_MAX_OWNED_WORKSPACES } from "@/lib/gen2/constants"; type Installation = { id: number; @@ -27,10 +28,12 @@ type Repository = { */ export function CreateGen2WorkspaceForm({ githubConnected, + ownedWorkspaceCount = 0, appSlug, connectGitHub, }: { githubConnected: boolean; + ownedWorkspaceCount?: number; appSlug?: string | undefined; /** * The bound `connectGitHubAccount` server action, handed down rather than @@ -40,6 +43,7 @@ export function CreateGen2WorkspaceForm({ connectGitHub?: (() => void) | undefined; }) { const router = useRouter(); + const atWorkspaceLimit = ownedWorkspaceCount >= GEN2_MAX_OWNED_WORKSPACES; const [installations, setInstallations] = useState([]); const [installationId, setInstallationId] = useState(null); const [repositories, setRepositories] = useState([]); @@ -118,7 +122,7 @@ export function CreateGen2WorkspaceForm({ ) : null} + {deletionPending && !error ? ( +

+ {workspace.lastError + ? "Deletion did not finish. Retry deletion to continue." + : "Workspace deletion is in progress."} +

+ ) : null} {error ? (

{error} diff --git a/apps/web/components/gen2/workspace-room.tsx b/apps/web/components/gen2/workspace-room.tsx index 0de0f7011..35bc8864a 100644 --- a/apps/web/components/gen2/workspace-room.tsx +++ b/apps/web/components/gen2/workspace-room.tsx @@ -14,6 +14,7 @@ const STATUS_LABEL: Record = { ready: "Ready", failed: "Failed", stopped: "Starting", + deleting: "Deleting", }; export function Gen2WorkspaceRoom({ diff --git a/apps/web/lib/gen2/constants.ts b/apps/web/lib/gen2/constants.ts new file mode 100644 index 000000000..b8a43e0f5 --- /dev/null +++ b/apps/web/lib/gen2/constants.ts @@ -0,0 +1,2 @@ +/** Maximum number of Gen 2 workspaces a user may own at once. */ +export const GEN2_MAX_OWNED_WORKSPACES = 2; diff --git a/apps/web/lib/gen2/instance-lifecycle.test.ts b/apps/web/lib/gen2/instance-lifecycle.test.ts index bb09fd35b..6d450b238 100644 --- a/apps/web/lib/gen2/instance-lifecycle.test.ts +++ b/apps/web/lib/gen2/instance-lifecycle.test.ts @@ -208,6 +208,18 @@ describe("gen2 instance lifecycle", () => { expect(mocks.updates).toEqual([]); }); + it("does not restart a workspace once deletion has begun", async () => { + mocks.member.status = "deleting"; + await expect( + ensureGen2Instance(mocks.member.id, "user-1", { + provision: mocks.provision, + destroy: mocks.destroy, + }), + ).rejects.toMatchObject({ status: 409 }); + expect(mocks.ensureHostReady).not.toHaveBeenCalled(); + expect(mocks.provision).not.toHaveBeenCalled(); + }); + it("leaves a ready workspace untouched when runtime verification succeeds", async () => { mocks.member.status = "ready"; mocks.member.sandboxId = "sandbox-1"; diff --git a/apps/web/lib/gen2/workspaces.test.ts b/apps/web/lib/gen2/workspaces.test.ts index dbfcdd857..dae1f5bed 100644 --- a/apps/web/lib/gen2/workspaces.test.ts +++ b/apps/web/lib/gen2/workspaces.test.ts @@ -3,9 +3,23 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; const mocks = vi.hoisted(() => ({ inserted: [] as Array<{ table: string; values: Record }>, + events: [] as string[], failCreate: false, + failDiscard: false, + ownedCount: 0, + currentStatus: "pending", + memberStatus: "pending", + memberRole: "owner", + memberLastError: null as string | null, createInviteToken: vi.fn(() => "share-token"), hashInviteToken: vi.fn((token: string) => `hash:${token}`), + destroySandbox: vi.fn(async () => { + mocks.events.push("destroy"); + }), + discardSandboxSnapshot: vi.fn(async () => { + mocks.events.push("discard-snapshot"); + if (mocks.failDiscard) throw new Error("orchestrator unavailable"); + }), })); vi.mock("../platform/crypto", () => ({ @@ -17,49 +31,140 @@ vi.mock("../platform/observability", () => ({ logEvent: vi.fn(), })); -vi.mock("../platform/database", () => ({ - getDatabase: () => ({ - transaction: async (callback: (transaction: unknown) => unknown) => { - if (mocks.failCreate) { - throw new Error( - 'Failed query: insert into "gen2_workspaces" params: [user-1,Workspace]', - ); - } - const transaction = { - insert: (table: Parameters[0]) => ({ - values: (values: Record) => { - const tableName = getTableName(table); - mocks.inserted.push({ table: tableName, values }); - if (tableName === "gen2_workspaces") { - return { - returning: async () => [ - { - id: "11111111-1111-4111-8111-111111111111", - status: "pending", - sandboxId: null, - lastError: null, - createdAt: new Date("2026-09-20T20:00:00.000Z"), - updatedAt: new Date("2026-09-20T20:00:00.000Z"), - ...values, +vi.mock("../runtime/orchestrator-sandbox", () => ({ + destroySandbox: mocks.destroySandbox, + discardSandboxSnapshot: mocks.discardSandboxSnapshot, +})); + +vi.mock("../platform/database", () => { + function selectedRows( + table: Parameters[0], + selection: Record, + ) { + const tableName = getTableName(table); + if (tableName === "users") return [{ id: "user-1" }]; + if ("count" in selection) return [{ count: mocks.ownedCount }]; + return [{ ownerId: "user-1", status: mocks.currentStatus }]; + } + + function update(table: Parameters[0]) { + return { + set: (values: Record) => ({ + where: async () => { + mocks.events.push(`update:${getTableName(table)}`); + if (values.status) mocks.currentStatus = String(values.status); + if (values.lastError) + mocks.memberLastError = String(values.lastError); + }, + }), + }; + } + + return { + getDatabase: () => ({ + transaction: async (callback: (transaction: unknown) => unknown) => { + if (mocks.failCreate) { + throw new Error( + 'Failed query: insert into "gen2_workspaces" params: [user-1,Workspace]', + ); + } + const transaction = { + select: (selection: Record) => ({ + from: (table: Parameters[0]) => ({ + where: () => { + const rows = selectedRows(table, selection); + if ("count" in selection) mocks.events.push("count-owned"); + return Object.assign(Promise.resolve(rows), { + for: async () => { + mocks.events.push( + getTableName(table) === "users" + ? "lock-owner" + : "lock-delete-row", + ); + return rows; }, - ], - }; - } - return Promise.resolve(); - }, + }); + }, + }), + }), + insert: (table: Parameters[0]) => ({ + values: (values: Record) => { + const tableName = getTableName(table); + mocks.events.push(`insert:${tableName}`); + mocks.inserted.push({ table: tableName, values }); + if (tableName === "gen2_workspaces") { + return { + returning: async () => [ + { + id: "11111111-1111-4111-8111-111111111111", + status: "pending", + sandboxId: null, + lastError: null, + createdAt: new Date("2026-09-20T20:00:00.000Z"), + updatedAt: new Date("2026-09-20T20:00:00.000Z"), + ...values, + }, + ], + }; + } + return Promise.resolve(); + }, + }), + update, + }; + return callback(transaction); + }, + select: () => ({ + from: () => ({ + innerJoin: () => ({ + where: () => ({ + limit: async () => [ + { + id: "11111111-1111-4111-8111-111111111111", + name: "Studio", + status: mocks.memberStatus, + sandboxId: null, + lastError: mocks.memberLastError, + role: mocks.memberRole, + repository: null, + repositoryPrivate: false, + defaultBranch: null, + createdAt: new Date("2026-09-20T20:00:00.000Z"), + updatedAt: new Date("2026-09-20T20:00:00.000Z"), + }, + ], + }), + }), }), - }; - return callback(transaction); - }, - }), -})); + }), + update, + delete: () => ({ + where: async () => { + mocks.events.push("delete-row"); + }, + }), + }), + }; +}); -import { createGen2Workspace, defaultGen2WorkspaceName } from "./workspaces"; +import { + createGen2Workspace, + defaultGen2WorkspaceName, + deleteGen2Workspace, +} from "./workspaces"; -describe("gen2 workspace creation", () => { +describe("gen2 workspaces", () => { beforeEach(() => { mocks.inserted.length = 0; + mocks.events.length = 0; mocks.failCreate = false; + mocks.failDiscard = false; + mocks.ownedCount = 0; + mocks.currentStatus = "pending"; + mocks.memberStatus = "pending"; + mocks.memberRole = "owner"; + mocks.memberLastError = null; + vi.clearAllMocks(); }); it("defaults the name when none is given", () => { @@ -67,7 +172,7 @@ describe("gen2 workspace creation", () => { expect(defaultGen2WorkspaceName(" Studio ")).toBe("Studio"); }); - it("creates a workspace row and an owner membership", async () => { + it("locks the owner before counting and creating a workspace", async () => { const workspace = await createGen2Workspace("user-1", "Studio"); expect(workspace).toMatchObject({ id: "11111111-1111-4111-8111-111111111111", @@ -76,6 +181,11 @@ describe("gen2 workspace creation", () => { role: "owner", sandboxId: null, }); + expect(mocks.events.slice(0, 3)).toEqual([ + "lock-owner", + "count-owned", + "insert:gen2_workspaces", + ]); expect(mocks.inserted).toEqual([ { table: "gen2_workspaces", @@ -92,6 +202,50 @@ describe("gen2 workspace creation", () => { ]); }); + it("rejects a third owned workspace without writing rows", async () => { + mocks.ownedCount = 2; + await expect(createGen2Workspace("user-1")).rejects.toMatchObject({ + message: + "You can own up to 2 Gen 2 workspaces. Delete one to create another.", + status: 409, + }); + expect(mocks.inserted).toHaveLength(0); + }); + + it("stops the guest and purges its snapshot before deleting the row", async () => { + await deleteGen2Workspace("11111111-1111-4111-8111-111111111111", "user-1"); + expect(mocks.events).toEqual([ + "lock-delete-row", + "update:gen2_workspaces", + "destroy", + "discard-snapshot", + "delete-row", + ]); + }); + + it("keeps failed deletions retryable and only then frees the slot", async () => { + mocks.failDiscard = true; + await expect( + deleteGen2Workspace("11111111-1111-4111-8111-111111111111", "user-1"), + ).rejects.toMatchObject({ status: 502 }); + expect(mocks.events).not.toContain("delete-row"); + expect(mocks.memberLastError).toMatch(/Retry deletion/); + + mocks.failDiscard = false; + mocks.memberStatus = "deleting"; + mocks.currentStatus = "deleting"; + await deleteGen2Workspace("11111111-1111-4111-8111-111111111111", "user-1"); + expect(mocks.events).toContain("delete-row"); + }); + + it("does not delete a workspace while it is provisioning", async () => { + mocks.memberStatus = "provisioning"; + await expect( + deleteGen2Workspace("11111111-1111-4111-8111-111111111111", "user-1"), + ).rejects.toMatchObject({ status: 409 }); + expect(mocks.destroySandbox).not.toHaveBeenCalled(); + }); + it("does not surface the database query when creation fails", async () => { mocks.failCreate = true; await expect(createGen2Workspace("user-1")).rejects.toMatchObject({ diff --git a/apps/web/lib/gen2/workspaces.ts b/apps/web/lib/gen2/workspaces.ts index 66969e270..d013a773e 100644 --- a/apps/web/lib/gen2/workspaces.ts +++ b/apps/web/lib/gen2/workspaces.ts @@ -1,6 +1,6 @@ import "server-only"; -import { and, eq } from "drizzle-orm"; +import { and, count, eq } from "drizzle-orm"; import { gen2WorkspaceDetailSchema, @@ -14,7 +14,11 @@ import { createInviteToken, hashInviteToken } from "../platform/crypto"; import { getRepository } from "../github/github"; import { getDatabase } from "../platform/database"; import { logEvent } from "../platform/observability"; -import { destroySandbox } from "../runtime/orchestrator-sandbox"; +import { + destroySandbox, + discardSandboxSnapshot, +} from "../runtime/orchestrator-sandbox"; +import { GEN2_MAX_OWNED_WORKSPACES } from "./constants"; import { Gen2AccessError, Gen2LifecycleError } from "./errors"; const DEFAULT_WORKSPACE_NAME = "Workspace"; @@ -52,6 +56,24 @@ export async function createGen2Workspace( ); try { const workspace = await getDatabase().transaction(async (transaction) => { + // Serialize creates for this owner so two simultaneous requests cannot + // both observe the last available slot. + await transaction + .select({ id: schema.users.id }) + .from(schema.users) + .where(eq(schema.users.id, userId)) + .for("update"); + const [owned] = await transaction + .select({ count: count() }) + .from(schema.gen2Workspaces) + .where(eq(schema.gen2Workspaces.ownerId, userId)); + if ((owned?.count ?? 0) >= GEN2_MAX_OWNED_WORKSPACES) { + throw new Gen2LifecycleError( + `You can own up to ${GEN2_MAX_OWNED_WORKSPACES} Gen 2 workspaces. Delete one to create another.`, + 409, + ); + } + const [created] = await transaction .insert(schema.gen2Workspaces) .values({ @@ -118,7 +140,11 @@ export async function listGen2WorkspacesForUser(userId: string) { return rows.map((row) => toWorkspace(row, row.role)); } -export async function requireGen2Member(workspaceId: string, userId: string) { +export async function requireGen2Member( + workspaceId: string, + userId: string, + options: { allowDeleting?: boolean } = {}, +) { const [row] = await getDatabase() .select({ id: schema.gen2Workspaces.id, @@ -148,6 +174,9 @@ export async function requireGen2Member(workspaceId: string, userId: string) { if (!row) { throw new Gen2AccessError(); } + if (row.status === "deleting" && !options.allowDeleting) { + throw new Gen2LifecycleError("This workspace is being deleted."); + } return toWorkspace(row, row.role); } @@ -176,18 +205,91 @@ export async function getGen2WorkspaceDetail( } export async function deleteGen2Workspace(workspaceId: string, userId: string) { - const workspace = await requireGen2Member(workspaceId, userId); + const workspace = await requireGen2Member(workspaceId, userId, { + allowDeleting: true, + }); if (workspace.role !== "owner") { throw new Gen2AccessError("Only the owner can delete this workspace.", 403); } + if (workspace.status === "provisioning") { + throw new Gen2LifecycleError( + "Wait for the workspace to finish starting before deleting it.", + ); + } - // The sandbox owns the workspace files and hibernation snapshot. Destroy it - // before removing the database row so a runtime failure leaves the workspace - // visible and retryable instead of orphaning its machine. - await destroySandbox(workspaceId); - await getDatabase() - .delete(schema.gen2Workspaces) - .where(eq(schema.gen2Workspaces.id, workspaceId)); + const database = getDatabase(); + await database.transaction(async (transaction) => { + const [current] = await transaction + .select({ + ownerId: schema.gen2Workspaces.ownerId, + status: schema.gen2Workspaces.status, + }) + .from(schema.gen2Workspaces) + .where(eq(schema.gen2Workspaces.id, workspaceId)) + .for("update"); + if (!current) throw new Gen2AccessError(); + if (current.ownerId !== userId) { + throw new Gen2AccessError( + "Only the owner can delete this workspace.", + 403, + ); + } + if (current.status === "provisioning") { + throw new Gen2LifecycleError( + "Wait for the workspace to finish starting before deleting it.", + ); + } + if (current.status !== "deleting") { + await transaction + .update(schema.gen2Workspaces) + .set({ status: "deleting", lastError: null, updatedAt: new Date() }) + .where(eq(schema.gen2Workspaces.id, workspaceId)); + } + }); + + try { + // Stop a live guest, then remove its hibernation snapshot. The normal stop + // path intentionally preserves that snapshot for resume; deletion must + // purge it before freeing the owner's workspace slot. + await destroySandbox(workspaceId); + await discardSandboxSnapshot(workspaceId); + await database + .delete(schema.gen2Workspaces) + .where( + and( + eq(schema.gen2Workspaces.id, workspaceId), + eq(schema.gen2Workspaces.ownerId, userId), + eq(schema.gen2Workspaces.status, "deleting"), + ), + ); + } catch (error) { + logEvent("error", "gen2.workspace.delete_failed", { + detail: error instanceof Error ? error.message : "unknown", + }); + try { + await database + .update(schema.gen2Workspaces) + .set({ + lastError: + "Deletion did not finish. Retry deletion from the workspace list.", + updatedAt: new Date(), + }) + .where( + and( + eq(schema.gen2Workspaces.id, workspaceId), + eq(schema.gen2Workspaces.status, "deleting"), + ), + ); + } catch (updateError) { + logEvent("error", "gen2.workspace.delete_status_failed", { + detail: updateError instanceof Error ? updateError.message : "unknown", + }); + } + throw new Gen2LifecycleError( + "Couldn't fully delete this workspace. Retry deletion from the workspace list.", + 502, + ); + } } export async function createGen2ShareLink( @@ -220,12 +322,17 @@ export async function joinGen2Workspace(token: string, userId: string) { const [workspace] = await getDatabase() .select({ id: schema.gen2Workspaces.id, + status: schema.gen2Workspaces.status, activeInviteExpiresAt: schema.gen2Workspaces.activeInviteExpiresAt, }) .from(schema.gen2Workspaces) .where(eq(schema.gen2Workspaces.activeInviteTokenHash, tokenHash)) .limit(1); - if (!workspace || !workspaceInviteIsActive(workspace.activeInviteExpiresAt)) { + if ( + !workspace || + workspace.status === "deleting" || + !workspaceInviteIsActive(workspace.activeInviteExpiresAt) + ) { throw new Gen2AccessError("This invite link is no longer valid.", 404); } diff --git a/apps/web/lib/runtime/fake-guest.ts b/apps/web/lib/runtime/fake-guest.ts index 6e8523c9a..38060fd90 100644 --- a/apps/web/lib/runtime/fake-guest.ts +++ b/apps/web/lib/runtime/fake-guest.ts @@ -297,6 +297,9 @@ export function handleFakeGuestRequest( sandboxes.delete(workspaceId); return new Response(null, { status: 204 }); } + if (method === "DELETE" && rest === "/snapshot") { + return new Response(null, { status: 204 }); + } const sandbox = require(workspaceId); const input = payload as Record; diff --git a/docs/gen2-workspace.md b/docs/gen2-workspace.md index 0fd2374e2..253db6532 100644 --- a/docs/gen2-workspace.md +++ b/docs/gen2-workspace.md @@ -1,7 +1,7 @@ # Gen 2 workspace **Status:** Current -**Date:** 2026-09-21 +**Date:** 2026-09-26 Gen 2 is a new workspace, isolated from `lib/workspaces`. The product is: @@ -30,6 +30,11 @@ the file the agent just edited. - Create a workspace from a GitHub repository (public repositories are cloned by the host, private ones arrive as a bounded snapshot the control plane fetched, so no GitHub token enters the VM) +- Own up to two Gen 2 workspaces at a time; shared workspaces do not count +- Delete an owned workspace to remove its guest and saved disk snapshots and + free an ownership slot +- Run up to six active sandboxes per host; idle guests hibernate after 15 + minutes and a quiet host deallocates after one minute - Upload a local file onto the machine - A workbench beside the chat — file tree with Git status, a CodeMirror 6 editor with revision-checked saves, a shell, and a live Git status/diff @@ -40,8 +45,10 @@ Opening a workspace is the intent to use it, so `ensureGen2Instance` runs on open and is safe for any member to call -- the person who follows a share link should not have to wait for the owner to press something. The composer is never disabled either: type into a cold workspace and the machine is brought -up as part of sending. The orchestrator pauses an idle guest after four hours -on its own, so nothing needs stopping by hand. +up as part of sending. The orchestrator hibernates an idle guest after 15 +minutes, preserving its workspace disk while releasing its sandbox slot. A +host with no active sandboxes deallocates after one quiet minute. Opening the +workspace resumes it from the saved disk. ## Interface @@ -107,7 +114,7 @@ stack against it. ## Out of scope -Gen 1 agent sessions, worktrees, GitHub, hibernation, OpenFGA, the original +Gen 1 agent sessions, worktrees, GitHub, OpenFGA, the original `workspaces` table, and the embedded Orca IDE. Concurrent agents: the guest serialises Codex (`start_codex_exec` waits on diff --git a/packages/contracts/src/gen2.ts b/packages/contracts/src/gen2.ts index 6f70bae2e..705c3cc47 100644 --- a/packages/contracts/src/gen2.ts +++ b/packages/contracts/src/gen2.ts @@ -8,6 +8,7 @@ export const gen2WorkspaceStatusSchema = z.enum([ "ready", "failed", "stopped", + "deleting", ]); export const gen2WorkspaceRoleSchema = z.enum(["owner", "editor", "viewer"]); diff --git a/packages/db/drizzle/0054_long_gressill.sql b/packages/db/drizzle/0054_long_gressill.sql new file mode 100644 index 000000000..79b1f4cce --- /dev/null +++ b/packages/db/drizzle/0054_long_gressill.sql @@ -0,0 +1 @@ +ALTER TYPE "public"."gen2_workspace_status" ADD VALUE 'deleting'; \ No newline at end of file diff --git a/packages/db/drizzle/meta/0054_snapshot.json b/packages/db/drizzle/meta/0054_snapshot.json new file mode 100644 index 000000000..a9a40bb99 --- /dev/null +++ b/packages/db/drizzle/meta/0054_snapshot.json @@ -0,0 +1,9254 @@ +{ + "id": "1674b5e5-d9da-486a-b8f2-26ec5255f90b", + "prevId": "eff266ba-2201-441a-af4b-1d834ca420f4", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.access_requests": { + "name": "access_requests", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "github_login": { + "name": "github_login", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "persona": { + "name": "persona", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "building": { + "name": "building", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "referrer": { + "name": "referrer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip_hash": { + "name": "ip_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "access_request_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "invited_at": { + "name": "invited_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "invite_token_hash": { + "name": "invite_token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invite_token_expires_at": { + "name": "invite_token_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_at": { + "name": "accepted_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": { + "access_requests_email_idx": { + "name": "access_requests_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "access_requests_status_created_idx": { + "name": "access_requests_status_created_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "access_requests_ip_created_idx": { + "name": "access_requests_ip_created_idx", + "columns": [ + { + "expression": "ip_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "access_requests_invite_token_hash_idx": { + "name": "access_requests_invite_token_hash_idx", + "columns": [ + { + "expression": "invite_token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_briefs": { + "name": "agent_briefs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "goal": { + "name": "goal", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "approach_summary": { + "name": "approach_summary", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "plan_steps": { + "name": "plan_steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "current_step": { + "name": "current_step", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "files_likely_to_touch": { + "name": "files_likely_to_touch", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "keywords": { + "name": "keywords", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "status": { + "name": "status", + "type": "agent_brief_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'planning'" + }, + "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_briefs_session_idx": { + "name": "agent_briefs_session_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_briefs_workspace_status_idx": { + "name": "agent_briefs_workspace_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_briefs_workspace_id_workspaces_id_fk": { + "name": "agent_briefs_workspace_id_workspaces_id_fk", + "tableFrom": "agent_briefs", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_briefs_session_id_agent_sessions_id_fk": { + "name": "agent_briefs_session_id_agent_sessions_id_fk", + "tableFrom": "agent_briefs", + "tableTo": "agent_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_events": { + "name": "agent_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "turn_id": { + "name": "turn_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_events_idempotency_idx": { + "name": "agent_events_idempotency_idx", + "columns": [ + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_events_session_created_idx": { + "name": "agent_events_session_created_idx", + "columns": [ + { + "expression": "session_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_events_workspace_id_workspaces_id_fk": { + "name": "agent_events_workspace_id_workspaces_id_fk", + "tableFrom": "agent_events", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_events_session_id_agent_sessions_id_fk": { + "name": "agent_events_session_id_agent_sessions_id_fk", + "tableFrom": "agent_events", + "tableTo": "agent_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_events_turn_id_agent_turns_id_fk": { + "name": "agent_events_turn_id_agent_turns_id_fk", + "tableFrom": "agent_events", + "tableTo": "agent_turns", + "columnsFrom": [ + "turn_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_session_import_artifacts": { + "name": "agent_session_import_artifacts", + "schema": "", + "columns": { + "import_id": { + "name": "import_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "media_type": { + "name": "media_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "plaintext_sha256": { + "name": "plaintext_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "plaintext_bytes": { + "name": "plaintext_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "encrypted_payload": { + "name": "encrypted_payload", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "agent_session_import_artifacts_created_idx": { + "name": "agent_session_import_artifacts_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_session_import_artifacts_import_id_agent_session_imports_id_fk": { + "name": "agent_session_import_artifacts_import_id_agent_session_imports_id_fk", + "tableFrom": "agent_session_import_artifacts", + "tableTo": "agent_session_imports", + "columnsFrom": [ + "import_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_session_imports": { + "name": "agent_session_imports", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "imported_by": { + "name": "imported_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "parent_import_id": { + "name": "parent_import_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "worktree_id": { + "name": "worktree_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "agent_session_id": { + "name": "agent_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "source_provider": { + "name": "source_provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_session_id": { + "name": "external_session_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "capsule_schema_version": { + "name": "capsule_schema_version", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "capsule_sha256": { + "name": "capsule_sha256", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "agent_session_import_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'storing'" + }, + "repository_status": { + "name": "repository_status", + "type": "repository_restore_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "continuation_mode": { + "name": "continuation_mode", + "type": "session_continuation_mode", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_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": { + "agent_session_imports_idempotency_idx": { + "name": "agent_session_imports_idempotency_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "imported_by", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_session_imports_workspace_status_idx": { + "name": "agent_session_imports_workspace_status_idx", + "columns": [ + { + "expression": "workspace_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": {} + }, + "agent_session_imports_importer_idx": { + "name": "agent_session_imports_importer_idx", + "columns": [ + { + "expression": "imported_by", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_session_imports_source_idx": { + "name": "agent_session_imports_source_idx", + "columns": [ + { + "expression": "imported_by", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_session_imports_parent_idx": { + "name": "agent_session_imports_parent_idx", + "columns": [ + { + "expression": "parent_import_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_session_imports_active_writer_idx": { + "name": "agent_session_imports_active_writer_idx", + "columns": [ + { + "expression": "imported_by", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "external_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"agent_session_imports\".\"continuation_mode\" = 'native_resume' and \"agent_session_imports\".\"status\" in ('launching', 'active') and \"agent_session_imports\".\"deleted_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_session_imports_organization_id_organizations_id_fk": { + "name": "agent_session_imports_organization_id_organizations_id_fk", + "tableFrom": "agent_session_imports", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "agent_session_imports_workspace_id_workspaces_id_fk": { + "name": "agent_session_imports_workspace_id_workspaces_id_fk", + "tableFrom": "agent_session_imports", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_session_imports_imported_by_users_id_fk": { + "name": "agent_session_imports_imported_by_users_id_fk", + "tableFrom": "agent_session_imports", + "tableTo": "users", + "columnsFrom": [ + "imported_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "agent_session_imports_parent_import_id_agent_session_imports_id_fk": { + "name": "agent_session_imports_parent_import_id_agent_session_imports_id_fk", + "tableFrom": "agent_session_imports", + "tableTo": "agent_session_imports", + "columnsFrom": [ + "parent_import_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "agent_session_imports_worktree_id_worktrees_id_fk": { + "name": "agent_session_imports_worktree_id_worktrees_id_fk", + "tableFrom": "agent_session_imports", + "tableTo": "worktrees", + "columnsFrom": [ + "worktree_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "agent_session_imports_agent_session_id_agent_sessions_id_fk": { + "name": "agent_session_imports_agent_session_id_agent_sessions_id_fk", + "tableFrom": "agent_session_imports", + "tableTo": "agent_sessions", + "columnsFrom": [ + "agent_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_sessions": { + "name": "agent_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "worktree_id": { + "name": "worktree_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "issue_number": { + "name": "issue_number", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'Agent'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'gpt-5'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'openai'" + }, + "kind": { + "name": "kind", + "type": "agent_session_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'managed'" + }, + "status": { + "name": "status", + "type": "agent_session_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'idle'" + }, + "workflow_run_id": { + "name": "workflow_run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interrupted_at": { + "name": "interrupted_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": { + "agent_sessions_workspace_issue_idx": { + "name": "agent_sessions_workspace_issue_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "issue_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_sessions_workspace_status_idx": { + "name": "agent_sessions_workspace_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "agent_sessions_workspace_id_workspaces_id_fk": { + "name": "agent_sessions_workspace_id_workspaces_id_fk", + "tableFrom": "agent_sessions", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_sessions_worktree_id_worktrees_id_fk": { + "name": "agent_sessions_worktree_id_worktrees_id_fk", + "tableFrom": "agent_sessions", + "tableTo": "worktrees", + "columnsFrom": [ + "worktree_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_sessions_created_by_users_id_fk": { + "name": "agent_sessions_created_by_users_id_fk", + "tableFrom": "agent_sessions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_turns": { + "name": "agent_turns", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attachments": { + "name": "attachments", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "status": { + "name": "status", + "type": "agent_turn_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "workflow_run_id": { + "name": "workflow_run_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "response_id": { + "name": "response_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output": { + "name": "output", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "finished_at": { + "name": "finished_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": { + "agent_turns_session_created_idx": { + "name": "agent_turns_session_created_idx", + "columns": [ + { + "expression": "session_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_turns_session_id_agent_sessions_id_fk": { + "name": "agent_turns_session_id_agent_sessions_id_fk", + "tableFrom": "agent_turns", + "tableTo": "agent_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "agent_turns_author_id_users_id_fk": { + "name": "agent_turns_author_id_users_id_fk", + "tableFrom": "agent_turns", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.brain_entries": { + "name": "brain_entries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "brain_entry_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "paths": { + "name": "paths", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "keywords": { + "name": "keywords", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "supersedes_id": { + "name": "supersedes_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "brain_entries_workspace_created_idx": { + "name": "brain_entries_workspace_created_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "brain_entries_workspace_kind_idx": { + "name": "brain_entries_workspace_kind_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "brain_entries_workspace_id_workspaces_id_fk": { + "name": "brain_entries_workspace_id_workspaces_id_fk", + "tableFrom": "brain_entries", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "brain_entries_session_id_agent_sessions_id_fk": { + "name": "brain_entries_session_id_agent_sessions_id_fk", + "tableFrom": "brain_entries", + "tableTo": "agent_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "brain_entries_author_id_users_id_fk": { + "name": "brain_entries_author_id_users_id_fk", + "tableFrom": "brain_entries", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.brain_overlaps": { + "name": "brain_overlaps", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "left_session_id": { + "name": "left_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "right_session_id": { + "name": "right_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "brain_overlap_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "score": { + "name": "score", + "type": "real", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "evidence": { + "name": "evidence", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "status": { + "name": "status", + "type": "brain_overlap_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "detected_at": { + "name": "detected_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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": { + "brain_overlaps_pair_kind_idx": { + "name": "brain_overlaps_pair_kind_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "left_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "right_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "brain_overlaps_workspace_status_idx": { + "name": "brain_overlaps_workspace_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "brain_overlaps_workspace_id_workspaces_id_fk": { + "name": "brain_overlaps_workspace_id_workspaces_id_fk", + "tableFrom": "brain_overlaps", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "brain_overlaps_left_session_id_agent_sessions_id_fk": { + "name": "brain_overlaps_left_session_id_agent_sessions_id_fk", + "tableFrom": "brain_overlaps", + "tableTo": "agent_sessions", + "columnsFrom": [ + "left_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "brain_overlaps_right_session_id_agent_sessions_id_fk": { + "name": "brain_overlaps_right_session_id_agent_sessions_id_fk", + "tableFrom": "brain_overlaps", + "tableTo": "agent_sessions", + "columnsFrom": [ + "right_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.claude_connection_sessions": { + "name": "claude_connection_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "scope_type": { + "name": "scope_type", + "type": "credential_scope_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'USER'" + }, + "scope_id": { + "name": "scope_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "claude_connection_session_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'starting'" + }, + "runner_id": { + "name": "runner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "authorize_url": { + "name": "authorize_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "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": { + "claude_connection_sessions_user_idx": { + "name": "claude_connection_sessions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "claude_connection_sessions_expiry_idx": { + "name": "claude_connection_sessions_expiry_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "claude_connection_sessions_user_id_users_id_fk": { + "name": "claude_connection_sessions_user_id_users_id_fk", + "tableFrom": "claude_connection_sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cli_access_tokens": { + "name": "cli_access_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'CoDev CLI'" + }, + "client_type": { + "name": "client_type", + "type": "cli_client_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'cli'" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "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 + }, + "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": { + "cli_access_tokens_token_hash_idx": { + "name": "cli_access_tokens_token_hash_idx", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cli_access_tokens_user_idx": { + "name": "cli_access_tokens_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cli_access_tokens_expiry_idx": { + "name": "cli_access_tokens_expiry_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cli_access_tokens_user_id_users_id_fk": { + "name": "cli_access_tokens_user_id_users_id_fk", + "tableFrom": "cli_access_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.cli_device_authorizations": { + "name": "cli_device_authorizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "device_code_hash": { + "name": "device_code_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_code": { + "name": "user_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "cli_device_authorization_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "client_type": { + "name": "client_type", + "type": "cli_client_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'cli'" + }, + "approved_by": { + "name": "approved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "consumed_at": { + "name": "consumed_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": { + "cli_device_authorizations_device_code_idx": { + "name": "cli_device_authorizations_device_code_idx", + "columns": [ + { + "expression": "device_code_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cli_device_authorizations_user_code_idx": { + "name": "cli_device_authorizations_user_code_idx", + "columns": [ + { + "expression": "user_code", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "cli_device_authorizations_expiry_idx": { + "name": "cli_device_authorizations_expiry_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cli_device_authorizations_approved_by_users_id_fk": { + "name": "cli_device_authorizations_approved_by_users_id_fk", + "tableFrom": "cli_device_authorizations", + "tableTo": "users", + "columnsFrom": [ + "approved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.collaboration_conflict_resolutions": { + "name": "collaboration_conflict_resolutions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "worktree_id": { + "name": "worktree_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by": { + "name": "resolved_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "strategy": { + "name": "strategy", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "snapshot_revision": { + "name": "snapshot_revision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "filesystem_revision": { + "name": "filesystem_revision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_revision": { + "name": "result_revision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "collaboration_conflict_resolutions_document_idx": { + "name": "collaboration_conflict_resolutions_document_idx", + "columns": [ + { + "expression": "worktree_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk": { + "name": "collaboration_conflict_resolutions_worktree_id_worktrees_id_fk", + "tableFrom": "collaboration_conflict_resolutions", + "tableTo": "worktrees", + "columnsFrom": [ + "worktree_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "collaboration_conflict_resolutions_resolved_by_users_id_fk": { + "name": "collaboration_conflict_resolutions_resolved_by_users_id_fk", + "tableFrom": "collaboration_conflict_resolutions", + "tableTo": "users", + "columnsFrom": [ + "resolved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_artifacts": { + "name": "conversation_artifacts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "downloadable": { + "name": "downloadable", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "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": { + "conversation_artifacts_conversation_idx": { + "name": "conversation_artifacts_conversation_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "conversation_artifacts_message_idx": { + "name": "conversation_artifacts_message_idx", + "columns": [ + { + "expression": "message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_artifacts_conversation_id_conversations_id_fk": { + "name": "conversation_artifacts_conversation_id_conversations_id_fk", + "tableFrom": "conversation_artifacts", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversation_artifacts_message_id_conversation_messages_id_fk": { + "name": "conversation_artifacts_message_id_conversation_messages_id_fk", + "tableFrom": "conversation_artifacts", + "tableTo": "conversation_messages", + "columnsFrom": [ + "message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversation_messages": { + "name": "conversation_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "sequence": { + "name": "sequence", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_user_id": { + "name": "author_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_name": { + "name": "author_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_content_type": { + "name": "source_content_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_created_at": { + "name": "source_created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "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()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "conversation_messages_sequence_idx": { + "name": "conversation_messages_sequence_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sequence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversation_messages_conversation_id_conversations_id_fk": { + "name": "conversation_messages_conversation_id_conversations_id_fk", + "tableFrom": "conversation_messages", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "conversation_messages_author_user_id_users_id_fk": { + "name": "conversation_messages_author_user_id_users_id_fk", + "tableFrom": "conversation_messages", + "tableTo": "users", + "columnsFrom": [ + "author_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.conversations": { + "name": "conversations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "owner_id": { + "name": "owner_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'imported'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source_provider": { + "name": "source_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_external_id": { + "name": "source_external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_url": { + "name": "source_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_model": { + "name": "source_model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source_updated_at": { + "name": "source_updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "warnings": { + "name": "warnings", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "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": { + "conversations_owner_updated_idx": { + "name": "conversations_owner_updated_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "conversations_owner_source_idx": { + "name": "conversations_owner_source_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source_external_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "conversations_owner_id_users_id_fk": { + "name": "conversations_owner_id_users_id_fk", + "tableFrom": "conversations", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.coordination_messages": { + "name": "coordination_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "from_session_id": { + "name": "from_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "to_session_id": { + "name": "to_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "correlation_id": { + "name": "correlation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "response_to_id": { + "name": "response_to_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "coordination_message_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "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": { + "coordination_messages_target_status_idx": { + "name": "coordination_messages_target_status_idx", + "columns": [ + { + "expression": "to_session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "coordination_messages_workspace_id_workspaces_id_fk": { + "name": "coordination_messages_workspace_id_workspaces_id_fk", + "tableFrom": "coordination_messages", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "coordination_messages_from_session_id_agent_sessions_id_fk": { + "name": "coordination_messages_from_session_id_agent_sessions_id_fk", + "tableFrom": "coordination_messages", + "tableTo": "agent_sessions", + "columnsFrom": [ + "from_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "coordination_messages_to_session_id_agent_sessions_id_fk": { + "name": "coordination_messages_to_session_id_agent_sessions_id_fk", + "tableFrom": "coordination_messages", + "tableTo": "agent_sessions", + "columnsFrom": [ + "to_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.design_partner_feedback": { + "name": "design_partner_feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rating": { + "name": "rating", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "release": { + "name": "release", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'new'" + }, + "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": { + "design_partner_feedback_user_created_idx": { + "name": "design_partner_feedback_user_created_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "design_partner_feedback_status_created_idx": { + "name": "design_partner_feedback_status_created_idx", + "columns": [ + { + "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": { + "design_partner_feedback_user_id_users_id_fk": { + "name": "design_partner_feedback_user_id_users_id_fk", + "tableFrom": "design_partner_feedback", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "design_partner_feedback_workspace_id_workspaces_id_fk": { + "name": "design_partner_feedback_workspace_id_workspaces_id_fk", + "tableFrom": "design_partner_feedback", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feature_override_audit_events": { + "name": "feature_override_audit_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "target_user_id": { + "name": "target_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "feature": { + "name": "feature", + "type": "feature_key", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "feature_override_audit_action", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "previous_enabled": { + "name": "previous_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "previous_expires_at": { + "name": "previous_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_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": { + "feature_override_audit_org_created_idx": { + "name": "feature_override_audit_org_created_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "feature_override_audit_user_created_idx": { + "name": "feature_override_audit_user_created_idx", + "columns": [ + { + "expression": "target_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "feature_override_audit_events_organization_id_organizations_id_fk": { + "name": "feature_override_audit_events_organization_id_organizations_id_fk", + "tableFrom": "feature_override_audit_events", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "feature_override_audit_events_target_user_id_users_id_fk": { + "name": "feature_override_audit_events_target_user_id_users_id_fk", + "tableFrom": "feature_override_audit_events", + "tableTo": "users", + "columnsFrom": [ + "target_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "feature_override_audit_events_actor_user_id_users_id_fk": { + "name": "feature_override_audit_events_actor_user_id_users_id_fk", + "tableFrom": "feature_override_audit_events", + "tableTo": "users", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.gen2_agent_turns": { + "name": "gen2_agent_turns", + "schema": "", + "columns": { + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "output": { + "name": "output", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "pending_base64": { + "name": "pending_base64", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "exited": { + "name": "exited", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reply_message_id": { + "name": "reply_message_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": { + "gen2_agent_turns_chat_idx": { + "name": "gen2_agent_turns_chat_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk": { + "name": "gen2_agent_turns_workspace_id_gen2_workspaces_id_fk", + "tableFrom": "gen2_agent_turns", + "tableTo": "gen2_workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "gen2_agent_turns_chat_id_gen2_chats_id_fk": { + "name": "gen2_agent_turns_chat_id_gen2_chats_id_fk", + "tableFrom": "gen2_agent_turns", + "tableTo": "gen2_chats", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "gen2_agent_turns_user_id_users_id_fk": { + "name": "gen2_agent_turns_user_id_users_id_fk", + "tableFrom": "gen2_agent_turns", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk": { + "name": "gen2_agent_turns_reply_message_id_gen2_chat_messages_id_fk", + "tableFrom": "gen2_agent_turns", + "tableTo": "gen2_chat_messages", + "columnsFrom": [ + "reply_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.gen2_chat_messages": { + "name": "gen2_chat_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "chat_id": { + "name": "chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "items": { + "name": "items", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "gen2_chat_messages_chat_idx": { + "name": "gen2_chat_messages_chat_idx", + "columns": [ + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "gen2_chat_messages_chat_id_gen2_chats_id_fk": { + "name": "gen2_chat_messages_chat_id_gen2_chats_id_fk", + "tableFrom": "gen2_chat_messages", + "tableTo": "gen2_chats", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.gen2_chats": { + "name": "gen2_chats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by_user_id": { + "name": "created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "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": { + "gen2_chats_workspace_updated_idx": { + "name": "gen2_chats_workspace_updated_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "gen2_chats_workspace_id_gen2_workspaces_id_fk": { + "name": "gen2_chats_workspace_id_gen2_workspaces_id_fk", + "tableFrom": "gen2_chats", + "tableTo": "gen2_workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "gen2_chats_created_by_user_id_users_id_fk": { + "name": "gen2_chats_created_by_user_id_users_id_fk", + "tableFrom": "gen2_chats", + "tableTo": "users", + "columnsFrom": [ + "created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.gen2_workspace_members": { + "name": "gen2_workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "gen2_workspace_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'editor'" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "gen2_workspace_members_user_idx": { + "name": "gen2_workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk": { + "name": "gen2_workspace_members_workspace_id_gen2_workspaces_id_fk", + "tableFrom": "gen2_workspace_members", + "tableTo": "gen2_workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "gen2_workspace_members_user_id_users_id_fk": { + "name": "gen2_workspace_members_user_id_users_id_fk", + "tableFrom": "gen2_workspace_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "gen2_workspace_members_workspace_id_user_id_pk": { + "name": "gen2_workspace_members_workspace_id_user_id_pk", + "columns": [ + "workspace_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.gen2_workspaces": { + "name": "gen2_workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "owner_id": { + "name": "owner_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "gen2_workspace_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active_invite_token_hash": { + "name": "active_invite_token_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active_invite_created_by_user_id": { + "name": "active_invite_created_by_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "active_invite_role": { + "name": "active_invite_role", + "type": "gen2_workspace_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "active_invite_created_at": { + "name": "active_invite_created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "active_invite_expires_at": { + "name": "active_invite_expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "github_installation_id": { + "name": "github_installation_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "github_repository_id": { + "name": "github_repository_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "repository": { + "name": "repository", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "repository_private": { + "name": "repository_private", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "default_branch": { + "name": "default_branch", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "base_sha": { + "name": "base_sha", + "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": { + "gen2_workspaces_owner_idx": { + "name": "gen2_workspaces_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "gen2_workspaces_active_invite_token_hash_idx": { + "name": "gen2_workspaces_active_invite_token_hash_idx", + "columns": [ + { + "expression": "active_invite_token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "gen2_workspaces_owner_id_users_id_fk": { + "name": "gen2_workspaces_owner_id_users_id_fk", + "tableFrom": "gen2_workspaces", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "gen2_workspaces_active_invite_created_by_user_id_users_id_fk": { + "name": "gen2_workspaces_active_invite_created_by_user_id_users_id_fk", + "tableFrom": "gen2_workspaces", + "tableTo": "users", + "columnsFrom": [ + "active_invite_created_by_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_connections": { + "name": "github_connections", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "encrypted_access_token": { + "name": "encrypted_access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_refresh_token": { + "name": "encrypted_refresh_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 + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'bearer'" + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "key_version": { + "name": "key_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "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": { + "github_connections_access_expiry_idx": { + "name": "github_connections_access_expiry_idx", + "columns": [ + { + "expression": "access_token_expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "github_connections_user_id_users_id_fk": { + "name": "github_connections_user_id_users_id_fk", + "tableFrom": "github_connections", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_issue_assignments": { + "name": "github_issue_assignments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "github_repository_id": { + "name": "github_repository_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "issue_number": { + "name": "issue_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "github_issue_id": { + "name": "github_issue_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "github_issue_assignments_repository_issue_idx": { + "name": "github_issue_assignments_repository_issue_idx", + "columns": [ + { + "expression": "github_repository_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "issue_number", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "github_issue_assignments_session_idx": { + "name": "github_issue_assignments_session_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "github_issue_assignments_workspace_idx": { + "name": "github_issue_assignments_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "github_issue_assignments_workspace_id_workspaces_id_fk": { + "name": "github_issue_assignments_workspace_id_workspaces_id_fk", + "tableFrom": "github_issue_assignments", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "github_issue_assignments_session_id_agent_sessions_id_fk": { + "name": "github_issue_assignments_session_id_agent_sessions_id_fk", + "tableFrom": "github_issue_assignments", + "tableTo": "agent_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.mobile_push_tokens": { + "name": "mobile_push_tokens", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expo_push_token": { + "name": "expo_push_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "platform": { + "name": "platform", + "type": "mobile_platform", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "device_id": { + "name": "device_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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": { + "mobile_push_tokens_token_idx": { + "name": "mobile_push_tokens_token_idx", + "columns": [ + { + "expression": "expo_push_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "mobile_push_tokens_user_idx": { + "name": "mobile_push_tokens_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mobile_push_tokens_user_id_users_id_fk": { + "name": "mobile_push_tokens_user_id_users_id_fk", + "tableFrom": "mobile_push_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_feature_overrides": { + "name": "organization_feature_overrides", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "feature": { + "name": "feature", + "type": "feature_key", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "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": {}, + "foreignKeys": { + "organization_feature_overrides_organization_id_organizations_id_fk": { + "name": "organization_feature_overrides_organization_id_organizations_id_fk", + "tableFrom": "organization_feature_overrides", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_feature_overrides_created_by_users_id_fk": { + "name": "organization_feature_overrides_created_by_users_id_fk", + "tableFrom": "organization_feature_overrides", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "organization_feature_overrides_organization_id_feature_pk": { + "name": "organization_feature_overrides_organization_id_feature_pk", + "columns": [ + "organization_id", + "feature" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_members": { + "name": "organization_members", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "organization_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "organization_members_user_idx": { + "name": "organization_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_members_organization_id_organizations_id_fk": { + "name": "organization_members_organization_id_organizations_id_fk", + "tableFrom": "organization_members", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_members_user_id_users_id_fk": { + "name": "organization_members_user_id_users_id_fk", + "tableFrom": "organization_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "organization_members_organization_id_user_id_pk": { + "name": "organization_members_organization_id_user_id_pk", + "columns": [ + "organization_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_subscriptions": { + "name": "organization_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "plan_id": { + "name": "plan_id", + "type": "subscription_plan", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "organization_subscription_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_customer_id": { + "name": "provider_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provider_subscription_id": { + "name": "provider_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "canceled_at": { + "name": "canceled_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": { + "organization_subscriptions_org_idx": { + "name": "organization_subscriptions_org_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "organization_subscriptions_provider_idx": { + "name": "organization_subscriptions_provider_idx", + "columns": [ + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider_subscription_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "organization_subscriptions_organization_id_organizations_id_fk": { + "name": "organization_subscriptions_organization_id_organizations_id_fk", + "tableFrom": "organization_subscriptions", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "organization_subscriptions_plan_id_plans_id_fk": { + "name": "organization_subscriptions_plan_id_plans_id_fk", + "tableFrom": "organization_subscriptions", + "tableTo": "plans", + "columnsFrom": [ + "plan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organizations": { + "name": "organizations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "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": { + "organizations_slug_idx": { + "name": "organizations_slug_idx", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.page_views": { + "name": "page_views", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "referrer": { + "name": "referrer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip_hash": { + "name": "ip_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "page_views_created_idx": { + "name": "page_views_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "page_views_user_created_idx": { + "name": "page_views_user_created_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "page_views_path_created_idx": { + "name": "page_views_path_created_idx", + "columns": [ + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "page_views_user_id_users_id_fk": { + "name": "page_views_user_id_users_id_fk", + "tableFrom": "page_views", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.path_claims": { + "name": "path_claims", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "session_id": { + "name": "session_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "path_glob": { + "name": "path_glob", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "intent": { + "name": "intent", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "revision": { + "name": "revision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "claim_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "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": { + "path_claims_session_status_idx": { + "name": "path_claims_session_status_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "path_claims_expiry_idx": { + "name": "path_claims_expiry_idx", + "columns": [ + { + "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": { + "path_claims_session_id_agent_sessions_id_fk": { + "name": "path_claims_session_id_agent_sessions_id_fk", + "tableFrom": "path_claims", + "tableTo": "agent_sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.plan_entitlements": { + "name": "plan_entitlements", + "schema": "", + "columns": { + "plan_id": { + "name": "plan_id", + "type": "subscription_plan", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "feature": { + "name": "feature", + "type": "feature_key", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": 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": {}, + "foreignKeys": { + "plan_entitlements_plan_id_plans_id_fk": { + "name": "plan_entitlements_plan_id_plans_id_fk", + "tableFrom": "plan_entitlements", + "tableTo": "plans", + "columnsFrom": [ + "plan_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "plan_entitlements_plan_id_feature_pk": { + "name": "plan_entitlements_plan_id_feature_pk", + "columns": [ + "plan_id", + "feature" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.plans": { + "name": "plans", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "subscription_plan", + "typeSchema": "public", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": 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": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.provider_credential_events": { + "name": "provider_credential_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "credential_id": { + "name": "credential_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "provider": { + "name": "provider", + "type": "credential_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope_type": { + "name": "scope_type", + "type": "credential_scope_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "scope_id": { + "name": "scope_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "provider_credential_events_credential_created_idx": { + "name": "provider_credential_events_credential_created_idx", + "columns": [ + { + "expression": "credential_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "provider_credential_events_actor_created_idx": { + "name": "provider_credential_events_actor_created_idx", + "columns": [ + { + "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": { + "provider_credential_events_actor_id_users_id_fk": { + "name": "provider_credential_events_actor_id_users_id_fk", + "tableFrom": "provider_credential_events", + "tableTo": "users", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "provider_credential_events_workspace_id_workspaces_id_fk": { + "name": "provider_credential_events_workspace_id_workspaces_id_fk", + "tableFrom": "provider_credential_events", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.provider_credentials": { + "name": "provider_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "scope_type": { + "name": "scope_type", + "type": "credential_scope_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "scope_id": { + "name": "scope_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "credential_provider", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "credential_type": { + "name": "credential_type", + "type": "credential_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "priority_order": { + "name": "priority_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "encrypted_api_key": { + "name": "encrypted_api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "encrypted_access_token": { + "name": "encrypted_access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "encrypted_refresh_token": { + "name": "encrypted_refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "endpoint_url": { + "name": "endpoint_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "aws_role_arn": { + "name": "aws_role_arn", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_connected": { + "name": "is_connected", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "key_version": { + "name": "key_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "last_four": { + "name": "last_four", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "provider_credential_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "provider_subject_hash": { + "name": "provider_subject_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "encrypted_material": { + "name": "encrypted_material", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_refreshed_at": { + "name": "last_refreshed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sharing_enabled": { + "name": "sharing_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "unavailable_until": { + "name": "unavailable_until", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "connected_via": { + "name": "connected_via", + "type": "credential_connected_via", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "enabled_for_rooms": { + "name": "enabled_for_rooms", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "enabled_for_workspace": { + "name": "enabled_for_workspace", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": 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": { + "provider_credentials_scope_provider_type_idx": { + "name": "provider_credentials_scope_provider_type_idx", + "columns": [ + { + "expression": "scope_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scope_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "credential_type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "provider_credentials_scope_provider_priority_idx": { + "name": "provider_credentials_scope_provider_priority_idx", + "columns": [ + { + "expression": "scope_type", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "scope_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "priority_order", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "provider_credentials_status_idx": { + "name": "provider_credentials_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "provider_credentials_created_by_users_id_fk": { + "name": "provider_credentials_created_by_users_id_fk", + "tableFrom": "provider_credentials", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.published_branches": { + "name": "published_branches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "branch_name": { + "name": "branch_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "publication_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "source_head_sha": { + "name": "source_head_sha", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "base_sha": { + "name": "base_sha", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "commit_sha": { + "name": "commit_sha", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "repository_id": { + "name": "repository_id", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "remote_ref": { + "name": "remote_ref", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html_url": { + "name": "html_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pull_request_number": { + "name": "pull_request_number", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "pull_request_url": { + "name": "pull_request_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_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": { + "published_branches_workspace_name_idx": { + "name": "published_branches_workspace_name_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "branch_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "published_branches_workspace_request_idx": { + "name": "published_branches_workspace_request_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "request_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "published_branches_workspace_status_idx": { + "name": "published_branches_workspace_status_idx", + "columns": [ + { + "expression": "workspace_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": { + "published_branches_workspace_id_workspaces_id_fk": { + "name": "published_branches_workspace_id_workspaces_id_fk", + "tableFrom": "published_branches", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "published_branches_published_by_users_id_fk": { + "name": "published_branches_published_by_users_id_fk", + "tableFrom": "published_branches", + "tableTo": "users", + "columnsFrom": [ + "published_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.runtime_hosts": { + "name": "runtime_hosts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "runtime_address": { + "name": "runtime_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lifecycle_state": { + "name": "lifecycle_state", + "type": "runtime_host_lifecycle", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'provisioning'" + }, + "max_workspace_slots": { + "name": "max_workspace_slots", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4 + }, + "free_workspace_slots": { + "name": "free_workspace_slots", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 4 + }, + "image_version": { + "name": "image_version", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_heartbeat_at": { + "name": "last_heartbeat_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "draining_at": { + "name": "draining_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()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "runtime_hosts_provider_id_idx": { + "name": "runtime_hosts_provider_id_idx", + "columns": [ + { + "expression": "provider_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "runtime_hosts_runtime_address_idx": { + "name": "runtime_hosts_runtime_address_idx", + "columns": [ + { + "expression": "runtime_address", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "runtime_hosts_capacity_idx": { + "name": "runtime_hosts_capacity_idx", + "columns": [ + { + "expression": "lifecycle_state", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "free_workspace_slots", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sandbox_runtime_intervals": { + "name": "sandbox_runtime_intervals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "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": { + "sandbox_runtime_intervals_user_open_idx": { + "name": "sandbox_runtime_intervals_user_open_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ended_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sandbox_runtime_intervals_workspace_open_idx": { + "name": "sandbox_runtime_intervals_workspace_open_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "ended_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sandbox_runtime_intervals_user_id_users_id_fk": { + "name": "sandbox_runtime_intervals_user_id_users_id_fk", + "tableFrom": "sandbox_runtime_intervals", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sandbox_runtime_intervals_workspace_id_workspaces_id_fk": { + "name": "sandbox_runtime_intervals_workspace_id_workspaces_id_fk", + "tableFrom": "sandbox_runtime_intervals", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shared_chat_invites": { + "name": "shared_chat_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "shared_chat_id": { + "name": "shared_chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_token": { + "name": "encrypted_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_by": { + "name": "accepted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shared_chat_invites_token_hash_idx": { + "name": "shared_chat_invites_token_hash_idx", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shared_chat_invites_room_idx": { + "name": "shared_chat_invites_room_idx", + "columns": [ + { + "expression": "shared_chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shared_chat_invites_shared_chat_id_shared_chats_id_fk": { + "name": "shared_chat_invites_shared_chat_id_shared_chats_id_fk", + "tableFrom": "shared_chat_invites", + "tableTo": "shared_chats", + "columnsFrom": [ + "shared_chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_chat_invites_created_by_users_id_fk": { + "name": "shared_chat_invites_created_by_users_id_fk", + "tableFrom": "shared_chat_invites", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_chat_invites_accepted_by_users_id_fk": { + "name": "shared_chat_invites_accepted_by_users_id_fk", + "tableFrom": "shared_chat_invites", + "tableTo": "users", + "columnsFrom": [ + "accepted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shared_chat_members": { + "name": "shared_chat_members", + "schema": "", + "columns": { + "shared_chat_id": { + "name": "shared_chat_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "shared_chat_members_user_idx": { + "name": "shared_chat_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shared_chat_members_shared_chat_id_shared_chats_id_fk": { + "name": "shared_chat_members_shared_chat_id_shared_chats_id_fk", + "tableFrom": "shared_chat_members", + "tableTo": "shared_chats", + "columnsFrom": [ + "shared_chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_chat_members_user_id_users_id_fk": { + "name": "shared_chat_members_user_id_users_id_fk", + "tableFrom": "shared_chat_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "shared_chat_members_shared_chat_id_user_id_pk": { + "name": "shared_chat_members_shared_chat_id_user_id_pk", + "columns": [ + "shared_chat_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.shared_chats": { + "name": "shared_chats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "conversation_id": { + "name": "conversation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_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": { + "shared_chats_conversation_idx": { + "name": "shared_chats_conversation_idx", + "columns": [ + { + "expression": "conversation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "shared_chats_owner_updated_idx": { + "name": "shared_chats_owner_updated_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "shared_chats_conversation_id_conversations_id_fk": { + "name": "shared_chats_conversation_id_conversations_id_fk", + "tableFrom": "shared_chats", + "tableTo": "conversations", + "columnsFrom": [ + "conversation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "shared_chats_owner_id_users_id_fk": { + "name": "shared_chats_owner_id_users_id_fk", + "tableFrom": "shared_chats", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_compute_usage": { + "name": "user_compute_usage", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "minutes_used": { + "name": "minutes_used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_compute_usage_user_id_users_id_fk": { + "name": "user_compute_usage_user_id_users_id_fk", + "tableFrom": "user_compute_usage", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_environment_variables": { + "name": "user_environment_variables", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "encrypted_value": { + "name": "encrypted_value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "key_version": { + "name": "key_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "last_four": { + "name": "last_four", + "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": { + "user_environment_variables_user_name_idx": { + "name": "user_environment_variables_user_name_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "user_environment_variables_user_updated_idx": { + "name": "user_environment_variables_user_updated_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_environment_variables_user_id_users_id_fk": { + "name": "user_environment_variables_user_id_users_id_fk", + "tableFrom": "user_environment_variables", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_feature_overrides": { + "name": "user_feature_overrides", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "feature": { + "name": "feature", + "type": "feature_key", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "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": { + "user_feature_overrides_user_idx": { + "name": "user_feature_overrides_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_feature_overrides_organization_id_organizations_id_fk": { + "name": "user_feature_overrides_organization_id_organizations_id_fk", + "tableFrom": "user_feature_overrides", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_feature_overrides_user_id_users_id_fk": { + "name": "user_feature_overrides_user_id_users_id_fk", + "tableFrom": "user_feature_overrides", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_feature_overrides_created_by_users_id_fk": { + "name": "user_feature_overrides_created_by_users_id_fk", + "tableFrom": "user_feature_overrides", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "user_feature_overrides_organization_id_user_id_feature_pk": { + "name": "user_feature_overrides_organization_id_user_id_feature_pk", + "columns": [ + "organization_id", + "user_id", + "feature" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "github_user_id": { + "name": "github_user_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "google_user_id": { + "name": "google_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "clerk_user_id": { + "name": "clerk_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "login": { + "name": "login", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "avatar_url": { + "name": "avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_admin": { + "name": "is_admin", + "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": { + "users_github_user_id_idx": { + "name": "users_github_user_id_idx", + "columns": [ + { + "expression": "github_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_google_user_id_idx": { + "name": "users_google_user_id_idx", + "columns": [ + { + "expression": "google_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_clerk_user_id_idx": { + "name": "users_clerk_user_id_idx", + "columns": [ + { + "expression": "clerk_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_login_idx": { + "name": "users_login_idx", + "columns": [ + { + "expression": "login", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_channel_messages": { + "name": "workspace_channel_messages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "channel_id": { + "name": "channel_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_kind": { + "name": "author_kind", + "type": "channel_message_author_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "author_label": { + "name": "author_label", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_session_id": { + "name": "agent_session_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mentions": { + "name": "mentions", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "mentions_agent": { + "name": "mentions_agent", + "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": { + "workspace_channel_messages_channel_idx": { + "name": "workspace_channel_messages_channel_idx", + "columns": [ + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_channel_messages_workspace_idx": { + "name": "workspace_channel_messages_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_channel_messages_channel_id_workspace_channels_id_fk": { + "name": "workspace_channel_messages_channel_id_workspace_channels_id_fk", + "tableFrom": "workspace_channel_messages", + "tableTo": "workspace_channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_channel_messages_workspace_id_workspaces_id_fk": { + "name": "workspace_channel_messages_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_channel_messages", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_channel_messages_author_id_users_id_fk": { + "name": "workspace_channel_messages_author_id_users_id_fk", + "tableFrom": "workspace_channel_messages", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "workspace_channel_messages_agent_session_id_agent_sessions_id_fk": { + "name": "workspace_channel_messages_agent_session_id_agent_sessions_id_fk", + "tableFrom": "workspace_channel_messages", + "tableTo": "agent_sessions", + "columnsFrom": [ + "agent_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_channel_reads": { + "name": "workspace_channel_reads", + "schema": "", + "columns": { + "channel_id": { + "name": "channel_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "last_read_at": { + "name": "last_read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_channel_reads_user_idx": { + "name": "workspace_channel_reads_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_channel_reads_channel_id_workspace_channels_id_fk": { + "name": "workspace_channel_reads_channel_id_workspace_channels_id_fk", + "tableFrom": "workspace_channel_reads", + "tableTo": "workspace_channels", + "columnsFrom": [ + "channel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_channel_reads_user_id_users_id_fk": { + "name": "workspace_channel_reads_user_id_users_id_fk", + "tableFrom": "workspace_channel_reads", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workspace_channel_reads_channel_id_user_id_pk": { + "name": "workspace_channel_reads_channel_id_user_id_pk", + "columns": [ + "channel_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_channels": { + "name": "workspace_channels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "topic": { + "name": "topic", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_access": { + "name": "agent_access", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "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": { + "workspace_channels_workspace_slug_idx": { + "name": "workspace_channels_workspace_slug_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_channels_workspace_idx": { + "name": "workspace_channels_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_channels_workspace_id_workspaces_id_fk": { + "name": "workspace_channels_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_channels", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_channels_created_by_users_id_fk": { + "name": "workspace_channels_created_by_users_id_fk", + "tableFrom": "workspace_channels", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_chat_leases": { + "name": "workspace_chat_leases", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "holder_id": { + "name": "holder_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lease_token": { + "name": "lease_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_chat_leases_expiry_idx": { + "name": "workspace_chat_leases_expiry_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_chat_leases_workspace_id_workspaces_id_fk": { + "name": "workspace_chat_leases_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_chat_leases", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_chat_leases_holder_id_users_id_fk": { + "name": "workspace_chat_leases_holder_id_users_id_fk", + "tableFrom": "workspace_chat_leases", + "tableTo": "users", + "columnsFrom": [ + "holder_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workspace_chat_leases_workspace_id_chat_id_pk": { + "name": "workspace_chat_leases_workspace_id_chat_id_pk", + "columns": [ + "workspace_id", + "chat_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_chat_participants": { + "name": "workspace_chat_participants", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_chat_participants_expiry_idx": { + "name": "workspace_chat_participants_expiry_idx", + "columns": [ + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_chat_participants_workspace_id_workspaces_id_fk": { + "name": "workspace_chat_participants_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_chat_participants", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_chat_participants_user_id_users_id_fk": { + "name": "workspace_chat_participants_user_id_users_id_fk", + "tableFrom": "workspace_chat_participants", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk": { + "name": "workspace_chat_participants_workspace_id_chat_id_user_id_client_id_pk", + "columns": [ + "workspace_id", + "chat_id", + "user_id", + "client_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_chat_prompt_receipts": { + "name": "workspace_chat_prompt_receipts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "client_message_id": { + "name": "client_message_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attachments": { + "name": "attachments", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_chat_prompt_receipts_client_message_idx": { + "name": "workspace_chat_prompt_receipts_client_message_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "client_message_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_chat_prompt_receipts_chat_created_idx": { + "name": "workspace_chat_prompt_receipts_chat_created_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "chat_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk": { + "name": "workspace_chat_prompt_receipts_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_chat_prompt_receipts", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_chat_prompt_receipts_author_id_users_id_fk": { + "name": "workspace_chat_prompt_receipts_author_id_users_id_fk", + "tableFrom": "workspace_chat_prompt_receipts", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_events": { + "name": "workspace_events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "sequence": { + "name": "sequence", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_id": { + "name": "actor_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_events_sequence_idx": { + "name": "workspace_events_sequence_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "sequence", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_events_workspace_id_workspaces_id_fk": { + "name": "workspace_events_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_events", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_events_actor_id_users_id_fk": { + "name": "workspace_events_actor_id_users_id_fk", + "tableFrom": "workspace_events", + "tableTo": "users", + "columnsFrom": [ + "actor_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invites": { + "name": "workspace_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invitee_email": { + "name": "invitee_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "invitee_login": { + "name": "invitee_login", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_role": { + "name": "access_role", + "type": "workspace_access_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'viewer'" + }, + "allow_link": { + "name": "allow_link", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "revoked_at": { + "name": "revoked_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_at": { + "name": "accepted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "accepted_by": { + "name": "accepted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_invites_token_hash_idx": { + "name": "workspace_invites_token_hash_idx", + "columns": [ + { + "expression": "token_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invites_workspace_idx": { + "name": "workspace_invites_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_invites_workspace_id_workspaces_id_fk": { + "name": "workspace_invites_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_invites", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_invites_created_by_users_id_fk": { + "name": "workspace_invites_created_by_users_id_fk", + "tableFrom": "workspace_invites", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_invites_accepted_by_users_id_fk": { + "name": "workspace_invites_accepted_by_users_id_fk", + "tableFrom": "workspace_invites", + "tableTo": "users", + "columnsFrom": [ + "accepted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_member_statuses": { + "name": "workspace_member_statuses", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "emoji": { + "name": "emoji", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "headline": { + "name": "headline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_member_statuses_workspace_idx": { + "name": "workspace_member_statuses_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_member_statuses_workspace_id_workspaces_id_fk": { + "name": "workspace_member_statuses_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_member_statuses", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_member_statuses_user_id_users_id_fk": { + "name": "workspace_member_statuses_user_id_users_id_fk", + "tableFrom": "workspace_member_statuses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workspace_member_statuses_workspace_id_user_id_pk": { + "name": "workspace_member_statuses_workspace_id_user_id_pk", + "columns": [ + "workspace_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'member'" + }, + "access_role": { + "name": "access_role", + "type": "workspace_access_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'viewer'" + }, + "can_terminal": { + "name": "can_terminal", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "can_merge": { + "name": "can_merge", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_members_user_idx": { + "name": "workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_members_workspace_id_workspaces_id_fk": { + "name": "workspace_members_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_members", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_members_user_id_users_id_fk": { + "name": "workspace_members_user_id_users_id_fk", + "tableFrom": "workspace_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "name": "workspace_members_workspace_id_user_id_pk", + "columns": [ + "workspace_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_runtime_assignments": { + "name": "workspace_runtime_assignments", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "host_id": { + "name": "host_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "generation": { + "name": "generation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "fencing_token": { + "name": "fencing_token", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "disk_id": { + "name": "disk_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "disk_lun": { + "name": "disk_lun", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "runtime_state": { + "name": "runtime_state", + "type": "workspace_runtime_assignment_state", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'assigned'" + }, + "last_used_at": { + "name": "last_used_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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": { + "workspace_runtime_assignments_host_state_idx": { + "name": "workspace_runtime_assignments_host_state_idx", + "columns": [ + { + "expression": "host_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "runtime_state", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_runtime_assignments_state_updated_idx": { + "name": "workspace_runtime_assignments_state_updated_idx", + "columns": [ + { + "expression": "runtime_state", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_runtime_assignments_workspace_id_workspaces_id_fk": { + "name": "workspace_runtime_assignments_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_runtime_assignments", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "workspace_runtime_assignments_host_id_runtime_hosts_id_fk": { + "name": "workspace_runtime_assignments_host_id_runtime_hosts_id_fk", + "tableFrom": "workspace_runtime_assignments", + "tableTo": "runtime_hosts", + "columnsFrom": [ + "host_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_runtimes": { + "name": "workspace_runtimes", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "sandbox_id": { + "name": "sandbox_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "backend": { + "name": "backend", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'firecracker'" + }, + "status": { + "name": "status", + "type": "sandbox_runtime_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'provisioning'" + }, + "provisioned_head_sha": { + "name": "provisioned_head_sha", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snapshot_ref": { + "name": "snapshot_ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_heartbeat_at": { + "name": "last_heartbeat_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "hibernated_at": { + "name": "hibernated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "provisioned_at": { + "name": "provisioned_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "stopped_at": { + "name": "stopped_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": { + "workspace_runtimes_status_updated_idx": { + "name": "workspace_runtimes_status_updated_idx", + "columns": [ + { + "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": { + "workspace_runtimes_workspace_id_workspaces_id_fk": { + "name": "workspace_runtimes_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_runtimes", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "workspace_runtimes_sandbox_id_unique": { + "name": "workspace_runtimes_sandbox_id_unique", + "nullsNotDistinct": false, + "columns": [ + "sandbox_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_snapshots": { + "name": "workspace_snapshots", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "head_sha": { + "name": "head_sha", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "snapshot": { + "name": "snapshot", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "total_bytes": { + "name": "total_bytes", + "type": "integer", + "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": { + "workspace_snapshots_updated_idx": { + "name": "workspace_snapshots_updated_idx", + "columns": [ + { + "expression": "updated_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_snapshots_workspace_id_workspaces_id_fk": { + "name": "workspace_snapshots_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_snapshots", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_state_documents": { + "name": "workspace_state_documents", + "schema": "", + "columns": { + "document_name": { + "name": "document_name", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "bytea", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "workspace_state_documents_workspace_idx": { + "name": "workspace_state_documents_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspace_state_documents_workspace_id_workspaces_id_fk": { + "name": "workspace_state_documents_workspace_id_workspaces_id_fk", + "tableFrom": "workspace_state_documents", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "owner_id": { + "name": "owner_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "github_installation_id": { + "name": "github_installation_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "github_repository_id": { + "name": "github_repository_id", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "repository": { + "name": "repository", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "repository_visibility": { + "name": "repository_visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'public'" + }, + "default_branch": { + "name": "default_branch", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "base_sha": { + "name": "base_sha", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "workspace_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "hibernate_at": { + "name": "hibernate_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "deleted_at": { + "name": "deleted_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": { + "workspaces_owner_idx": { + "name": "workspaces_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspaces_organization_idx": { + "name": "workspaces_organization_idx", + "columns": [ + { + "expression": "organization_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspaces_repository_idx": { + "name": "workspaces_repository_idx", + "columns": [ + { + "expression": "github_repository_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspaces_status_expiry_idx": { + "name": "workspaces_status_expiry_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspaces_deleted_idx": { + "name": "workspaces_deleted_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "workspaces_owner_id_users_id_fk": { + "name": "workspaces_owner_id_users_id_fk", + "tableFrom": "workspaces", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "workspaces_organization_id_organizations_id_fk": { + "name": "workspaces_organization_id_organizations_id_fk", + "tableFrom": "workspaces", + "tableTo": "organizations", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.worktrees": { + "name": "worktrees", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "worktree_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head_sha": { + "name": "head_sha", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "worktree_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "review_head_sha": { + "name": "review_head_sha", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "review_base_sha": { + "name": "review_base_sha", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "review_diff_digest": { + "name": "review_diff_digest", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "merged_at": { + "name": "merged_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "discarded_at": { + "name": "discarded_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": { + "worktrees_workspace_name_idx": { + "name": "worktrees_workspace_name_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "worktrees_workspace_status_idx": { + "name": "worktrees_workspace_status_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "worktrees_workspace_id_workspaces_id_fk": { + "name": "worktrees_workspace_id_workspaces_id_fk", + "tableFrom": "worktrees", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "worktrees_reviewed_by_users_id_fk": { + "name": "worktrees_reviewed_by_users_id_fk", + "tableFrom": "worktrees", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.yjs_snapshots": { + "name": "yjs_snapshots", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "worktree_id": { + "name": "worktree_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "revision": { + "name": "revision", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "update_base64": { + "name": "update_base64", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_vector_base64": { + "name": "state_vector_base64", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "filesystem_contents": { + "name": "filesystem_contents", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "filesystem_revision": { + "name": "filesystem_revision", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "has_conflict": { + "name": "has_conflict", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "conflict_filesystem_revision": { + "name": "conflict_filesystem_revision", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "conflict_detected_at": { + "name": "conflict_detected_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "conflict_resolved_at": { + "name": "conflict_resolved_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "conflict_resolved_by": { + "name": "conflict_resolved_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "conflict_resolution": { + "name": "conflict_resolution", + "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": { + "yjs_snapshots_worktree_path_idx": { + "name": "yjs_snapshots_worktree_path_idx", + "columns": [ + { + "expression": "worktree_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "path", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "yjs_snapshots_worktree_id_worktrees_id_fk": { + "name": "yjs_snapshots_worktree_id_worktrees_id_fk", + "tableFrom": "yjs_snapshots", + "tableTo": "worktrees", + "columnsFrom": [ + "worktree_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "yjs_snapshots_conflict_resolved_by_users_id_fk": { + "name": "yjs_snapshots_conflict_resolved_by_users_id_fk", + "tableFrom": "yjs_snapshots", + "tableTo": "users", + "columnsFrom": [ + "conflict_resolved_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.access_request_status": { + "name": "access_request_status", + "schema": "public", + "values": [ + "pending", + "invited", + "declined" + ] + }, + "public.agent_brief_status": { + "name": "agent_brief_status", + "schema": "public", + "values": [ + "planning", + "active", + "blocked", + "paused", + "done" + ] + }, + "public.agent_session_import_status": { + "name": "agent_session_import_status", + "schema": "public", + "values": [ + "storing", + "stored", + "restoring", + "ready", + "launching", + "active", + "failed", + "deleted" + ] + }, + "public.agent_session_kind": { + "name": "agent_session_kind", + "schema": "public", + "values": [ + "managed", + "cli" + ] + }, + "public.agent_session_status": { + "name": "agent_session_status", + "schema": "public", + "values": [ + "idle", + "running", + "waiting", + "completed", + "interrupted", + "failed" + ] + }, + "public.agent_turn_status": { + "name": "agent_turn_status", + "schema": "public", + "values": [ + "queued", + "running", + "completed", + "interrupted", + "failed" + ] + }, + "public.brain_entry_kind": { + "name": "brain_entry_kind", + "schema": "public", + "values": [ + "decision", + "attempt", + "dead_end", + "finding", + "convention", + "handoff" + ] + }, + "public.brain_overlap_kind": { + "name": "brain_overlap_kind", + "schema": "public", + "values": [ + "duplicate_intent", + "file_overlap", + "claim_contest" + ] + }, + "public.brain_overlap_status": { + "name": "brain_overlap_status", + "schema": "public", + "values": [ + "open", + "acknowledged", + "resolved" + ] + }, + "public.channel_message_author_kind": { + "name": "channel_message_author_kind", + "schema": "public", + "values": [ + "member", + "agent", + "system" + ] + }, + "public.claim_status": { + "name": "claim_status", + "schema": "public", + "values": [ + "active", + "released", + "expired", + "contested" + ] + }, + "public.claude_connection_session_status": { + "name": "claude_connection_session_status", + "schema": "public", + "values": [ + "starting", + "awaiting_code", + "exchanging", + "connected", + "failed" + ] + }, + "public.cli_client_type": { + "name": "cli_client_type", + "schema": "public", + "values": [ + "cli", + "mobile" + ] + }, + "public.cli_device_authorization_status": { + "name": "cli_device_authorization_status", + "schema": "public", + "values": [ + "pending", + "approved", + "denied" + ] + }, + "public.credential_connected_via": { + "name": "credential_connected_via", + "schema": "public", + "values": [ + "browser", + "cli", + "api_key" + ] + }, + "public.credential_provider": { + "name": "credential_provider", + "schema": "public", + "values": [ + "anthropic", + "openai", + "bedrock", + "azure_foundry", + "cursor", + "custom" + ] + }, + "public.credential_scope_type": { + "name": "credential_scope_type", + "schema": "public", + "values": [ + "USER", + "WORKSPACE", + "ORGANIZATION" + ] + }, + "public.credential_type": { + "name": "credential_type", + "schema": "public", + "values": [ + "API_KEY", + "OAUTH_TOKEN", + "AWS_BEDROCK_ROLE", + "AZURE_ENDPOINT", + "HOSTED_CODEX_SUBSCRIPTION" + ] + }, + "public.feature_key": { + "name": "feature_key", + "schema": "public", + "values": [ + "hosted_codex_subscription" + ] + }, + "public.feature_override_audit_action": { + "name": "feature_override_audit_action", + "schema": "public", + "values": [ + "created", + "updated", + "deleted" + ] + }, + "public.gen2_workspace_role": { + "name": "gen2_workspace_role", + "schema": "public", + "values": [ + "owner", + "editor", + "viewer" + ] + }, + "public.gen2_workspace_status": { + "name": "gen2_workspace_status", + "schema": "public", + "values": [ + "pending", + "provisioning", + "ready", + "failed", + "stopped", + "deleting" + ] + }, + "public.member_role": { + "name": "member_role", + "schema": "public", + "values": [ + "owner", + "member" + ] + }, + "public.coordination_message_status": { + "name": "coordination_message_status", + "schema": "public", + "values": [ + "pending", + "delivered", + "resolved" + ] + }, + "public.mobile_platform": { + "name": "mobile_platform", + "schema": "public", + "values": [ + "ios", + "android" + ] + }, + "public.organization_role": { + "name": "organization_role", + "schema": "public", + "values": [ + "owner", + "admin", + "billing_admin", + "member" + ] + }, + "public.organization_subscription_status": { + "name": "organization_subscription_status", + "schema": "public", + "values": [ + "trialing", + "active", + "past_due", + "canceled" + ] + }, + "public.provider_credential_status": { + "name": "provider_credential_status", + "schema": "public", + "values": [ + "active", + "reauthorization_required", + "revoked", + "failed" + ] + }, + "public.publication_status": { + "name": "publication_status", + "schema": "public", + "values": [ + "pending", + "published", + "failed" + ] + }, + "public.repository_restore_status": { + "name": "repository_restore_status", + "schema": "public", + "values": [ + "pending", + "matched", + "restored", + "conflicted", + "unavailable", + "transcript_only" + ] + }, + "public.runtime_host_lifecycle": { + "name": "runtime_host_lifecycle", + "schema": "public", + "values": [ + "provisioning", + "ready", + "draining", + "stopped", + "failed" + ] + }, + "public.sandbox_runtime_status": { + "name": "sandbox_runtime_status", + "schema": "public", + "values": [ + "provisioning", + "ready", + "hibernated", + "stopping", + "stopped", + "failed" + ] + }, + "public.session_continuation_mode": { + "name": "session_continuation_mode", + "schema": "public", + "values": [ + "managed", + "native_resume" + ] + }, + "public.subscription_plan": { + "name": "subscription_plan", + "schema": "public", + "values": [ + "free", + "pro", + "team", + "enterprise" + ] + }, + "public.workspace_access_role": { + "name": "workspace_access_role", + "schema": "public", + "values": [ + "owner", + "co_steer", + "reviewer", + "viewer" + ] + }, + "public.workspace_runtime_assignment_state": { + "name": "workspace_runtime_assignment_state", + "schema": "public", + "values": [ + "assigned", + "starting", + "ready", + "draining", + "lost" + ] + }, + "public.workspace_status": { + "name": "workspace_status", + "schema": "public", + "values": [ + "pending", + "provisioning", + "ready", + "hibernated", + "stopping", + "stopped", + "failed" + ] + }, + "public.worktree_kind": { + "name": "worktree_kind", + "schema": "public", + "values": [ + "integration", + "agent" + ] + }, + "public.worktree_status": { + "name": "worktree_status", + "schema": "public", + "values": [ + "active", + "frozen", + "merged", + "discarded" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json index 84cbd134e..ed3a66a58 100644 --- a/packages/db/drizzle/meta/_journal.json +++ b/packages/db/drizzle/meta/_journal.json @@ -379,6 +379,13 @@ "when": 1790051443996, "tag": "0053_good_plazm", "breakpoints": true + }, + { + "idx": 54, + "version": "7", + "when": 1790398244312, + "tag": "0054_long_gressill", + "breakpoints": true } ] -} +} \ No newline at end of file diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index 224d9f39d..ec2c8d034 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -1998,6 +1998,7 @@ export const gen2WorkspaceStatus = pgEnum("gen2_workspace_status", [ "ready", "failed", "stopped", + "deleting", ]); export const gen2WorkspaceRole = pgEnum("gen2_workspace_role", [ diff --git a/services/orchestrator/src/backend/firecracker.rs b/services/orchestrator/src/backend/firecracker.rs index da28b9e6b..474c5f956 100644 --- a/services/orchestrator/src/backend/firecracker.rs +++ b/services/orchestrator/src/backend/firecracker.rs @@ -583,7 +583,8 @@ impl FirecrackerBackend { pub async fn discard_snapshot(&self, workspace_id: &str) -> Result<()> { let _guard = self.provision.lock().await; - remove_directory_if_present(&self.snapshot_dir(workspace_id)).await + remove_directory_if_present(&self.snapshot_dir(workspace_id)).await?; + remove_directory_if_present(&self.previous_snapshot_dir(workspace_id)).await } pub async fn read_file(