diff --git a/.env.migrate.example b/.env.migrate.example index f85093e7..4179b6aa 100644 --- a/.env.migrate.example +++ b/.env.migrate.example @@ -6,6 +6,3 @@ SUPABASE_MIGRATION_EXPECTED_HOST=db.snqtclnmhcaupqynjyux.supabase.co SUPABASE_MIGRATION_EXPECTED_DATABASE=postgres SUPABASE_MIGRATION_EXPECTED_ROLE=postgres SUPABASE_MIGRATION_EXPECTED_SYSTEM_IDENTIFIER=replace_with_pg_control_system_identifier - -# Optional one-time protected migration attestation envelope. -CHEATCODE_MIGRATION_ATTESTATIONS= diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index 8f65f952..4cd819de 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -2,6 +2,9 @@ name: Static Checks on: pull_request: + push: + branches: + - main permissions: contents: read diff --git a/AGENTS.md b/AGENTS.md index d15f2223..984f34eb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,7 +14,7 @@ source tree on July 13, 2026; the repository now contains V2 code only. | Layer | Choice | |---|---| | Backend | Cloudflare Workers + Durable Objects + Workflows | -| Frontend | Next.js 16.2.10 + React 19.2.7 + Tailwind 4.3.2 + shadcn 4.6.0 + AI Elements + Streamdown on Vercel | +| Frontend | Next.js 16.2.11 + React 19.2.7 + Tailwind 4.3.2 + shadcn 4.6.0 + AI Elements + Streamdown on Vercel | | Agent framework | Mastra 1.51.0 on Vercel AI SDK v6.0.205 | | Sandbox | Daytona per-user sandboxes via REST-over-fetch | | Browser | Stagehand v3.7.0 LOCAL inside the Daytona sandbox snapshot | @@ -234,7 +234,7 @@ The deleted `plan.md` is not authoritative and must not be restored. Base change Specifically check before changing: - `pnpm-workspace.yaml` and the lockfile for exact dependency versions -- `packages/db/src/schema`, `packages/db/drizzle`, and `infra/supabase/migrations` for Postgres behavior +- `packages/db/src/schema` and `packages/db/drizzle` for Postgres behavior - Worker `wrangler.jsonc`, `apps/web/vercel.json`, and `.github/workflows` for deployment topology - `biome.jsonc` and TypeScript configs for code-quality rules diff --git a/CLAUDE.md b/CLAUDE.md index 8fec565e..cf79d813 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -14,7 +14,7 @@ Direct competitors: Manus (generalist async agent), HappyCapy (GUI workstation + |---|---| | Language | **TypeScript** everywhere. No Python in backend. Python lives only inside the Daytona sandbox. | | Backend runtime | **Cloudflare Workers + Durable Objects + Workflows** | -| Frontend | **Next.js 16.2.10 + React 19.2.7 + Tailwind 4.3.2 + shadcn CLI 4.6.0 + AI Elements + Streamdown** on Vercel | +| Frontend | **Next.js 16.2.11 + React 19.2.7 + Tailwind 4.3.2 + shadcn CLI 4.6.0 + AI Elements + Streamdown** on Vercel | | Agent framework | **Mastra 1.51.0** on top of **Vercel AI SDK v6.0.205** | | Sandbox | **Daytona Sandboxes** via REST-over-fetch (no SDK in Workers; `packages/tools-code/src/daytona-client.ts`) — one persistent sandbox per user with isolated project folders | | Browser automation | **Stagehand v3.7.0 LOCAL mode** inside the Daytona sandbox image | diff --git a/README.md b/README.md index 56763872..11100426 100644 --- a/README.md +++ b/README.md @@ -202,23 +202,21 @@ pnpm deadcode ## Database migrations -`scripts/migrate.ts` owns migration planning and execution. Every mutation -requires `--apply` and an explicit phase; `--phase=all` is read-only. +`scripts/migrate.ts` owns migration planning and execution. The repository keeps +one current-schema baseline plus future forward migrations in the Drizzle +journal; it does not retain the pre-launch migration archive. ```bash -pnpm db:migrate -- --dry-run --phase=all -pnpm db:migrate -- --apply --phase=pre-deploy -pnpm db:migrate -- --apply --phase=post-deploy -pnpm db:migrate -- --apply --phase=release-finalization +pnpm db:migrate -- --dry-run +pnpm db:migrate -- --apply ``` The migration command loads `.env.migrate` on an authorized operator workstation, validates the administrative connection target and pinned database identity before applying changes, and accepts protected process environment values in automation. Migration credentials are never loaded by the app or -bound to a Worker. Apply expand -migrations before code that depends on them, and apply contractions only after -all deployed code is compatible with the contracted schema. +bound to a Worker. The runner verifies the exact source journal and final +production contract through the same pinned administrative session. Configure the three Worker Hyperdrive bindings with the existing guarded helper: @@ -260,11 +258,9 @@ deployed last. The independent preview proxy deploys only when its dependency closure changed. If Cloudflare release metadata is unavailable or inconsistent, the command safely redeploys the relevant set instead of guessing. -There is no second release orchestrator, compatibility deploy command, or hidden -workspace-reconciliation command. Schema migrations, Worker deployment, and -Vercel deployment are explicit operations; operators must sequence them using -the expand/contract rule above and verify Worker health and the production web -revision before applying destructive migrations. +Schema migrations, Worker deployment, and Vercel deployment are explicit +operations. Verify Worker health and the production web revision whenever a +release moves more than one surface. Publish a new immutable Daytona snapshot after changing `infra/containers/sandbox/` by dispatching the protected workflow from `main`: diff --git a/apps/agent-worker/README.md b/apps/agent-worker/README.md index 2b332d90..476fea5c 100644 --- a/apps/agent-worker/README.md +++ b/apps/agent-worker/README.md @@ -196,14 +196,15 @@ failed cleanup instead of silently leaking storage. Filesystem operations with a path remain concurrent across unrelated projects, but arbitrary code, shell execution, and process launch always take a non-exclusive global lease because path parsing cannot prove their runtime filesystem scope. Project cleanup fences and drains that lease, terminates every managed and -same-user untracked sandbox process, and only then removes the folder. Account deletion destroys shared -sandbox state once and removes run Durable Objects in bounded pages. The account cleanup -RPC synchronously fences new sandbox work, drains operations that already started, records -final sandbox usage, clears the user's Daytona volume subpath, and deletes every validated -sandbox. A temporary durable tombstone makes an interrupted cleanup resume behind the same -fence. Once external cleanup succeeds, the configured 2026-07-15 Workers compatibility contract -lets one atomic `deleteAll()` remove that tombstone, owner keys, workspace SQLite schema, and -alarm so the object ceases to occupy storage. +same-user untracked sandbox process, and only then removes the folder. Account +deletion destroys shared sandbox state once and removes run Durable Objects in +bounded pages. The account cleanup RPC synchronously fences new sandbox work, +drains operations that already started, records final sandbox usage, clears the +user's Daytona volume subpath, and deletes every validated sandbox. A temporary +durable tombstone makes an interrupted cleanup resume behind the same fence. +Once external cleanup succeeds, one atomic `deleteAll()` removes the tombstone, +owner keys, workspace SQLite schema, and alarm so the object ceases to occupy +storage. Constructors inspect existing identity and SQLite metadata without materializing an empty store. An object with no registered owner absorbs late lease/alarm cleanup and rejects every other @@ -221,38 +222,20 @@ project/thread soft-delete generation and verifies that every requested run belo scope. The 30-second signature window is therefore safe to retry and cannot authorize stale or cross-tenant destruction; no shared key or legacy signature fallback exists. -Workspace and sandbox releases use a separate signed internal RPC. For one exact -release SHA, the closed release gate and an in-memory mutation lease reject concurrent -workspace operations. Preparation stops affected processes, collision-checks and renames -Daytona folders, reconciles process and port state, and records only temporary KV evidence for -the canonical folders that existed. Finalization reloads the already-canonical Postgres -inventory and requires the same physical evidence before snapshot work begins. The release -workflow drains all AgentRuns before this phase, so no stale run can recreate a replaced path. -Generic Durable Object reconciliation deliberately runs first: it contracts the permanent -SQLite schema to the project tombstone table and removes the one-time transition and retired-slug -tables; prepare and finalize do not depend on either table. An owner with no materialized sandbox -state uses only the in-memory maintenance lease plus the temporary evidence key, so successful -reconciliation does not leave an empty SQLite store behind. - -Finalization also reconciles the user's existing Daytona sandbox to the exact configured -snapshot. Volume-backed replacements mount the same isolated subpath and compare complete tree -digests. The one-time adoption of a local-disk sandbox creates a deterministic archive and copies -it through durable 8 MiB chunks; there is no total workspace-size cap. A candidate never carries -the canonical label while the source does. After digest verification the source is retired, the -candidate receives the full canonical label set, the Durable Object atomically adopts its exact -ID, and only then is the old sandbox deleted. Every boundary is retryable by the temporary -upgrade phase and deterministic candidate identity. Once final verification succeeds, both the -workspace-transition evidence and snapshot-upgrade state are deleted; an ambiguous response can -therefore retry against the canonical physical state without leaving cutover residue. Account -deletion clears the user's shared-volume subpath before deleting all exact owned sandboxes, so -persistent volume data does not outlive the account. +Every ProjectSandbox uses the one configured immutable Daytona snapshot and the +one configured shared workspace volume. Existing sandbox identity is accepted +only when its owner, canonical labels, snapshot, volume, and mount contract all +match. Mismatches fail closed instead of running a hidden migration. New +sandboxes mount the user's isolated volume subpath directly at `/workspace`. +Account deletion clears that subpath before deleting all exactly owned +sandboxes, so persistent volume data does not outlive the account. Production binds `CHEATCODE_RELEASE_GATE` explicitly. `draining` rejects public run, sandbox, preview, download, and deletion admission while allowing already admitted AgentRun Workflow/DO callbacks, sandbox operations, and persistence to finish. `closed` additionally fences those continuation paths and serves only -`/health` plus the exact signed canonical-workspace reconciliation RPC. Stable -drain proofs run at both gates before DDL. +`/health` plus the signed database-readiness RPC. Stable drain proofs run at +both gates before DDL. Project ZIP generation and streaming share the exact `PROJECT_ARCHIVE_MAX_OUTPUT_BYTES` contract from `@cheatcode/types` (640 MiB). The @@ -276,7 +259,7 @@ pnpm --filter @cheatcode/agent-worker typecheck - `CHEATCODE_ENVIRONMENT` (`production` in committed Wrangler config; local generated config overrides it) - `CHEATCODE_RELEASE_SHA` (required for production deployments) -- `CHEATCODE_RELEASE_GATE` (`open` in source; coordinated releases inject `draining` and then `closed` until migration/reconciliation complete) +- `CHEATCODE_RELEASE_GATE` (`open` in source; coordinated releases inject `draining` and then `closed` until migration and database-readiness checks complete) - `CF_VERSION_METADATA` - `AGENT_RUN` - `AGENT_RUN_WORKFLOW` diff --git a/apps/agent-worker/src/agent-api-system-routes.ts b/apps/agent-worker/src/agent-api-system-routes.ts index f0afd073..7fefc21f 100644 --- a/apps/agent-worker/src/agent-api-system-routes.ts +++ b/apps/agent-worker/src/agent-api-system-routes.ts @@ -3,7 +3,6 @@ import { findGeneratedOutput, getProject, isAgentStateDeletionAuthorized, - loadWorkspaceTransitionOwner, withUserContext, } from "@cheatcode/db"; import { resolveWorkerSecret, type WorkerSecret } from "@cheatcode/env"; @@ -11,10 +10,7 @@ import { APIError, readBoundedRequestText } from "@cheatcode/observability"; import { InternalAgentStateDeleteBodySchema, InternalStateDeleteResponseSchema, - InternalWorkspaceReconciliationBodySchema, - InternalWorkspaceReconciliationResponseSchema, internalUserStateDeletePath, - internalUserWorkspaceReconciliationPath, OutputIdSchema, ProjectId, UserId, @@ -47,108 +43,11 @@ type AgentContext = Context<{ Bindings: AgentEnv }>; export function registerAgentSystemHttpRoutes(app: Hono<{ Bindings: AgentEnv }>): void { app.post("/internal/users/:userId/delete-state", deleteInternalUserState); - app.post("/internal/users/:userId/reconcile-workspaces", reconcileInternalUserWorkspaces); app.post("/v1/outputs/:outputId/download-url", mintOutputDownloadUrl); app.get("/v1/outputs/:outputId/download", downloadOutput); app.post("/v1/projects/:projectId/download", downloadProjectArchive); } -async function reconcileInternalUserWorkspaces(c: AgentContext): Promise { - if (c.env.CHEATCODE_RELEASE_GATE !== "closed") { - throw new APIError( - 409, - "conflict_state_invalid", - "Workspace reconciliation requires the closed release gate", - { retriable: false }, - ); - } - assertAgentInternalHostname(c.req.raw); - assertAgentLifecycleCapability(c.req.raw); - const userId = UserId(GatewayUserIdSchema.parse(c.req.param("userId"))); - const rawBody = await readBoundedRequestText( - c.req.raw, - MAX_INTERNAL_MAINTENANCE_BODY_BYTES, - "Internal workspace reconciliation", - ); - await verifyAgentLifecycleRequest({ - expectedPathname: internalUserWorkspaceReconciliationPath(userId), - rawBody, - request: c.req.raw, - secrets: c.env, - }); - const body = InternalWorkspaceReconciliationBodySchema.parse( - parseInternalMaintenanceJson(rawBody), - ); - if (c.env.CHEATCODE_RELEASE_SHA !== body.releaseSha) { - throw new APIError(409, "conflict_state_invalid", "Agent release does not match transition", { - details: { actualReleaseSha: c.env.CHEATCODE_RELEASE_SHA ?? null }, - retriable: false, - }); - } - await assertWorkspaceTransitionInventory(c.env, userId, body); - const sandbox = await sandboxStubForUser(c.env, userId); - const result = - body.phase === "prepare" - ? await sandbox.prepareWorkspaceTransition(body) - : await sandbox.finalizeWorkspaceTransition(body); - return c.json(InternalWorkspaceReconciliationResponseSchema.parse(result)); -} - -async function assertWorkspaceTransitionInventory( - env: AgentEnv, - userId: UserId, - body: z.infer, -): Promise { - const { db, close } = createDb(env.HYPERDRIVE, { - audience: "app_agent", - signingSecret: env.DATABASE_CONTEXT_SIGNING_SECRET_AGENT, - }); - try { - const owner = await withUserContext(db, userId, (transaction) => - loadWorkspaceTransitionOwner(transaction, userId), - ); - if (!owner || !workspaceInventoryMatches(owner.projects, body.projects, body.phase)) { - throw new APIError( - 409, - "conflict_state_invalid", - "Postgres workspace inventory does not match transition", - { retriable: false }, - ); - } - } finally { - await close(); - } -} - -function workspaceInventoryMatches( - actual: Array<{ - canonicalWorkspaceSlug: string; - currentWorkspaceSlug: string; - projectId: string; - }>, - requested: Array<{ - canonicalWorkspaceSlug: string; - currentWorkspaceSlug: string; - projectId: string; - }>, - phase: "finalize" | "prepare", -): boolean { - if (actual.length !== requested.length) { - return false; - } - const requestedById = new Map(requested.map((project) => [project.projectId, project])); - return actual.every((project) => { - const request = requestedById.get(project.projectId); - return ( - request?.canonicalWorkspaceSlug === project.canonicalWorkspaceSlug && - (phase === "finalize" - ? project.currentWorkspaceSlug === request.canonicalWorkspaceSlug - : project.currentWorkspaceSlug === request.currentWorkspaceSlug || - project.currentWorkspaceSlug === request.canonicalWorkspaceSlug) - ); - }); -} - async function deleteInternalUserState(c: AgentContext): Promise { assertAgentInternalHostname(c.req.raw); assertAgentLifecycleCapability(c.req.raw); diff --git a/apps/agent-worker/src/durable-object-storage.ts b/apps/agent-worker/src/durable-object-storage.ts deleted file mode 100644 index cd3f0a2c..00000000 --- a/apps/agent-worker/src/durable-object-storage.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { APIError, readBoundedRequestText } from "@cheatcode/observability"; -import { - INTERNAL_DURABLE_OBJECT_STORAGE_PATH, - InternalDurableObjectStorageRequestSchema, - InternalDurableObjectStorageResponseSchema, -} from "@cheatcode/types"; -import type { Context, Hono } from "hono"; -import type { AgentEnv } from "./agent-env"; -import { - assertAgentDurableObjectStorageCapability, - assertAgentInternalHostname, - parseInternalMaintenanceJson, - verifyAgentDurableObjectStorageRequest, -} from "./internal-maintenance"; - -const MAX_STORAGE_BODY_BYTES = 4 * 1024; -type AgentContext = Context<{ Bindings: AgentEnv }>; - -export function registerAgentDurableObjectStorageRoute(app: Hono<{ Bindings: AgentEnv }>): void { - app.post(INTERNAL_DURABLE_OBJECT_STORAGE_PATH, handleDurableObjectStorage); -} - -async function handleDurableObjectStorage(c: AgentContext): Promise { - assertClosedRelease(c.env); - assertAgentInternalHostname(c.req.raw); - assertAgentDurableObjectStorageCapability(c.req.raw); - const rawBody = await readBoundedRequestText( - c.req.raw, - MAX_STORAGE_BODY_BYTES, - "Durable Object storage request", - ); - await verifyAgentDurableObjectStorageRequest({ - expectedPathname: INTERNAL_DURABLE_OBJECT_STORAGE_PATH, - rawBody, - request: c.req.raw, - secrets: c.env, - }); - const input = InternalDurableObjectStorageRequestSchema.parse( - parseInternalMaintenanceJson(rawBody), - ); - if (input.releaseSha !== c.env.CHEATCODE_RELEASE_SHA) { - throw releaseMismatch("Durable Object request does not match the agent release"); - } - if (input.className === "AgentRun") { - const id = c.env.AGENT_RUN.idFromString(input.objectId); - return c.json( - InternalDurableObjectStorageResponseSchema.parse( - await c.env.AGENT_RUN.get(id).reconcileStorageSchema(input), - ), - ); - } - if (input.className === "ProjectSandbox") { - const id = c.env.PROJECT_SANDBOX.idFromString(input.objectId); - return c.json( - InternalDurableObjectStorageResponseSchema.parse( - await c.env.PROJECT_SANDBOX.get(id).reconcileStorageSchema(input), - ), - ); - } - throw releaseMismatch("Durable Object class is not owned by the agent Worker"); -} - -function assertClosedRelease(env: AgentEnv): void { - if (env.CHEATCODE_RELEASE_GATE !== "closed") { - throw releaseMismatch("Durable Object reconciliation requires the closed release gate"); - } -} - -function releaseMismatch(message: string): APIError { - return new APIError(409, "conflict_state_invalid", message, { retriable: false }); -} diff --git a/apps/agent-worker/src/durable-objects/agent-run-storage.ts b/apps/agent-worker/src/durable-objects/agent-run-storage.ts index c20422e6..d0e1652f 100644 --- a/apps/agent-worker/src/durable-objects/agent-run-storage.ts +++ b/apps/agent-worker/src/durable-objects/agent-run-storage.ts @@ -1,6 +1,5 @@ import { assertExactSqliteSchema, - assertSqliteRowCountPreserved, type ExpectedSqliteObject, setCurrentSqliteStorageVersion, } from "@cheatcode/durable-storage"; @@ -21,33 +20,8 @@ const OWNER_USER_ID_KEY = "owner_user_id"; const RESOLVED_LOGICAL_MODEL_ID_KEY = "resolved_logical_model_id"; const RUN_STATUS_VALUES_SQL = "'pending','running','completed','failed','canceled'"; -interface ExpectedColumn { - defaultValue: string | null; - isNotNull: boolean; - isPrimaryKey: boolean; - name: string; - type: string; -} - -const RUN_COLUMNS = [ - column("id", "TEXT", true, true), - column("status", "TEXT", true), - column("model_id", "TEXT", true), - column("created_at", "INTEGER", true), - column("started_at", "INTEGER"), - column("completed_at", "INTEGER"), -] as const; -const MESSAGE_PART_COLUMNS = [ - column("seq", "INTEGER", false, true), - column("part_type", "TEXT", true), - column("payload_json", "TEXT", true), -] as const; const MESSAGE_PART_PAGE_MAX_BYTES = 256 * 1024; const MESSAGE_PART_PAGE_MAX_ROWS = 32; -const RUN_STATE_COLUMNS = [ - column("key", "TEXT", true, true), - column("value", "TEXT", true), -] as const; const RUN_TABLE_SQL = `CREATE TABLE run ( id TEXT PRIMARY KEY CHECK (length(id) = 36), status TEXT NOT NULL CHECK (status IN (${RUN_STATUS_VALUES_SQL})), @@ -88,11 +62,12 @@ export interface StoredRunSnapshot { } export function initializeAgentRunStorage(ctx: DurableObjectState): void { - reconcileRunTable(ctx); - reconcileMessagePartTable(ctx); - reconcileRunStateTable(ctx); - normalizeRunStateStatus(ctx); - setCurrentSqliteStorageVersion(ctx); + ctx.storage.transactionSync(() => { + ctx.storage.sql.exec(RUN_TABLE_SQL); + ctx.storage.sql.exec(MESSAGE_PART_TABLE_SQL); + ctx.storage.sql.exec(RUN_STATE_TABLE_SQL); + setCurrentSqliteStorageVersion(ctx); + }); assertAgentRunStorage(ctx); } @@ -107,44 +82,6 @@ export function hasAgentRunStorage(ctx: DurableObjectState): boolean { ); } -/** Force-normalizes dormant run objects while the production release gate is closed. */ -export function reconcileAgentRunStorage(ctx: DurableObjectState): void { - prepareAgentRunRebuild(ctx); - ctx.storage.transactionSync(() => { - rebuildAgentRunTables(ctx); - normalizeRunStateStatus(ctx); - removePersistedArtifactCapabilities(ctx); - }); - setCurrentSqliteStorageVersion(ctx); - assertAgentRunStorage(ctx); -} - -function prepareAgentRunRebuild(ctx: DurableObjectState): void { - const sources = [ - { columns: RUN_COLUMNS, create: () => createRunTable(ctx, "run"), table: "run" }, - { - columns: MESSAGE_PART_COLUMNS, - create: () => createMessagePartTable(ctx, "message_part"), - table: "message_part", - }, - { - columns: RUN_STATE_COLUMNS, - create: () => createRunStateTable(ctx, "run_state"), - table: "run_state", - }, - ] as const; - for (const source of sources) { - const columns = tableColumns(ctx, source.table); - if (columns.length === 0) { - source.create(); - continue; - } - if (!source.columns.every(({ name }) => hasColumn(columns, name))) { - throw new Error(`Unsupported AgentRun ${source.table} schema; refusing lossy evolution.`); - } - } -} - export function assertAgentRunStorage(ctx: DurableObjectState): void { assertExactSqliteSchema(ctx, AGENT_RUN_STORAGE_SCHEMA); } @@ -199,34 +136,6 @@ export function deleteRunStateValues(ctx: DurableObjectState, keys: string[]): v } } -function removePersistedArtifactCapabilities(ctx: DurableObjectState): void { - const rows = ctx.storage.sql - .exec("SELECT seq, payload_json FROM message_part WHERE part_type = 'data-artifact'") - .toArray(); - for (const row of rows) { - if ( - !isRecord(row) || - typeof row["seq"] !== "number" || - typeof row["payload_json"] !== "string" - ) { - throw new Error("Invalid stored artifact transcript row; refusing lossy reconciliation."); - } - const parsed = JSON.parse(row["payload_json"]) as unknown; - if (!isRecord(parsed) || parsed["type"] !== "data-artifact" || !isRecord(parsed["data"])) { - throw new Error("Invalid stored artifact payload; refusing lossy reconciliation."); - } - if (!("downloadUrl" in parsed["data"])) { - continue; - } - const data = { ...parsed["data"], downloadUrl: undefined }; - ctx.storage.sql.exec( - "UPDATE message_part SET payload_json = ? WHERE seq = ?", - JSON.stringify({ ...parsed, data }), - row["seq"], - ); - } -} - export function upsertRunRow(ctx: DurableObjectState, input: StoredRunIdentity): void { const now = Date.now(); ctx.storage.sql.exec( @@ -386,158 +295,6 @@ export function readStoredRunSnapshot(ctx: DurableObjectState): StoredRunSnapsho }; } -function reconcileRunTable(ctx: DurableObjectState): void { - const columns = tableColumns(ctx, "run"); - if (columns.length === 0) { - createRunTable(ctx, "run"); - return; - } - if (hasExactColumns(columns, RUN_COLUMNS) && hasCurrentRunTableSql(ctx)) { - return; - } - if (!RUN_COLUMNS.every(({ name }) => hasColumn(columns, name))) { - throw new Error("Unsupported AgentRun run schema; refusing lossy evolution."); - } - ctx.storage.transactionSync(() => { - ctx.storage.sql.exec("DROP TABLE IF EXISTS run_next"); - createRunTable(ctx, "run_next"); - copyRunRows(ctx, "run", "run_next"); - assertSqliteRowCountPreserved(ctx, "run", "run_next"); - ctx.storage.sql.exec("DROP TABLE run"); - ctx.storage.sql.exec("ALTER TABLE run_next RENAME TO run"); - }); -} - -function createRunTable(ctx: DurableObjectState, table: "run" | "run_next"): void { - ctx.storage.sql.exec(RUN_TABLE_SQL.replace("CREATE TABLE run", `CREATE TABLE ${table}`)); -} - -function reconcileMessagePartTable(ctx: DurableObjectState): void { - const columns = tableColumns(ctx, "message_part"); - if (columns.length === 0) { - createMessagePartTable(ctx, "message_part"); - return; - } - if (hasExactColumns(columns, MESSAGE_PART_COLUMNS)) { - return; - } - if (!MESSAGE_PART_COLUMNS.every(({ name }) => hasColumn(columns, name))) { - throw new Error("Unsupported AgentRun message schema; refusing lossy evolution."); - } - ctx.storage.transactionSync(() => { - ctx.storage.sql.exec("DROP TABLE IF EXISTS message_part_next"); - createMessagePartTable(ctx, "message_part_next"); - const names = MESSAGE_PART_COLUMNS.map(({ name }) => name).join(", "); - ctx.storage.sql.exec( - `INSERT INTO message_part_next (${names}) SELECT ${names} FROM message_part`, - ); - assertSqliteRowCountPreserved(ctx, "message_part", "message_part_next"); - ctx.storage.sql.exec("DROP TABLE message_part"); - ctx.storage.sql.exec("ALTER TABLE message_part_next RENAME TO message_part"); - }); -} - -function createMessagePartTable( - ctx: DurableObjectState, - table: "message_part" | "message_part_next", -): void { - ctx.storage.sql.exec( - MESSAGE_PART_TABLE_SQL.replace("CREATE TABLE message_part", `CREATE TABLE ${table}`), - ); -} - -function reconcileRunStateTable(ctx: DurableObjectState): void { - const columns = tableColumns(ctx, "run_state"); - if (columns.length === 0) { - createRunStateTable(ctx, "run_state"); - return; - } - if (hasExactColumns(columns, RUN_STATE_COLUMNS)) { - return; - } - if (!RUN_STATE_COLUMNS.every(({ name }) => hasColumn(columns, name))) { - throw new Error("Unsupported AgentRun state schema; refusing lossy evolution."); - } - ctx.storage.transactionSync(() => { - ctx.storage.sql.exec("DROP TABLE IF EXISTS run_state_next"); - createRunStateTable(ctx, "run_state_next"); - ctx.storage.sql.exec( - "INSERT INTO run_state_next (key, value) SELECT key, value FROM run_state", - ); - assertSqliteRowCountPreserved(ctx, "run_state", "run_state_next"); - ctx.storage.sql.exec("DROP TABLE run_state"); - ctx.storage.sql.exec("ALTER TABLE run_state_next RENAME TO run_state"); - }); -} - -function createRunStateTable(ctx: DurableObjectState, table: "run_state" | "run_state_next"): void { - ctx.storage.sql.exec( - RUN_STATE_TABLE_SQL.replace("CREATE TABLE run_state", `CREATE TABLE ${table}`), - ); -} - -function rebuildAgentRunTables(ctx: DurableObjectState): void { - for (const table of ["run", "message_part", "run_state"] as const) { - ctx.storage.sql.exec(`DROP TABLE IF EXISTS ${table}_reconcile_source`); - ctx.storage.sql.exec(`ALTER TABLE ${table} RENAME TO ${table}_reconcile_source`); - } - ctx.storage.sql.exec(RUN_TABLE_SQL); - ctx.storage.sql.exec(MESSAGE_PART_TABLE_SQL); - ctx.storage.sql.exec(RUN_STATE_TABLE_SQL); - copyRunRows(ctx, "run_reconcile_source", "run"); - ctx.storage.sql.exec( - `INSERT INTO message_part (seq, part_type, payload_json) - SELECT seq, part_type, payload_json FROM message_part_reconcile_source`, - ); - ctx.storage.sql.exec( - "INSERT INTO run_state (key, value) SELECT key, value FROM run_state_reconcile_source", - ); - for (const table of ["run", "message_part", "run_state"] as const) { - assertSqliteRowCountPreserved(ctx, `${table}_reconcile_source`, table); - ctx.storage.sql.exec(`DROP TABLE ${table}_reconcile_source`); - } -} - -function tableColumns(ctx: DurableObjectState, table: "message_part" | "run" | "run_state") { - return ctx.storage.sql.exec(`PRAGMA table_info(${table})`).toArray(); -} - -function hasExactColumns(rows: unknown[], expected: readonly ExpectedColumn[]): boolean { - return ( - rows.length === expected.length && - expected.every((value, index) => { - const row = rows[index]; - return ( - isRecord(row) && - row["cid"] === index && - row["name"] === value.name && - row["type"] === value.type && - row["notnull"] === Number(value.isNotNull) && - row["pk"] === Number(value.isPrimaryKey) && - row["dflt_value"] === value.defaultValue - ); - }) - ); -} - -function hasColumn(rows: unknown[], name: string): boolean { - return rows.some((row) => isRecord(row) && row["name"] === name); -} - -function column( - name: string, - type: string, - isNotNull = false, - isPrimaryKey = false, - defaultValue: string | null = null, -): ExpectedColumn { - return { defaultValue, isNotNull, isPrimaryKey, name, type }; -} - -function isRecord(value: unknown): value is Record { - return typeof value === "object" && value !== null; -} - function readMessageStats(ctx: DurableObjectState): { lastSeq: number; messageCount: number } { const rows = ctx.storage.sql .exec("SELECT COUNT(*) AS message_count, COALESCE(MAX(seq), 0) AS last_seq FROM message_part") @@ -587,51 +344,6 @@ function runStatusColumn( return null; } -function hasCurrentRunTableSql(ctx: DurableObjectState): boolean { - const row = firstRecord( - ctx.storage.sql - .exec("SELECT sql FROM sqlite_schema WHERE type = 'table' AND name = 'run'") - .toArray(), - ); - const sql = row?.["sql"]; - return typeof sql === "string" && compactSql(sql) === compactSql(RUN_TABLE_SQL); -} - -function compactSql(sql: string): string { - return sql.replace(/\s+/g, " ").trim().toLowerCase(); -} - -function copyRunRows( - ctx: DurableObjectState, - source: "run" | "run_reconcile_source", - target: "run" | "run_next", -): void { - ctx.storage.sql.exec( - `INSERT INTO ${target} (id, status, model_id, created_at, started_at, completed_at) - SELECT id, - CASE WHEN status IN (${RUN_STATUS_VALUES_SQL}) THEN status ELSE 'canceled' END, - model_id, - created_at, - started_at, - CASE - WHEN status IN (${RUN_STATUS_VALUES_SQL}) THEN completed_at - ELSE COALESCE(completed_at, started_at, created_at) - END - FROM ${source}`, - ); -} - -function normalizeRunStateStatus(ctx: DurableObjectState): void { - const status = getRunStateValue(ctx, "status"); - if (!status || ["running", "completed", "failed", "canceled"].includes(status)) { - return; - } - setRunStateValue(ctx, "status", "canceled"); - if (!getRunStateValue(ctx, "completed_at")) { - setRunStateValue(ctx, "completed_at", String(Date.now())); - } -} - function parseLogicalModelId(value: string | null | undefined): LogicalModelId | undefined { const parsed = LogicalModelIdSchema.safeParse(value); return parsed.success ? parsed.data : undefined; diff --git a/apps/agent-worker/src/durable-objects/agent-run.ts b/apps/agent-worker/src/durable-objects/agent-run.ts index 0f2c5754..3a0d390c 100644 --- a/apps/agent-worker/src/durable-objects/agent-run.ts +++ b/apps/agent-worker/src/durable-objects/agent-run.ts @@ -6,14 +6,7 @@ import type { CodeRuntimeContext, WorkspaceResolver, } from "@cheatcode/sandbox-contracts"; -import { - AgentRunId, - type InternalDurableObjectStorageRequest, - ProjectId, - RunStatusSnapshotSchema, - ThreadId, - UserId, -} from "@cheatcode/types"; +import { AgentRunId, ProjectId, RunStatusSnapshotSchema, ThreadId, UserId } from "@cheatcode/types"; import type { UIMessageChunk } from "ai"; import { createAgentStreamResponse } from "../streaming/ui-message-stream"; import { armAgentRunAlarm, armClosedAgentRunAlarm } from "./agent-run-alarm"; @@ -51,6 +44,7 @@ import { retryPendingAgentRunStatus, } from "./agent-run-status-persistence"; import { + assertAgentRunStorage, claimAgentRunDeletion, getRunStateTimestamp, getRunStateValue, @@ -64,7 +58,6 @@ import { import type { StreamDriverDeps } from "./agent-run-stream-driver"; import { AgentRunWorkflowController } from "./agent-run-workflow-controller"; import { createRunWorkspaceResolver } from "./agent-run-workspace"; -import { reconcileAgentRunStorageRequest } from "./durable-storage-reconciliation"; import { mastraChunkError, normalizeMastraStreamError } from "./mastra-stream-chunks"; import { hasActiveRun } from "./run-state"; import { type AgentRunSnapshotStatus, snapshotAgentRunStatus } from "./run-summary"; @@ -119,6 +112,7 @@ export class AgentRun extends DurableObject { await this.ctx.storage.deleteAlarm(); return; } + assertAgentRunStorage(this.ctx); if (this.env.CHEATCODE_RELEASE_GATE === "closed") { await armClosedAgentRunAlarm(this.ctx, this.getStatus()); return; @@ -134,9 +128,6 @@ export class AgentRun extends DurableObject { } } - public reconcileStorageSchema(value: InternalDurableObjectStorageRequest) { - return reconcileAgentRunStorageRequest(this.ctx, this.env, value); - } private async handleAlarm(): Promise { if (isAgentRunDeleted(this.ctx)) { await this.ctx.storage.deleteAlarm(); @@ -189,6 +180,9 @@ export class AgentRun extends DurableObject { // FIFO admission makes /start settle before a later presence probe observes the object. const response = this.requestAdmissionTail.then(() => { const hasStorage = hasAgentRunStorage(this.ctx); + if (hasStorage) { + assertAgentRunStorage(this.ctx); + } return handleAgentRunRequest(request, { browserTakeoverResume: (userId, takeoverId) => hasStorage ? this.browserTakeover.resume(userId, takeoverId) : absentAgentRunOkResponse(), diff --git a/apps/agent-worker/src/durable-objects/durable-storage-reconciliation.ts b/apps/agent-worker/src/durable-objects/durable-storage-reconciliation.ts deleted file mode 100644 index 9eda3f98..00000000 --- a/apps/agent-worker/src/durable-objects/durable-storage-reconciliation.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { - assertStorageReconciliationRequest, - reconcileExactSqliteStorage, - storageSchemaEvidence, -} from "@cheatcode/durable-storage"; -import type { - InternalDurableObjectStorageRequest, - InternalDurableObjectStorageResponse, -} from "@cheatcode/types"; -import type { AgentRunEnv } from "./agent-run-env"; -import { assertAgentRunStorage, reconcileAgentRunStorage } from "./agent-run-storage"; -import type { ProjectSandboxEnv } from "./project-sandbox-lifecycle-support"; -import { - assertProjectSandboxStorage, - reconcileProjectSandboxStorage, -} from "./project-sandbox-workspace-state"; - -export function reconcileAgentRunStorageRequest( - ctx: DurableObjectState, - env: AgentRunEnv, - value: InternalDurableObjectStorageRequest, -): InternalDurableObjectStorageResponse { - const input = assertStorageReconciliationRequest(ctx, env, value, "AgentRun"); - reconcileExactSqliteStorage( - input.mode, - () => assertAgentRunStorage(ctx), - () => reconcileAgentRunStorage(ctx), - ); - return storageSchemaEvidence(input); -} - -export function reconcileProjectSandboxStorageRequest( - ctx: DurableObjectState, - env: ProjectSandboxEnv, - value: InternalDurableObjectStorageRequest, -): InternalDurableObjectStorageResponse { - const input = assertStorageReconciliationRequest(ctx, env, value, "ProjectSandbox"); - reconcileExactSqliteStorage( - input.mode, - () => assertProjectSandboxStorage(ctx), - () => reconcileProjectSandboxStorage(ctx), - ); - return storageSchemaEvidence(input); -} diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-cleanup-script.ts b/apps/agent-worker/src/durable-objects/project-sandbox-cleanup-script.ts new file mode 100644 index 00000000..1fcf63e2 --- /dev/null +++ b/apps/agent-worker/src/durable-objects/project-sandbox-cleanup-script.ts @@ -0,0 +1,24 @@ +import { shellQuote } from "./project-sandbox-process-support"; + +const CLEAR_WORKSPACE_SCRIPT = ` +import base64 +import json +import os +import shutil + +json.loads(base64.b64decode(__import__("sys").argv[1]).decode("utf-8")) +root = "/workspace" +os.makedirs(root, exist_ok=True) +for name in os.listdir(root): + path = os.path.join(root, name) + if os.path.isdir(path) and not os.path.islink(path): + shutil.rmtree(path) + else: + os.unlink(path) +print(json.dumps({"cleared": True}, separators=(",", ":"))) +`; + +export function clearWorkspaceCommand(): string { + const encoded = btoa(JSON.stringify({})); + return `python3 -c ${shellQuote(CLEAR_WORKSPACE_SCRIPT)} ${shellQuote(encoded)}`; +} diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-daytona-identity.ts b/apps/agent-worker/src/durable-objects/project-sandbox-daytona-identity.ts index bcc509d1..0f087416 100644 --- a/apps/agent-worker/src/durable-objects/project-sandbox-daytona-identity.ts +++ b/apps/agent-worker/src/durable-objects/project-sandbox-daytona-identity.ts @@ -19,44 +19,6 @@ export function canonicalSandboxLabels(input: { }; } -export function candidateSandboxLabels(input: { - sandboxName: string; - snapshot: string; - upgradeId: string; - volumeId: string; - volumeName: string; -}): Record { - return { - app: APP_LABEL, - role: "candidate", - sandboxOwner: input.sandboxName, - snapshot: input.snapshot, - upgradeId: input.upgradeId, - workspaceVolumeId: input.volumeId, - workspaceVolumeName: input.volumeName, - }; -} - -export function retiredSandboxLabels(input: { - sandbox: DaytonaSandbox; - sandboxName: string; - upgradeId: string; -}): Record { - return { - app: APP_LABEL, - role: "retired", - sandboxOwner: input.sandboxName, - snapshot: input.sandbox.snapshot, - upgradeId: input.upgradeId, - ...(input.sandbox.labels["workspaceVolumeId"] - ? { workspaceVolumeId: input.sandbox.labels["workspaceVolumeId"] } - : {}), - ...(input.sandbox.labels["workspaceVolumeName"] - ? { workspaceVolumeName: input.sandbox.labels["workspaceVolumeName"] } - : {}), - }; -} - export function isCanonicalSandbox(sandbox: DaytonaSandbox, sandboxName: string): boolean { return sandbox.labels["app"] === APP_LABEL && sandbox.labels["sandboxId"] === sandboxName; } @@ -79,29 +41,6 @@ export function isDesiredCanonicalSandbox( ); } -export function isUpgradeCandidate( - sandbox: DaytonaSandbox, - input: { - sandboxName: string; - snapshot: string; - upgradeId: string; - volumeId: string; - volumeName: string; - }, -): boolean { - return ( - sandbox.labels["app"] === APP_LABEL && - sandbox.labels["role"] === "candidate" && - sandbox.labels["sandboxOwner"] === input.sandboxName && - sandbox.labels["snapshot"] === input.snapshot && - sandbox.labels["upgradeId"] === input.upgradeId && - sandbox.labels["workspaceVolumeId"] === input.volumeId && - sandbox.labels["workspaceVolumeName"] === input.volumeName && - sandbox.snapshot === input.snapshot && - hasWorkspaceMount(sandbox, input.volumeId, input.sandboxName) - ); -} - function hasWorkspaceMount( sandbox: DaytonaSandbox, volumeId: string, diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-lifecycle.ts b/apps/agent-worker/src/durable-objects/project-sandbox-lifecycle.ts index 255e0351..6db0a3ba 100644 --- a/apps/agent-worker/src/durable-objects/project-sandbox-lifecycle.ts +++ b/apps/agent-worker/src/durable-objects/project-sandbox-lifecycle.ts @@ -9,6 +9,7 @@ import { } from "@cheatcode/tools-code"; import { z } from "zod"; import { type SandboxExecAuditEntry, writeExecAudit } from "./project-sandbox-audit"; +import { clearWorkspaceCommand } from "./project-sandbox-cleanup-script"; import { ProjectSandboxIdentityState } from "./project-sandbox-identity-state"; import { ACCOUNT_DELETION_TOMBSTONE_KEY, @@ -39,7 +40,6 @@ import type { ParsedProjectCleanupWorkspaceInput, ProjectSandboxRuntimeState, } from "./project-sandbox-runtime"; -import { clearWorkspaceCommand } from "./project-sandbox-snapshot-scripts"; import { initializeProjectSandboxStorage, openProjectSandboxWorkspaceState, @@ -54,7 +54,6 @@ export abstract class ProjectSandboxLifecycle extends DurableObject | undefined; private activeOperationCount = 0; private readonly activeOperationDrainWaiters = new Set<() => void>(); - private activeWorkspaceTransitionId: string | null = null; private daytonaClient: DaytonaClient | undefined; private daytonaId: string | undefined; private sandboxMutationTail: Promise = Promise.resolve(); @@ -89,7 +88,6 @@ export abstract class ProjectSandboxLifecycle extends DurableObject { @@ -119,7 +117,7 @@ export abstract class ProjectSandboxLifecycle extends DurableObject void) | undefined; try { - release = this.acquireActiveSandboxOperation(undefined, true); + release = this.acquireActiveSandboxOperation(true); return assertProjectSandboxOwnerActive(this.env, userId) .then(() => { if (this.accountDeletionInProgress) { @@ -152,72 +150,6 @@ export abstract class ProjectSandboxLifecycle extends DurableObject( - transitionId: string, - operation: () => Promise, - ): Promise { - if (this.env.CHEATCODE_RELEASE_GATE !== "closed") { - return Promise.reject( - new APIError( - 409, - "conflict_state_invalid", - "Workspace transitions require the closed release gate", - { retriable: false }, - ), - ); - } - return this.initializeIdentityState().then(() => - this.runActiveWorkspaceTransition(transitionId, operation), - ); - } - private runActiveWorkspaceTransition( - transitionId: string, - operation: () => Promise, - ): Promise { - let releaseSandbox: (() => void) | undefined; - let releaseWorkspace: (() => void) | undefined; - try { - const workspaceState = this.openWorkspaceState(); - releaseWorkspace = workspaceState - ? workspaceState.acquireTransitionMutation(transitionId) - : this.acquireTransientWorkspaceTransition(transitionId); - return Promise.all([ - this.waitForActiveSandboxOperations(), - workspaceState?.waitForWorkspaceDrain() ?? Promise.resolve(), - ]) - .then(() => { - releaseSandbox = this.acquireActiveSandboxOperation(transitionId, true); - return operation(); - }) - .finally(() => { - releaseSandbox?.(); - releaseWorkspace?.(); - }); - } catch (error) { - releaseWorkspace?.(); - releaseSandbox?.(); - return Promise.reject(error); - } - } - - private acquireTransientWorkspaceTransition(transitionId: string): () => void { - if (this.activeWorkspaceTransitionId !== null) { - throw new APIError(409, "conflict_state_invalid", "Workspace maintenance is in progress", { - retriable: true, - }); - } - this.activeWorkspaceTransitionId = transitionId; - let isReleased = false; - return () => { - if (isReleased) { - return; - } - isReleased = true; - if (this.activeWorkspaceTransitionId === transitionId) { - this.activeWorkspaceTransitionId = null; - } - }; - } protected withActiveProjectWorkspaceOperation( workspaceScope: string | readonly string[] | null, operation: () => Promise, @@ -301,11 +233,6 @@ export abstract class ProjectSandboxLifecycle extends DurableObject Promise, @@ -322,7 +249,7 @@ export abstract class ProjectSandboxLifecycle extends DurableObject void { @@ -552,7 +478,7 @@ export abstract class ProjectSandboxLifecycle extends DurableObject { diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-project-files.ts b/apps/agent-worker/src/durable-objects/project-sandbox-project-files.ts index 7a91ee18..2bf1a723 100644 --- a/apps/agent-worker/src/durable-objects/project-sandbox-project-files.ts +++ b/apps/agent-worker/src/durable-objects/project-sandbox-project-files.ts @@ -11,13 +11,13 @@ import { ProjectFileUploadResponseSchema, } from "@cheatcode/types"; import { z } from "zod"; +import { ProjectSandboxProcesses } from "./project-sandbox-processes"; import { type ProjectListUploadedFilesInput, ProjectListUploadedFilesInputSchema, type ProjectUploadFileInput, ProjectUploadFileInputSchema, } from "./project-sandbox-runtime"; -import { ProjectSandboxWorkspaceTransition } from "./project-sandbox-workspace-transition"; const FILE_DIGEST_DOMAIN = "cheatcode:project-file:v2"; const VERSION_DIGEST_DOMAIN = "cheatcode:project-file-version:v2"; @@ -49,7 +49,7 @@ interface PreparedProjectFile { versionId: string; } -export abstract class ProjectSandboxProjectFiles extends ProjectSandboxWorkspaceTransition { +export abstract class ProjectSandboxProjectFiles extends ProjectSandboxProcesses { private projectFileMutationTail: Promise = Promise.resolve(); public listUploadedFiles( diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-provisioning.ts b/apps/agent-worker/src/durable-objects/project-sandbox-provisioning.ts index cff2b9d4..35f5317d 100644 --- a/apps/agent-worker/src/durable-objects/project-sandbox-provisioning.ts +++ b/apps/agent-worker/src/durable-objects/project-sandbox-provisioning.ts @@ -46,7 +46,7 @@ export class ProjectSandboxProvisioning { throw new APIError( 503, "unavailable_maintenance", - "Sandbox requires release-scoped snapshot reconciliation", + "Sandbox does not match the configured runtime", { details: { actualSnapshot: resolved.snapshot, diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-scripts.ts b/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-scripts.ts deleted file mode 100644 index 94f4db7b..00000000 --- a/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-scripts.ts +++ /dev/null @@ -1,396 +0,0 @@ -import { shellQuote } from "./project-sandbox-process-support"; - -export const SNAPSHOT_TRANSFER_CHUNK_BYTES = 8 * 1024 * 1024; - -export function prepareWorkspaceArchiveCommand(upgradeId: string): string { - return pythonCommand(PREPARE_WORKSPACE_ARCHIVE_SCRIPT, { - chunkBytes: SNAPSHOT_TRANSFER_CHUNK_BYTES, - upgradeId, - }); -} - -export function verifyWorkspaceArchiveCommand(input: { - archiveDigest: string; - archiveSize: number; - chunkCount: number; - treeDigest: string; - upgradeId: string; -}): string { - return pythonCommand(VERIFY_WORKSPACE_ARCHIVE_SCRIPT, input); -} - -export function digestWorkspaceCommand(): string { - return pythonCommand(DIGEST_WORKSPACE_SCRIPT, {}); -} - -export function verifyTransferChunkCommand(input: { - digest: string; - path: string; - size: number; -}): string { - return pythonCommand(VERIFY_TRANSFER_CHUNK_SCRIPT, input); -} - -export function clearWorkspaceCommand(): string { - return pythonCommand(CLEAR_WORKSPACE_SCRIPT, {}); -} - -function pythonCommand(script: string, payload: unknown): string { - const encoded = btoa(JSON.stringify(payload)); - return `python3 -c ${shellQuote(script)} ${shellQuote(encoded)}`; -} - -const TREE_DIGEST_FUNCTIONS = ` -def raise_walk_error(error): - raise error - -def tree_entries(root): - values = [] - for current, directories, files in os.walk(root, topdown=True, onerror=raise_walk_error, followlinks=False): - directories.sort() - files.sort() - for name in directories + files: - path = os.path.join(current, name) - relative = os.path.relpath(path, root).replace(os.sep, "/") - values.append((relative, path)) - values.sort(key=lambda value: value[0]) - return values - -def tree_digest(root): - digest = hashlib.sha256() - for relative, path in tree_entries(root): - metadata = os.lstat(path) - mode = stat.S_IMODE(metadata.st_mode) - if stat.S_ISDIR(metadata.st_mode): - header = [relative, "directory", mode] - elif stat.S_ISREG(metadata.st_mode): - header = [relative, "file", mode, metadata.st_size] - elif stat.S_ISLNK(metadata.st_mode): - header = [relative, "symlink", mode, os.readlink(path)] - else: - raise RuntimeError(f"Unsupported workspace entry: {relative}") - encoded = json.dumps(header, ensure_ascii=True, separators=(",", ":")).encode("ascii") - digest.update(len(encoded).to_bytes(8, "big")) - digest.update(encoded) - if stat.S_ISREG(metadata.st_mode): - with open(path, "rb") as source: - while True: - block = source.read(1024 * 1024) - if not block: - break - digest.update(block) - return digest.hexdigest() -`; - -const PREPARE_WORKSPACE_ARCHIVE_SCRIPT = ` -import base64 -import hashlib -import json -import os -import shutil -import stat -import sys -import tarfile - -${TREE_DIGEST_FUNCTIONS} - -payload = json.loads(base64.b64decode(sys.argv[1]).decode("utf-8")) -upgrade_id = payload["upgradeId"] -chunk_bytes = payload["chunkBytes"] -if not isinstance(upgrade_id, str) or len(upgrade_id) != 32 or any(c not in "0123456789abcdef" for c in upgrade_id): - raise RuntimeError("Invalid snapshot upgrade identity") -if not isinstance(chunk_bytes, int) or chunk_bytes < 1: - raise RuntimeError("Invalid snapshot transfer chunk size") - -root = "/workspace" -base = f"/tmp/cheatcode-snapshot-upgrade/{upgrade_id}" -chunks_path = os.path.join(base, "chunks") -os.makedirs(root, exist_ok=True) -shutil.rmtree(base, ignore_errors=True) -os.makedirs(chunks_path, mode=0o700) - -class ChunkWriter: - def __init__(self, directory, chunk_size): - self.archive_digest = hashlib.sha256() - self.archive_size = 0 - self.chunk_count = 0 - self.chunk_size = chunk_size - self.current = None - self.current_size = 0 - self.directory = directory - - def write(self, data): - view = memoryview(data) - total = len(view) - while view: - if self.current is None: - path = os.path.join(self.directory, f"chunk-{self.chunk_count:012d}") - self.current = open(path, "wb") - self.current_size = 0 - self.chunk_count += 1 - take = min(len(view), self.chunk_size - self.current_size) - block = view[:take] - self.current.write(block) - self.archive_digest.update(block) - self.archive_size += take - self.current_size += take - view = view[take:] - if self.current_size == self.chunk_size: - self.current.close() - self.current = None - return total - - def flush(self): - if self.current is not None: - self.current.flush() - - def close(self): - if self.current is not None: - self.current.close() - self.current = None - -digest = tree_digest(root) -writer = ChunkWriter(chunks_path, chunk_bytes) -with tarfile.open(fileobj=writer, mode="w|", dereference=False) as archive: - for relative, path in tree_entries(root): - archive.add(path, arcname=relative, recursive=False) -writer.close() - -print(json.dumps({ - "archiveDigest": writer.archive_digest.hexdigest(), - "archiveSize": writer.archive_size, - "chunkCount": writer.chunk_count, - "treeDigest": digest, -}, separators=(",", ":"))) -`; - -const DIGEST_WORKSPACE_SCRIPT = ` -import base64 -import hashlib -import json -import os -import stat -import sys - -${TREE_DIGEST_FUNCTIONS} - -json.loads(base64.b64decode(sys.argv[1]).decode("utf-8")) -os.makedirs("/workspace", exist_ok=True) -print(json.dumps({"treeDigest": tree_digest("/workspace")}, separators=(",", ":"))) -`; - -const VERIFY_TRANSFER_CHUNK_SCRIPT = ` -import base64 -import hashlib -import json -import os -import sys - -payload = json.loads(base64.b64decode(sys.argv[1]).decode("utf-8")) -path = payload["path"] -if not isinstance(path, str) or not path.startswith("/tmp/cheatcode-snapshot-upgrade/"): - raise RuntimeError("Invalid snapshot transfer path") -digest = hashlib.sha256() -size = 0 -with open(path, "rb") as source: - while True: - block = source.read(1024 * 1024) - if not block: - break - digest.update(block) - size += len(block) -verified = size == payload["size"] and digest.hexdigest() == payload["digest"] -print(json.dumps({"verified": verified}, separators=(",", ":"))) -raise SystemExit(0 if verified else 4) -`; - -const CLEAR_WORKSPACE_SCRIPT = ` -import base64 -import json -import os -import shutil - -json.loads(base64.b64decode(__import__("sys").argv[1]).decode("utf-8")) -root = "/workspace" -os.makedirs(root, exist_ok=True) -for name in os.listdir(root): - path = os.path.join(root, name) - if os.path.isdir(path) and not os.path.islink(path): - shutil.rmtree(path) - else: - os.unlink(path) -print(json.dumps({"cleared": True}, separators=(",", ":"))) -`; - -const VERIFY_WORKSPACE_ARCHIVE_SCRIPT = ` -import base64 -import hashlib -import json -import os -from pathlib import PurePosixPath -import shutil -import sqlite3 -import stat -import sys -import tarfile - -${TREE_DIGEST_FUNCTIONS} - -payload = json.loads(base64.b64decode(sys.argv[1]).decode("utf-8")) -upgrade_id = payload["upgradeId"] -if not isinstance(upgrade_id, str) or len(upgrade_id) != 32 or any(c not in "0123456789abcdef" for c in upgrade_id): - raise RuntimeError("Invalid snapshot upgrade identity") -base = f"/tmp/cheatcode-snapshot-upgrade/{upgrade_id}" -chunks_path = os.path.join(base, "chunks") -directory_modes_path = os.path.join(base, "directory-modes.sqlite") - -def retry_transfer(reason): - print(json.dumps({"reason": reason, "retryTransfer": True}, separators=(",", ":"))) - raise SystemExit(3) - -archive_digest = hashlib.sha256() -archive_size = 0 -try: - for index in range(payload["chunkCount"]): - chunk_path = os.path.join(chunks_path, f"chunk-{index:012d}") - with open(chunk_path, "rb") as source: - while True: - block = source.read(1024 * 1024) - if not block: - break - archive_digest.update(block) - archive_size += len(block) -except FileNotFoundError: - retry_transfer("missing chunk") - -if archive_size != payload["archiveSize"] or archive_digest.hexdigest() != payload["archiveDigest"]: - retry_transfer("archive digest mismatch") - -def safe_relative(value): - path = PurePosixPath(value) - if path.is_absolute() or not path.parts or any(part in ("", ".", "..") for part in path.parts): - raise RuntimeError(f"Unsafe archive path: {value}") - return path - -def validate_link(member): - if not (member.issym() or member.islnk()): - return - link = PurePosixPath(member.linkname) - if link.is_absolute(): - raise RuntimeError(f"Absolute archive link: {member.name}") - combined = link if member.islnk() else PurePosixPath(member.name).parent / link - depth = 0 - for part in combined.parts: - if part in ("", "."): - continue - if part == "..": - depth -= 1 - else: - depth += 1 - if depth < 0: - raise RuntimeError(f"Escaping archive link: {member.name}") - -class ChunkReader: - def __init__(self, directory, count): - self.count = count - self.current = None - self.directory = directory - self.index = 0 - - def read(self, size=-1): - if size is None or size < 0: - size = 1024 * 1024 - output = bytearray() - while len(output) < size and self.index < self.count: - if self.current is None: - path = os.path.join(self.directory, f"chunk-{self.index:012d}") - self.current = open(path, "rb") - block = self.current.read(size - len(output)) - if block: - output.extend(block) - continue - self.current.close() - self.current = None - self.index += 1 - return bytes(output) - - def close(self): - if self.current is not None: - self.current.close() - self.current = None - -def target_path(relative): - parts = safe_relative(relative).parts - current = root - for part in parts[:-1]: - current = os.path.join(current, part) - if os.path.lexists(current): - metadata = os.lstat(current) - if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISDIR(metadata.st_mode): - raise RuntimeError(f"Unsafe archive parent: {relative}") - else: - os.mkdir(current, mode=0o700) - return os.path.join(root, *parts) - -root = "/workspace" -os.makedirs(root, exist_ok=True) -for name in os.listdir(root): - path = os.path.join(root, name) - if os.path.isdir(path) and not os.path.islink(path): - shutil.rmtree(path) - else: - os.unlink(path) - -if os.path.exists(directory_modes_path): - os.unlink(directory_modes_path) -directory_modes = sqlite3.connect(directory_modes_path) -directory_modes.execute("CREATE TABLE modes (path TEXT PRIMARY KEY, mode INTEGER NOT NULL)") -reader = ChunkReader(chunks_path, payload["chunkCount"]) -with tarfile.open(fileobj=reader, mode="r|") as archive: - for member in archive: - safe_relative(member.name) - validate_link(member) - if not (member.isdir() or member.isreg() or member.issym() or member.islnk()): - raise RuntimeError(f"Unsupported archive member: {member.name}") - target = target_path(member.name) - if member.isdir(): - if os.path.lexists(target) and not os.path.isdir(target): - raise RuntimeError(f"Archive directory collides with a file: {member.name}") - os.makedirs(target, mode=0o700, exist_ok=True) - os.chmod(target, 0o700) - directory_modes.execute("INSERT INTO modes (path, mode) VALUES (?, ?)", (target, member.mode)) - elif member.issym(): - if os.path.lexists(target): - raise RuntimeError(f"Archive symlink destination exists: {member.name}") - os.symlink(member.linkname, target) - elif member.islnk(): - source_path = target_path(member.linkname) - if not os.path.isfile(source_path) or os.path.islink(source_path): - raise RuntimeError(f"Archive hardlink source is unavailable: {member.name}") - with open(source_path, "rb") as source, open(target, "xb") as destination: - shutil.copyfileobj(source, destination, 1024 * 1024) - os.chmod(target, member.mode) - else: - source = archive.extractfile(member) - if source is None: - raise RuntimeError(f"Archive file has no payload: {member.name}") - with source, open(target, "xb") as destination: - shutil.copyfileobj(source, destination, 1024 * 1024) - os.chmod(target, member.mode) -reader.close() -directory_modes.commit() -for target, mode in directory_modes.execute("SELECT path, mode FROM modes ORDER BY length(path) DESC"): - os.chmod(target, mode) -directory_modes.close() -os.unlink(directory_modes_path) - -verified_tree = tree_digest(root) -if verified_tree != payload["treeDigest"]: - print(json.dumps({"reason": "workspace digest mismatch", "retryTransfer": False}, separators=(",", ":"))) - raise SystemExit(4) -print(json.dumps({ - "archiveDigest": archive_digest.hexdigest(), - "retryTransfer": False, - "treeDigest": verified_tree, -}, separators=(",", ":"))) -`; diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-state.ts b/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-state.ts deleted file mode 100644 index a1811e59..00000000 --- a/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-state.ts +++ /dev/null @@ -1,151 +0,0 @@ -import { z } from "zod"; - -export const SNAPSHOT_RELEASE_SHA_PATTERN = /^[0-9a-f]{40}$/u; -const UPGRADE_ID_PATTERN = /^[0-9a-f]{32}$/u; -const DIGEST_PATTERN = /^[0-9a-f]{64}$/u; - -const SnapshotUpgradeStateBaseSchema = z - .object({ - archiveDigest: z.string().regex(DIGEST_PATTERN).nullable(), - archiveSize: z.number().int().positive().nullable(), - candidateId: z.string().min(1).max(500).nullable(), - chunkCount: z.number().int().positive().nullable(), - needsTransfer: z.boolean(), - nextChunk: z.number().int().nonnegative(), - phase: z.enum([ - "claimed", - "source-prepared", - "candidate-created", - "candidate-verified", - "source-retired", - "candidate-promoted", - "switched", - "completed", - ]), - releaseSha: z.string().regex(SNAPSHOT_RELEASE_SHA_PATTERN), - sandboxName: z.string().min(1).max(100), - sourceId: z.string().min(1).max(500), - sourceSnapshot: z.string().min(1).max(500), - targetSnapshot: z.string().min(1).max(500), - treeDigest: z.string().regex(DIGEST_PATTERN).nullable(), - upgradeId: z.string().regex(UPGRADE_ID_PATTERN), - volumeId: z.string().uuid(), - volumeName: z.string().min(1).max(100), - }) - .strict(); - -export type SnapshotUpgradeState = z.infer; -export const SnapshotUpgradeStateSchema = - SnapshotUpgradeStateBaseSchema.superRefine(validateUpgradeState); - -function validateUpgradeState(state: SnapshotUpgradeState, context: z.RefinementCtx): void { - addStateIssue(context, preparedWithoutDigest(state), "Prepared upgrade has no tree digest."); - addStateIssue(context, incompleteTransferEvidence(state), "Transfer evidence is incomplete."); - addStateIssue(context, transferCursorExceeded(state), "Transfer cursor exceeds its chunk count."); - addStateIssue( - context, - mountedUpgradeHasTransferState(state), - "Mounted-volume upgrade has transfer state.", - ); - addStateIssue( - context, - verifiedCandidateHasMissingChunks(state), - "Verified candidate has incomplete chunks.", - ); - addStateIssue( - context, - claimedUpgradeHasEvidence(state), - "Claimed upgrade contains prepared evidence.", - ); - addStateIssue( - context, - candidatePhaseWithoutId(state), - "Candidate phase has no candidate sandbox.", - ); -} - -function addStateIssue(context: z.RefinementCtx, isInvalid: boolean, message: string): void { - if (isInvalid) context.addIssue({ code: "custom", message }); -} - -function preparedWithoutDigest(state: SnapshotUpgradeState): boolean { - return state.phase !== "claimed" && state.treeDigest === null; -} - -function incompleteTransferEvidence(state: SnapshotUpgradeState): boolean { - return ( - state.needsTransfer && - state.phase !== "claimed" && - (state.archiveDigest === null || state.archiveSize === null || state.chunkCount === null) - ); -} - -function transferCursorExceeded(state: SnapshotUpgradeState): boolean { - return state.needsTransfer && state.chunkCount !== null && state.nextChunk > state.chunkCount; -} - -function mountedUpgradeHasTransferState(state: SnapshotUpgradeState): boolean { - return ( - !state.needsTransfer && - (state.archiveDigest !== null || - state.archiveSize !== null || - state.chunkCount !== null || - state.nextChunk !== 0) - ); -} - -function verifiedCandidateHasMissingChunks(state: SnapshotUpgradeState): boolean { - return ( - state.needsTransfer && - isCandidateVerifiedPhase(state.phase) && - state.nextChunk !== state.chunkCount - ); -} - -function claimedUpgradeHasEvidence(state: SnapshotUpgradeState): boolean { - return ( - state.phase === "claimed" && - (state.archiveDigest !== null || - state.archiveSize !== null || - state.chunkCount !== null || - state.nextChunk !== 0 || - state.treeDigest !== null) - ); -} - -function candidatePhaseWithoutId(state: SnapshotUpgradeState): boolean { - return state.phase !== "claimed" && state.phase !== "source-prepared" && !state.candidateId; -} - -function isCandidateVerifiedPhase(phase: SnapshotUpgradeState["phase"]): boolean { - return ( - phase === "candidate-verified" || - phase === "source-retired" || - phase === "candidate-promoted" || - phase === "switched" || - phase === "completed" - ); -} - -export const ArchiveEvidenceSchema = z - .object({ - archiveDigest: z.string().regex(DIGEST_PATTERN), - archiveSize: z.number().int().positive(), - chunkCount: z.number().int().positive(), - treeDigest: z.string().regex(DIGEST_PATTERN), - }) - .strict(); -export const DigestEvidenceSchema = z - .object({ treeDigest: z.string().regex(DIGEST_PATTERN) }) - .strict(); -export const ChunkEvidenceSchema = z.object({ verified: z.boolean() }).strict(); -export const ArchiveVerificationSchema = z - .object({ - archiveDigest: z.string().regex(DIGEST_PATTERN), - retryTransfer: z.literal(false), - treeDigest: z.string().regex(DIGEST_PATTERN), - }) - .strict(); -export const RetryTransferSchema = z - .object({ reason: z.string().min(1).max(500), retryTransfer: z.literal(true) }) - .strict(); diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-upgrade.ts b/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-upgrade.ts deleted file mode 100644 index a59ee042..00000000 --- a/apps/agent-worker/src/durable-objects/project-sandbox-snapshot-upgrade.ts +++ /dev/null @@ -1,724 +0,0 @@ -import { APIError } from "@cheatcode/observability"; -import { DaytonaApiError, type DaytonaClient, type DaytonaSandbox } from "@cheatcode/tools-code"; -import type { SandboxSnapshotReconciliation } from "@cheatcode/types"; -import type { z } from "zod"; -import { - candidateSandboxLabels, - canonicalSandboxLabels, - isDesiredCanonicalSandbox, - isUpgradeCandidate, - retiredSandboxLabels, -} from "./project-sandbox-daytona-identity"; -import { - AUTO_ARCHIVE_MIN, - DAYTONA_ID_KEY, - DEFAULT_IDLE_STOP_MIN, - NEVER_AUTO_DELETE, - type ProjectSandboxEnv, -} from "./project-sandbox-lifecycle-support"; -import { isDestroyed, sleep } from "./project-sandbox-process-support"; -import type { ProjectSandboxProvisioning } from "./project-sandbox-provisioning"; -import { - digestWorkspaceCommand, - prepareWorkspaceArchiveCommand, - SNAPSHOT_TRANSFER_CHUNK_BYTES, - verifyTransferChunkCommand, - verifyWorkspaceArchiveCommand, -} from "./project-sandbox-snapshot-scripts"; -import { - ArchiveEvidenceSchema, - ArchiveVerificationSchema, - ChunkEvidenceSchema, - DigestEvidenceSchema, - RetryTransferSchema, - SNAPSHOT_RELEASE_SHA_PATTERN, - type SnapshotUpgradeState, - SnapshotUpgradeStateSchema, -} from "./project-sandbox-snapshot-state"; - -const SNAPSHOT_UPGRADE_STATE_KEY = "sandbox_snapshot_upgrade"; -const SNAPSHOT_EXEC_TIMEOUT_SECONDS = 480; -const DELETE_VERIFY_ATTEMPTS = 30; -const DELETE_VERIFY_DELAY_MS = 2_000; -const WORKSPACE_MOUNT_PATH = "/workspace"; - -interface SnapshotUpgradeInput { - adoptSandboxId: (sandboxId: string) => void; - client: DaytonaClient; - ctx: DurableObjectState; - env: ProjectSandboxEnv; - killProcesses: () => Promise; - provisioning: ProjectSandboxProvisioning; - sandboxName: string; - toUpstreamError: (error: unknown, fallback: string) => APIError; -} - -export class ProjectSandboxSnapshotUpgrade { - public constructor(private readonly input: SnapshotUpgradeInput) {} - - public async advance(releaseSha: string): Promise { - if (!SNAPSHOT_RELEASE_SHA_PATTERN.test(releaseSha)) { - throw snapshotInvariant("Snapshot upgrade release identity is invalid."); - } - try { - return await this.advanceExclusive(releaseSha); - } catch (error) { - throw this.input.toUpstreamError(error, "Daytona snapshot reconciliation failed."); - } - } - - private async advanceExclusive(releaseSha: string): Promise { - let state = await this.loadState(); - if (state?.phase === "completed" && state.releaseSha === releaseSha) { - this.assertCurrentContract(state, releaseSha); - return this.completeAndClear(state); - } - if (state?.phase === "completed") { - await this.input.ctx.storage.delete(SNAPSHOT_UPGRADE_STATE_KEY); - state = null; - } - state ??= await this.initializeState(releaseSha); - if (!state) { - return this.currentOrAbsentResult(); - } - this.assertCurrentContract(state, releaseSha); - for (;;) { - const next = await this.advancePhase(state); - if (next === null) { - return upgradingResult(state); - } - state = next; - if (state.phase === "completed") { - return this.completeAndClear(state); - } - } - } - - private async completeAndClear( - state: SnapshotUpgradeState, - ): Promise { - const result = completedResult(state); - await this.input.ctx.storage.delete(SNAPSHOT_UPGRADE_STATE_KEY); - if ((await this.input.ctx.storage.get(SNAPSHOT_UPGRADE_STATE_KEY)) !== undefined) { - throw snapshotInvariant("Completed snapshot upgrade state could not be removed."); - } - return result; - } - - private async initializeState(releaseSha: string): Promise { - const source = await this.input.provisioning.findExisting(this.input.client); - if (!source || isDestroyed(source)) { - return null; - } - if (this.input.provisioning.isDesired(source)) { - return null; - } - const volume = await this.input.provisioning.ensureWorkspaceVolume(this.input.client); - const upgradeId = await upgradeIdentity( - this.input.sandboxName, - source.id, - volume.id, - this.target, - ); - const state = SnapshotUpgradeStateSchema.parse({ - archiveDigest: null, - archiveSize: null, - candidateId: null, - chunkCount: null, - needsTransfer: - source.labels["workspaceVolumeId"] !== volume.id || - source.labels["workspaceVolumeName"] !== volume.name, - nextChunk: 0, - phase: "claimed", - releaseSha, - sandboxName: this.input.sandboxName, - sourceId: source.id, - sourceSnapshot: source.snapshot, - targetSnapshot: this.target, - treeDigest: null, - upgradeId, - volumeId: volume.id, - volumeName: volume.name, - }); - await this.storeState(state); - return state; - } - - private async currentOrAbsentResult(): Promise { - const current = await this.input.provisioning.findExisting(this.input.client); - if (!current || isDestroyed(current)) { - return snapshotResult({ - sourceSnapshot: null, - status: "absent", - targetSnapshot: this.target, - }); - } - if (!this.input.provisioning.isDesired(current)) { - throw snapshotInvariant("Snapshot upgrade state is absent for a noncurrent sandbox."); - } - return snapshotResult({ - sourceSnapshot: current.snapshot, - status: "current", - targetSnapshot: this.target, - }); - } - - private async advancePhase(state: SnapshotUpgradeState): Promise { - switch (state.phase) { - case "claimed": - return this.prepareSource(state); - case "source-prepared": - return this.createCandidate(state); - case "candidate-created": - return this.verifyCandidate(state); - case "candidate-verified": - return this.retireSource(state); - case "source-retired": - return this.promoteCandidate(state); - case "candidate-promoted": - return this.switchDurableIdentity(state); - case "switched": - return this.deleteSource(state); - case "completed": - return state; - } - } - - private async prepareSource(state: SnapshotUpgradeState): Promise { - const source = await this.requireSource(state); - await this.ensureStarted(source, "source"); - await this.input.killProcesses(); - const evidence = state.needsTransfer - ? await this.executeJson( - source.id, - prepareWorkspaceArchiveCommand(state.upgradeId), - ArchiveEvidenceSchema, - ) - : await this.executeJson(source.id, digestWorkspaceCommand(), DigestEvidenceSchema); - const next = SnapshotUpgradeStateSchema.parse({ - ...state, - archiveDigest: "archiveDigest" in evidence ? evidence.archiveDigest : null, - archiveSize: "archiveSize" in evidence ? evidence.archiveSize : null, - chunkCount: "chunkCount" in evidence ? evidence.chunkCount : null, - nextChunk: 0, - phase: "source-prepared", - treeDigest: evidence.treeDigest, - }); - await this.storeState(next); - return next; - } - - private async createCandidate(state: SnapshotUpgradeState): Promise { - const candidate = - (await this.findCandidate(state)) ?? (await this.createCandidateSandbox(state)); - this.assertCandidate(candidate, state); - await this.ensureStarted(candidate, "candidate"); - const next = SnapshotUpgradeStateSchema.parse({ - ...state, - candidateId: candidate.id, - phase: "candidate-created", - }); - await this.storeState(next); - return next; - } - - private async createCandidateSandbox(state: SnapshotUpgradeState): Promise { - try { - return await this.input.client.createSandbox({ - autoArchiveInterval: AUTO_ARCHIVE_MIN, - autoDeleteInterval: NEVER_AUTO_DELETE, - autoStopInterval: DEFAULT_IDLE_STOP_MIN, - labels: candidateSandboxLabels(candidateLabelInput(state)), - name: candidateName(state), - snapshot: state.targetSnapshot, - target: this.input.env.DAYTONA_TARGET, - user: "node", - volumes: [ - { - mountPath: WORKSPACE_MOUNT_PATH, - subpath: this.input.sandboxName, - volumeId: state.volumeId, - }, - ], - }); - } catch (error) { - if (error instanceof DaytonaApiError && error.status === 409) { - const existing = await this.findCandidate(state); - if (existing) return existing; - } - throw error; - } - } - - private async findCandidate(state: SnapshotUpgradeState): Promise { - const matches = ( - await this.input.client.listSandboxesByLabels({ - app: "cheatcode", - role: "candidate", - sandboxOwner: state.sandboxName, - upgradeId: state.upgradeId, - }) - ).filter((sandbox) => !isDestroyed(sandbox)); - if (matches.length > 1) { - throw snapshotInvariant("Multiple live Daytona snapshot candidates were found."); - } - const listed = matches[0]; - if (!listed) return null; - const candidate = await this.input.client.getSandbox(listed.id); - if (!candidate || isDestroyed(candidate)) return null; - this.assertCandidate(candidate, state); - return candidate; - } - - private async verifyCandidate(state: SnapshotUpgradeState): Promise { - const candidate = await this.requireCandidate(state); - await this.ensureStarted(candidate, "candidate"); - if (!state.needsTransfer) { - return this.verifyMountedWorkspace(state, candidate); - } - const transfer = await this.transferNextChunk(state, candidate); - if (!transfer) return null; - if (transfer.nextChunk < requireNumber(state.chunkCount, "chunk count")) return null; - return this.restoreTransferredWorkspace(transfer, candidate); - } - - private async transferNextChunk( - state: SnapshotUpgradeState, - candidate: DaytonaSandbox, - ): Promise { - const chunkCount = requireNumber(state.chunkCount, "chunk count"); - if (state.nextChunk >= chunkCount) return state; - const source = await this.requireSource(state); - await this.ensureStarted(source, "source"); - const sourcePath = transferChunkPath(state.upgradeId, state.nextChunk); - let bytes: Uint8Array; - try { - bytes = await this.input.client.downloadFile( - state.sourceId, - sourcePath, - SNAPSHOT_TRANSFER_CHUNK_BYTES, - ); - } catch (error) { - if (error instanceof DaytonaApiError && error.status === 404) { - await this.resetPreparedSource(state); - return null; - } - throw error; - } - const digest = await sha256Hex(bytes); - await this.input.client.createFolder(candidate.id, transferChunksPath(state.upgradeId), "700"); - await this.input.client.uploadFile(candidate.id, sourcePath, bytes); - await this.verifyTransferredChunk(candidate.id, sourcePath, bytes.byteLength, digest); - const next = SnapshotUpgradeStateSchema.parse({ ...state, nextChunk: state.nextChunk + 1 }); - await this.storeState(next); - return next; - } - - private async verifyTransferredChunk( - candidateId: string, - path: string, - size: number, - digest: string, - ): Promise { - const result = await this.input.client.execute(candidateId, { - command: verifyTransferChunkCommand({ digest, path, size }), - timeout: SNAPSHOT_EXEC_TIMEOUT_SECONDS, - }); - const evidence = ChunkEvidenceSchema.safeParse(parseJson(result.result)); - if (result.exitCode === 0 && evidence.success && evidence.data.verified) return; - if (result.exitCode === 4 && evidence.success && !evidence.data.verified) { - throw new APIError(502, "upstream_sandbox_failed", "Daytona transfer chunk was corrupted", { - retriable: true, - }); - } - throw snapshotInvariant("Daytona transfer chunk verification failed.", result.result); - } - - private async restoreTransferredWorkspace( - state: SnapshotUpgradeState, - candidate: DaytonaSandbox, - ): Promise { - const result = await this.input.client.execute(candidate.id, { - command: verifyWorkspaceArchiveCommand({ - archiveDigest: requireString(state.archiveDigest, "archive digest"), - archiveSize: requireNumber(state.archiveSize, "archive size"), - chunkCount: requireNumber(state.chunkCount, "chunk count"), - treeDigest: requireString(state.treeDigest, "tree digest"), - upgradeId: state.upgradeId, - }), - timeout: SNAPSHOT_EXEC_TIMEOUT_SECONDS, - }); - if (result.exitCode === 3 && RetryTransferSchema.safeParse(parseJson(result.result)).success) { - const reset = SnapshotUpgradeStateSchema.parse({ ...state, nextChunk: 0 }); - await this.storeState(reset); - return null; - } - const evidence = parseExecutedResult(result, ArchiveVerificationSchema, "workspace restore"); - if ( - evidence.archiveDigest !== state.archiveDigest || - evidence.treeDigest !== state.treeDigest - ) { - throw snapshotInvariant("Candidate workspace digest does not match the source."); - } - return this.markCandidateVerified(state); - } - - private async verifyMountedWorkspace( - state: SnapshotUpgradeState, - candidate: DaytonaSandbox, - ): Promise { - const evidence = await this.executeJson( - candidate.id, - digestWorkspaceCommand(), - DigestEvidenceSchema, - ); - if (evidence.treeDigest !== state.treeDigest) { - throw snapshotInvariant("Mounted workspace changed while the release gate was closed."); - } - return this.markCandidateVerified(state); - } - - private async markCandidateVerified(state: SnapshotUpgradeState): Promise { - const next = SnapshotUpgradeStateSchema.parse({ ...state, phase: "candidate-verified" }); - await this.storeState(next); - return next; - } - - private async retireSource(state: SnapshotUpgradeState): Promise { - const source = await this.input.client.getSandbox(state.sourceId); - if (source && !isDestroyed(source)) { - const expected = retiredSandboxLabels({ - sandbox: source, - sandboxName: this.input.sandboxName, - upgradeId: state.upgradeId, - }); - if (!labelsEqual(source.labels, expected)) { - this.input.provisioning.assertIdentity(source); - await this.input.client.replaceSandboxLabels(source.id, expected); - await this.assertLabels(source.id, expected, "retired source"); - } - } - const next = SnapshotUpgradeStateSchema.parse({ ...state, phase: "source-retired" }); - await this.storeState(next); - return next; - } - - private async promoteCandidate(state: SnapshotUpgradeState): Promise { - const candidateId = requireString(state.candidateId, "candidate id"); - const candidate = await this.input.client.getSandbox(candidateId); - if (!candidate || isDestroyed(candidate)) { - throw snapshotInvariant("Snapshot upgrade candidate disappeared."); - } - const canonical = canonicalSandboxLabels({ - sandboxName: this.input.sandboxName, - snapshot: state.targetSnapshot, - volumeId: state.volumeId, - volumeName: state.volumeName, - }); - const liveCanonical = ( - await this.input.client.listSandboxesByLabels({ - app: "cheatcode", - sandboxId: this.input.sandboxName, - }) - ).filter((sandbox) => !isDestroyed(sandbox)); - if (liveCanonical.some((sandbox) => sandbox.id !== candidate.id)) { - throw snapshotInvariant("Another canonical Daytona sandbox appeared during promotion."); - } - const isAlreadyPromoted = isDesiredCanonicalSandbox(candidate, { - sandboxName: this.input.sandboxName, - snapshot: state.targetSnapshot, - volumeId: state.volumeId, - volumeName: state.volumeName, - }); - if (!isAlreadyPromoted) { - this.assertCandidate(candidate, state); - await this.input.client.replaceSandboxLabels(candidate.id, canonical); - await this.assertLabels(candidate.id, canonical, "promoted candidate"); - } - const promoted = await this.requireDesiredCandidate(state); - const next = SnapshotUpgradeStateSchema.parse({ - ...state, - candidateId: promoted.id, - phase: "candidate-promoted", - }); - await this.storeState(next); - return next; - } - - private async switchDurableIdentity(state: SnapshotUpgradeState): Promise { - const candidateId = requireString(state.candidateId, "candidate id"); - const next = SnapshotUpgradeStateSchema.parse({ ...state, phase: "switched" }); - await this.input.ctx.storage.transaction(async (transaction) => { - await transaction.put(DAYTONA_ID_KEY, candidateId); - await transaction.put(SNAPSHOT_UPGRADE_STATE_KEY, next); - }); - this.input.adoptSandboxId(candidateId); - return next; - } - - private async deleteSource(state: SnapshotUpgradeState): Promise { - const candidateId = requireString(state.candidateId, "candidate id"); - await this.input.client.deleteFilePath(candidateId, transferBasePath(state.upgradeId), true); - const source = await this.input.client.getSandbox(state.sourceId); - if (source && !isDestroyed(source)) { - await this.input.client.deleteFilePath(source.id, transferBasePath(state.upgradeId), true); - await this.input.client.deleteSandbox(source.id); - await this.waitForDeletion(source.id); - } - const next = SnapshotUpgradeStateSchema.parse({ ...state, phase: "completed" }); - await this.storeState(next); - return next; - } - - private async waitForDeletion(sandboxId: string): Promise { - for (let attempt = 0; attempt < DELETE_VERIFY_ATTEMPTS; attempt += 1) { - const current = await this.input.client.getSandbox(sandboxId); - if (!current || isDestroyed(current)) return; - await sleep(DELETE_VERIFY_DELAY_MS); - } - throw new APIError(504, "upstream_sandbox_failed", "Retired Daytona sandbox was not deleted", { - retriable: true, - }); - } - - private async resetPreparedSource(state: SnapshotUpgradeState): Promise { - const reset = SnapshotUpgradeStateSchema.parse({ - ...state, - archiveDigest: null, - archiveSize: null, - chunkCount: null, - nextChunk: 0, - phase: "claimed", - treeDigest: null, - }); - await this.storeState(reset); - } - - private async requireSource(state: SnapshotUpgradeState): Promise { - const source = await this.input.client.getSandbox(state.sourceId); - if (!source || isDestroyed(source)) { - throw snapshotInvariant("Source Daytona sandbox disappeared before promotion."); - } - this.input.provisioning.assertIdentity(source); - return source; - } - - private async requireCandidate(state: SnapshotUpgradeState): Promise { - const id = requireString(state.candidateId, "candidate id"); - const candidate = await this.input.client.getSandbox(id); - if (!candidate || isDestroyed(candidate)) { - throw snapshotInvariant("Snapshot upgrade candidate disappeared."); - } - this.assertCandidate(candidate, state); - return candidate; - } - - private async requireDesiredCandidate(state: SnapshotUpgradeState): Promise { - const id = requireString(state.candidateId, "candidate id"); - const candidate = await this.input.client.getSandbox(id); - if ( - !candidate || - isDestroyed(candidate) || - !isDesiredCanonicalSandbox(candidate, { - sandboxName: this.input.sandboxName, - snapshot: state.targetSnapshot, - volumeId: state.volumeId, - volumeName: state.volumeName, - }) - ) { - throw snapshotInvariant("Promoted Daytona sandbox identity did not converge."); - } - return candidate; - } - - private async ensureStarted(sandbox: DaytonaSandbox, label: string): Promise { - if (!(await this.input.provisioning.ensureStarted(this.input.client, sandbox))) { - throw snapshotInvariant(`Snapshot upgrade ${label} sandbox disappeared.`); - } - } - - private assertCandidate(candidate: DaytonaSandbox, state: SnapshotUpgradeState): void { - if (!isUpgradeCandidate(candidate, candidateLabelInput(state))) { - throw snapshotInvariant("Daytona snapshot candidate identity mismatch."); - } - } - - private async assertLabels( - id: string, - expected: Record, - label: string, - ): Promise { - const current = await this.input.client.getSandbox(id); - if (!current || isDestroyed(current) || !labelsEqual(current.labels, expected)) { - throw snapshotInvariant(`Daytona ${label} labels did not converge.`); - } - } - - private async executeJson( - sandboxId: string, - command: string, - schema: T, - ): Promise> { - const result = await this.input.client.execute(sandboxId, { - command, - timeout: SNAPSHOT_EXEC_TIMEOUT_SECONDS, - }); - return parseExecutedResult(result, schema, "snapshot evidence"); - } - - private assertCurrentContract(state: SnapshotUpgradeState, releaseSha: string): void { - if ( - state.releaseSha !== releaseSha || - state.sandboxName !== this.input.sandboxName || - state.targetSnapshot !== this.target || - state.volumeName !== this.input.env.DAYTONA_WORKSPACE_VOLUME - ) { - throw snapshotInvariant("Pending snapshot upgrade belongs to another release contract."); - } - } - - private async loadState(): Promise { - const value = await this.input.ctx.storage.get(SNAPSHOT_UPGRADE_STATE_KEY); - return value === undefined ? null : SnapshotUpgradeStateSchema.parse(value); - } - - private storeState(state: SnapshotUpgradeState): Promise { - return this.input.ctx.storage.put( - SNAPSHOT_UPGRADE_STATE_KEY, - SnapshotUpgradeStateSchema.parse(state), - ); - } - - private get target(): string { - return this.input.env.DAYTONA_SANDBOX_SNAPSHOT; - } -} - -function parseExecutedResult( - result: { exitCode: number; result?: string | null | undefined }, - schema: T, - label: string, -): z.infer { - if (result.exitCode !== 0) { - throw snapshotInvariant(`Daytona ${label} command failed.`, result.result); - } - const parsed = schema.safeParse(parseJson(result.result)); - if (!parsed.success) { - throw snapshotInvariant(`Daytona ${label} was invalid.`); - } - return parsed.data; -} - -function snapshotResult(input: { - sourceSnapshot: string | null; - status: "absent" | "current"; - targetSnapshot: string; -}): SandboxSnapshotReconciliation { - return { - complete: true, - sourceSnapshot: input.sourceSnapshot, - status: input.status, - targetSnapshot: input.targetSnapshot, - upgradeId: null, - workspaceDigest: null, - }; -} - -function upgradingResult(state: SnapshotUpgradeState): SandboxSnapshotReconciliation { - return { - complete: false, - sourceSnapshot: state.sourceSnapshot, - status: "upgrading", - targetSnapshot: state.targetSnapshot, - upgradeId: state.upgradeId, - workspaceDigest: state.treeDigest, - }; -} - -function completedResult(state: SnapshotUpgradeState): SandboxSnapshotReconciliation { - return { - complete: true, - sourceSnapshot: state.sourceSnapshot, - status: "upgraded", - targetSnapshot: state.targetSnapshot, - upgradeId: state.upgradeId, - workspaceDigest: requireString(state.treeDigest, "tree digest"), - }; -} - -function candidateLabelInput(state: SnapshotUpgradeState) { - return { - sandboxName: state.sandboxName, - snapshot: state.targetSnapshot, - upgradeId: state.upgradeId, - volumeId: state.volumeId, - volumeName: state.volumeName, - }; -} - -function candidateName(state: SnapshotUpgradeState): string { - return `cheatcode-upgrade-${state.upgradeId}`; -} - -function transferBasePath(upgradeId: string): string { - return `/tmp/cheatcode-snapshot-upgrade/${upgradeId}`; -} - -function transferChunksPath(upgradeId: string): string { - return `${transferBasePath(upgradeId)}/chunks`; -} - -function transferChunkPath(upgradeId: string, index: number): string { - return `${transferChunksPath(upgradeId)}/chunk-${String(index).padStart(12, "0")}`; -} - -async function upgradeIdentity( - sandboxName: string, - sourceId: string, - volumeId: string, - targetSnapshot: string, -): Promise { - const digest = await sha256Hex(JSON.stringify([sandboxName, sourceId, targetSnapshot, volumeId])); - return digest.slice(0, 32); -} - -async function sha256Hex(value: string | Uint8Array): Promise { - const source = typeof value === "string" ? new TextEncoder().encode(value) : value; - const bytes = new Uint8Array(source.byteLength); - bytes.set(source); - const digest = await crypto.subtle.digest("SHA-256", bytes.buffer); - return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join(""); -} - -function labelsEqual(actual: Record, expected: Record): boolean { - const actualEntries = Object.entries(actual).sort(([left], [right]) => left.localeCompare(right)); - const expectedEntries = Object.entries(expected).sort(([left], [right]) => - left.localeCompare(right), - ); - return JSON.stringify(actualEntries) === JSON.stringify(expectedEntries); -} - -function parseJson(value: string | null | undefined): unknown { - try { - return JSON.parse(value ?? "") as unknown; - } catch { - return null; - } -} - -function requireString(value: string | null, label: string): string { - if (!value) throw snapshotInvariant(`Snapshot upgrade ${label} is absent.`); - return value; -} - -function requireNumber(value: number | null, label: string): number { - if (value === null) throw snapshotInvariant(`Snapshot upgrade ${label} is absent.`); - return value; -} - -function snapshotInvariant(message: string, output?: string | null): APIError { - return new APIError(409, "conflict_state_invalid", message, { - ...(output ? { details: { output: output.slice(-1_000) } } : {}), - retriable: false, - }); -} diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-workspace-state.ts b/apps/agent-worker/src/durable-objects/project-sandbox-workspace-state.ts index 65cb1b72..2b00d9d8 100644 --- a/apps/agent-worker/src/durable-objects/project-sandbox-workspace-state.ts +++ b/apps/agent-worker/src/durable-objects/project-sandbox-workspace-state.ts @@ -1,6 +1,5 @@ import { assertExactSqliteSchema, - assertSqliteRowCountPreserved, type ExpectedSqliteObject, setCurrentSqliteStorageVersion, } from "@cheatcode/durable-storage"; @@ -45,20 +44,12 @@ const PROJECT_SANDBOX_STORAGE_SCHEMA: readonly ExpectedSqliteObject[] = [ ]; export function initializeProjectSandboxStorage(ctx: DurableObjectState): void { - createWorkspaceStateTables(ctx); - setCurrentSqliteStorageVersion(ctx); - assertProjectSandboxStorage(ctx); -} - -/** Rebuilds workspace fences exactly while every public sandbox operation is closed. */ -export function reconcileProjectSandboxStorage(ctx: DurableObjectState): void { - createWorkspaceStateTables(ctx); - ctx.storage.transactionSync(() => rebuildWorkspaceStateTables(ctx)); + ctx.storage.sql.exec(CREATE_WORKSPACE_TOMBSTONE_TABLE); setCurrentSqliteStorageVersion(ctx); assertProjectSandboxStorage(ctx); } -export function assertProjectSandboxStorage(ctx: DurableObjectState): void { +function assertProjectSandboxStorage(ctx: DurableObjectState): void { assertExactSqliteSchema(ctx, PROJECT_SANDBOX_STORAGE_SCHEMA); } @@ -85,7 +76,6 @@ export function openProjectSandboxWorkspaceState( * Project tombstones intentionally outlive cleanup while the owning account is active. */ export class ProjectSandboxWorkspaceState { - private activeTransitionLeaseId: string | null = null; private readonly activeCounts = new Map(); private activeSharedMutationCount = 0; private activeUnscopedOperationCount = 0; @@ -116,8 +106,7 @@ export class ProjectSandboxWorkspaceState { if ( this.cleanupInProgressCount > 0 || this.pendingDeletionCount > 0 || - this.activeSharedMutationCount > 0 || - this.activeTransitionLeaseId + this.activeSharedMutationCount > 0 ) { throw cleanupInProgressError(); } @@ -144,8 +133,7 @@ export class ProjectSandboxWorkspaceState { if ( this.cleanupInProgressCount > 0 || this.pendingDeletionCount > 0 || - this.activeSharedMutationCount > 0 || - this.activeTransitionLeaseId + this.activeSharedMutationCount > 0 ) { throw cleanupInProgressError(); } @@ -156,8 +144,7 @@ export class ProjectSandboxWorkspaceState { if ( this.cleanupInProgressCount > 0 || this.pendingDeletionCount > 0 || - this.activeSharedMutationCount > 0 || - this.activeTransitionLeaseId + this.activeSharedMutationCount > 0 ) { throw cleanupInProgressError(); } @@ -178,34 +165,7 @@ export class ProjectSandboxWorkspaceState { }; } - public acquireTransitionMutation(transitionId: string): () => void { - if ( - this.cleanupInProgressCount > 0 || - this.pendingDeletionCount > 0 || - this.activeSharedMutationCount > 0 || - this.activeTransitionLeaseId !== null - ) { - throw cleanupInProgressError(); - } - this.activeTransitionLeaseId = transitionId; - const releaseMutation = this.acquireSharedMutationLease(); - let isReleased = false; - return () => { - if (isReleased) { - return; - } - isReleased = true; - releaseMutation(); - if (this.activeTransitionLeaseId === transitionId) { - this.activeTransitionLeaseId = null; - } - }; - } - - public assertOperationAllowed(transitionId?: string, allowWorkspaceCleanup = false): void { - if (this.activeTransitionLeaseId !== null && this.activeTransitionLeaseId !== transitionId) { - throw sharedMutationInProgressError(); - } + public assertOperationAllowed(allowWorkspaceCleanup = false): void { if ( !allowWorkspaceCleanup && (this.cleanupInProgressCount > 0 || this.pendingDeletionCount > 0) @@ -214,12 +174,6 @@ export class ProjectSandboxWorkspaceState { } } - public assertAccountDeletionAllowed(): void { - if (this.activeTransitionLeaseId) { - throw sharedMutationInProgressError(); - } - } - private acquireSharedMutationLease(): () => void { this.activeSharedMutationCount += 1; let isReleased = false; @@ -242,9 +196,6 @@ export class ProjectSandboxWorkspaceState { input: ParsedProjectCleanupWorkspaceInput, cleanup: () => Promise, ): Promise { - if (this.activeTransitionLeaseId) { - throw sharedMutationInProgressError(); - } if (this.claimDeletion(input)) { return Promise.resolve(); } @@ -399,43 +350,6 @@ export class ProjectSandboxWorkspaceState { } } -function createWorkspaceStateTables(ctx: DurableObjectState): void { - ctx.storage.sql.exec(CREATE_WORKSPACE_TOMBSTONE_TABLE); -} - -function rebuildWorkspaceStateTables(ctx: DurableObjectState): void { - ctx.storage.sql.exec("DROP TABLE IF EXISTS project_workspace_tombstone_reconcile_source"); - ctx.storage.sql.exec( - "ALTER TABLE project_workspace_tombstone RENAME TO project_workspace_tombstone_reconcile_source", - ); - ctx.storage.sql.exec(canonicalCreateSql(CREATE_WORKSPACE_TOMBSTONE_TABLE)); - copyWorkspaceStateRows(ctx); - ctx.storage.sql.exec("DROP TABLE project_workspace_tombstone_reconcile_source"); - // These are release-control evidence only; project deletion fences live in the tombstone table. - ctx.storage.sql.exec("DROP TABLE IF EXISTS project_workspace_transition"); - ctx.storage.sql.exec("DROP TABLE IF EXISTS project_workspace_retired_slug"); - ctx.storage.sql.exec("DROP TABLE IF EXISTS project_workspace_transition_reconcile_source"); - ctx.storage.sql.exec("DROP TABLE IF EXISTS project_workspace_retired_slug_reconcile_source"); -} - -function copyWorkspaceStateRows(ctx: DurableObjectState): void { - ctx.storage.sql.exec( - `INSERT INTO project_workspace_tombstone - (workspace_slug, project_id, deleted_at, completed_at) - SELECT workspace_slug, project_id, deleted_at, completed_at - FROM project_workspace_tombstone_reconcile_source`, - ); - assertSqliteRowCountPreserved( - ctx, - "project_workspace_tombstone_reconcile_source", - "project_workspace_tombstone", - ); -} - -function canonicalCreateSql(sql: string): string { - return sql.replace("CREATE TABLE IF NOT EXISTS", "CREATE TABLE"); -} - function parseExistingClaim( rows: Record[], input: ParsedProjectCleanupWorkspaceInput, @@ -460,12 +374,6 @@ function cleanupInProgressError(): APIError { }); } -function sharedMutationInProgressError(): APIError { - return new APIError(409, "conflict_state_invalid", "Workspace maintenance is in progress", { - retriable: true, - }); -} - function workspaceIdentityConflictError(input: ParsedProjectCleanupWorkspaceInput): APIError { return new APIError(409, "conflict_state_invalid", "Project workspace identity mismatch", { details: { projectId: input.projectId, workspaceSlug: input.workspaceSlug }, diff --git a/apps/agent-worker/src/durable-objects/project-sandbox-workspace-transition.ts b/apps/agent-worker/src/durable-objects/project-sandbox-workspace-transition.ts deleted file mode 100644 index d30a502b..00000000 --- a/apps/agent-worker/src/durable-objects/project-sandbox-workspace-transition.ts +++ /dev/null @@ -1,634 +0,0 @@ -import { APIError } from "@cheatcode/observability"; -import { - CanonicalProjectWorkspaceSlugSchema, - canonicalWorkspaceDigest, - type InternalWorkspaceReconciliationBody, - InternalWorkspaceReconciliationBodySchema, - type InternalWorkspaceReconciliationResponse, - type SandboxSnapshotReconciliation, - type WorkspaceTransitionProject, -} from "@cheatcode/types"; -import { z } from "zod"; -import { WORKSPACE_DIR } from "./project-sandbox-content-support"; -import { - APP_PREVIEW_SLOT_PREFIX, - PORT_ALLOC_KEY, - PortAllocationSchema, - PROC_PREFIX, - PROCESS_PORT_ALLOC_KEY, - ProcessPortReservationsSchema, - type ProcessRecord, - ProcessRecordSchema, - pruneExpiredProcessPortReservations, - shellQuote, - timeoutSeconds, -} from "./project-sandbox-process-support"; -import { ProjectSandboxProcesses } from "./project-sandbox-processes"; -import { ProjectWorkspaceSlugSchema, workspaceSlugFromPath } from "./project-sandbox-runtime"; -import { ProjectSandboxSnapshotUpgrade } from "./project-sandbox-snapshot-upgrade"; - -const WorkspaceTransitionScriptResultSchema = z - .object({ present: z.array(CanonicalProjectWorkspaceSlugSchema) }) - .strict(); -const WORKSPACE_TRANSITION_STATE_KEY = "workspace_transition_reconciliation"; -const WorkspaceTransitionStateSchema = z - .object({ - canonicalDigest: z.string().regex(/^[0-9a-f]{64}$/u), - presentSlugs: z.array(CanonicalProjectWorkspaceSlugSchema).max(10_000), - releaseSha: z.string().regex(/^[0-9a-f]{40}$/u), - }) - .strict() - .superRefine((state, context) => { - if ( - state.presentSlugs.some((workspaceSlug, index) => { - const previous = state.presentSlugs[index - 1]; - return previous !== undefined && previous >= workspaceSlug; - }) - ) { - context.addIssue({ - code: "custom", - message: "Workspace presence evidence must be sorted and unique.", - }); - } - }); - -type WorkspaceTransitionState = z.infer; - -interface WorkspaceTransitionIdentity { - canonicalDigest: string; -} - -interface ReconciliationPlan { - affectedProcessNames: Set; - changedWorkspaceSlugs: Set; - staleWorkspaceSlugs: Set; -} - -export abstract class ProjectSandboxWorkspaceTransition extends ProjectSandboxProcesses { - public async prepareWorkspaceTransition( - input: InternalWorkspaceReconciliationBody, - ): Promise { - const parsed = parsePhase(input, "prepare"); - const identity = await transitionIdentity(parsed); - const existing = await this.loadWorkspaceTransitionState(); - if (existing) { - this.assertWorkspaceTransitionIdentity(existing, identity); - await this.verifyPreparedWorkspaceTransition(parsed.projects, existing.presentSlugs); - await this.verifyStoredWorkspaceState(parsed.projects); - await this.adoptWorkspaceTransitionRelease(existing, parsed.releaseSha); - return transitionResult( - parsed, - identity, - "prepared", - pendingSnapshot(this.env.DAYTONA_SANDBOX_SNAPSHOT), - ); - } - const records = await this.loadProcessRecords(); - const allocation = PortAllocationSchema.parse( - (await this.ctx.storage.get(PORT_ALLOC_KEY)) ?? {}, - ); - ProcessPortReservationsSchema.parse((await this.ctx.storage.get(PROCESS_PORT_ALLOC_KEY)) ?? {}); - assertProjectPortTransitionSafe(parsed.projects, allocation.ports); - const plan = reconciliationPlan(parsed.projects, records, allocation.ports); - const id = await this.ensureExistingSandboxStarted(); - await this.terminateTransitionProcesses(id, records, plan); - const present = id ? await this.runWorkspaceTransitionScript(id, parsed.projects) : []; - const counts = await this.reconcileStoredWorkspaceState(parsed.projects, plan); - await this.verifyStoredWorkspaceState(parsed.projects); - await this.ctx.storage.put( - WORKSPACE_TRANSITION_STATE_KEY, - WorkspaceTransitionStateSchema.parse({ - canonicalDigest: identity.canonicalDigest, - presentSlugs: [...present].sort(), - releaseSha: parsed.releaseSha, - }), - ); - return transitionResult( - parsed, - identity, - "prepared", - pendingSnapshot(this.env.DAYTONA_SANDBOX_SNAPSHOT), - counts, - ); - } - - public async finalizeWorkspaceTransition( - input: InternalWorkspaceReconciliationBody, - ): Promise { - const parsed = parsePhase(input, "finalize"); - const identity = await transitionIdentity(parsed); - const state = await this.loadWorkspaceTransitionState(); - if (state) { - this.assertWorkspaceTransitionState(state, parsed, identity); - await this.verifyPreparedWorkspaceTransition(parsed.projects, state.presentSlugs); - } else { - assertCanonicalFinalizationInput(parsed.projects); - const id = await this.ensureExistingSandboxStarted(); - if (id) { - await this.verifyWorkspaceTransitionScript(id, parsed.projects); - } - } - await this.verifyStoredWorkspaceState(parsed.projects); - const snapshot = await this.advanceSnapshotUpgrade(parsed.releaseSha); - if (snapshot.complete) { - await this.clearWorkspaceTransitionState(); - } - return transitionResult(parsed, identity, "completed", snapshot); - } - - private async verifyPreparedWorkspaceTransition( - projects: WorkspaceTransitionProject[], - expectedPresent: string[], - ): Promise { - const id = await this.ensureExistingSandboxStarted(); - if (id) { - await this.verifyWorkspaceTransitionScript(id, projects, expectedPresent); - return; - } - if (expectedPresent.length > 0) { - throw transitionError("Prepared project folders no longer have a Daytona sandbox."); - } - } - - private async loadWorkspaceTransitionState(): Promise { - const value = await this.ctx.storage.get(WORKSPACE_TRANSITION_STATE_KEY); - return value === undefined ? null : WorkspaceTransitionStateSchema.parse(value); - } - - private async clearWorkspaceTransitionState(): Promise { - await this.ctx.storage.delete(WORKSPACE_TRANSITION_STATE_KEY); - if ((await this.ctx.storage.get(WORKSPACE_TRANSITION_STATE_KEY)) !== undefined) { - throw transitionError("Completed workspace transition state could not be removed."); - } - } - - private async adoptWorkspaceTransitionRelease( - state: WorkspaceTransitionState, - releaseSha: string, - ): Promise { - if (state.releaseSha === releaseSha) { - return; - } - await this.ctx.storage.put( - WORKSPACE_TRANSITION_STATE_KEY, - WorkspaceTransitionStateSchema.parse({ ...state, releaseSha }), - ); - } - - private assertWorkspaceTransitionIdentity( - state: WorkspaceTransitionState, - identity: WorkspaceTransitionIdentity, - ): void { - if (state.canonicalDigest !== identity.canonicalDigest) { - throw transitionError("Pending workspace transition belongs to another workspace contract."); - } - } - - private assertWorkspaceTransitionState( - state: WorkspaceTransitionState, - input: InternalWorkspaceReconciliationBody, - identity: WorkspaceTransitionIdentity, - ): void { - if ( - state.releaseSha !== input.releaseSha || - state.canonicalDigest !== identity.canonicalDigest - ) { - throw transitionError("Pending workspace transition belongs to another release contract."); - } - } - - private async advanceSnapshotUpgrade(releaseSha: string): Promise { - const client = await this.ensureClient(); - return new ProjectSandboxSnapshotUpgrade({ - adoptSandboxId: (sandboxId) => this.adoptDaytonaId(sandboxId), - client, - ctx: this.ctx, - env: this.env, - killProcesses: () => super.killAllProcesses(), - provisioning: this.sandboxProvisioning(), - sandboxName: this.sandboxName(), - toUpstreamError: (error, fallback) => this.toUpstreamError(error, fallback), - }).advance(releaseSha); - } - - private async loadProcessRecords(): Promise> { - const stored = await this.ctx.storage.list({ prefix: PROC_PREFIX }); - const records = new Map(); - for (const [key, value] of stored) { - const parsed = ProcessRecordSchema.safeParse(value); - if (!parsed.success) { - throw transitionError("Stored sandbox process state is invalid."); - } - records.set(key.slice(PROC_PREFIX.length), parsed.data); - } - return records; - } - - private async terminateTransitionProcesses( - id: string | null, - records: Map, - plan: ReconciliationPlan, - ): Promise { - if (id) { - for (const workspaceSlug of [...plan.staleWorkspaceSlugs].sort()) { - await this.terminateUntrackedWorkspaceProcesses(id, workspaceSlug); - } - } - for (const processName of [...plan.affectedProcessNames].sort()) { - if (id && records.has(processName)) { - await this.deleteProcessRecord(id, processName); - } else { - await this.ctx.storage.delete(`${PROC_PREFIX}${processName}`); - } - } - } - - private async reconcileStoredWorkspaceState( - projects: WorkspaceTransitionProject[], - plan: ReconciliationPlan, - ): Promise<{ - processPortReservationsRemoved: number; - processRecordsRemoved: number; - projectPortsRemoved: number; - }> { - const canonical = canonicalWorkspaceSet(projects); - const canonicalForCurrent = new Map( - projects.map((project) => [project.currentWorkspaceSlug, project.canonicalWorkspaceSlug]), - ); - return this.ctx.storage.transaction(async (transaction) => { - const storedAllocation = await transaction.get(PORT_ALLOC_KEY); - const allocation = PortAllocationSchema.parse(storedAllocation ?? {}); - const { ports, removed: projectPortsRemoved } = canonicalProjectPorts( - allocation.ports, - canonical, - canonicalForCurrent, - ); - if (storedAllocation !== undefined || Object.keys(ports).length > 0) { - await transaction.put(PORT_ALLOC_KEY, { ...allocation, ports }); - } - - const records = await transaction.list({ prefix: PROC_PREFIX }); - const storedReservations = await transaction.get(PROCESS_PORT_ALLOC_KEY); - const before = ProcessPortReservationsSchema.parse(storedReservations ?? {}); - const pruned = pruneExpiredProcessPortReservations(before, records, Date.now()); - const reservations = canonicalProcessPortReservations( - pruned, - canonical, - plan.affectedProcessNames, - ); - if (storedReservations !== undefined || Object.keys(reservations).length > 0) { - await transaction.put(PROCESS_PORT_ALLOC_KEY, reservations); - } - return { - processPortReservationsRemoved: - Object.keys(before).length - Object.keys(reservations).length, - processRecordsRemoved: plan.affectedProcessNames.size, - projectPortsRemoved, - }; - }); - } - - private async verifyStoredWorkspaceState(projects: WorkspaceTransitionProject[]): Promise { - const canonical = canonicalWorkspaceSet(projects); - const records = await this.loadProcessRecords(); - for (const [name, record] of records) { - if (processNeedsRemoval(name, record, canonical, new Set())) { - throw transitionError("Noncanonical sandbox process state remains after reconciliation."); - } - } - const allocation = PortAllocationSchema.parse( - (await this.ctx.storage.get(PORT_ALLOC_KEY)) ?? {}, - ); - if (Object.keys(allocation.ports).some((workspaceSlug) => !canonical.has(workspaceSlug))) { - throw transitionError("Noncanonical project port state remains after reconciliation."); - } - const reservations = ProcessPortReservationsSchema.parse( - (await this.ctx.storage.get(PROCESS_PORT_ALLOC_KEY)) ?? {}, - ); - if ( - Object.keys(reservations).some((processId) => { - const slot = previewSlotWorkspaceSlug(processId); - return slot === "invalid" || (slot !== null && !canonical.has(slot)); - }) - ) { - throw transitionError("Noncanonical process port state remains after reconciliation."); - } - } - - private async runWorkspaceTransitionScript( - id: string, - projects: WorkspaceTransitionProject[], - ): Promise { - return this.executeWorkspaceTransitionScript(id, { mode: "prepare", projects }); - } - - private async verifyWorkspaceTransitionScript( - id: string, - projects: WorkspaceTransitionProject[], - expectedPresent?: string[], - ): Promise { - const present = await this.executeWorkspaceTransitionScript(id, { mode: "verify", projects }); - if (expectedPresent) { - assertSameSlugs(present, expectedPresent); - } - } - - private async executeWorkspaceTransitionScript( - id: string, - payload: { - mode: "prepare" | "verify"; - projects: WorkspaceTransitionProject[]; - }, - ): Promise { - const encoded = btoa(JSON.stringify(payload)); - const result = await this.client().execute(id, { - command: `python3 -c ${shellQuote(WORKSPACE_TRANSITION_SCRIPT)} ${shellQuote(encoded)}`, - cwd: WORKSPACE_DIR, - timeout: timeoutSeconds(120_000), - }); - if (result.exitCode !== 0) { - throw transitionError("Project workspace folders could not be reconciled.", result.result); - } - const parsed = WorkspaceTransitionScriptResultSchema.safeParse(parseJson(result.result)); - if (!parsed.success) { - throw transitionError("Project workspace transition returned invalid evidence."); - } - return parsed.data.present; - } -} - -function reconciliationPlan( - projects: WorkspaceTransitionProject[], - records: Map, - projectPorts: Record, -): ReconciliationPlan { - const canonical = canonicalWorkspaceSet(projects); - const changedWorkspaceSlugs = new Set( - projects - .filter((project) => project.currentWorkspaceSlug !== project.canonicalWorkspaceSlug) - .flatMap((project) => [project.currentWorkspaceSlug, project.canonicalWorkspaceSlug]), - ); - const staleWorkspaceSlugs = new Set( - projects - .filter((project) => project.currentWorkspaceSlug !== project.canonicalWorkspaceSlug) - .flatMap((project) => [project.currentWorkspaceSlug, project.canonicalWorkspaceSlug]), - ); - for (const workspaceSlug of Object.keys(projectPorts)) { - if (!canonical.has(workspaceSlug)) { - const parsed = ProjectWorkspaceSlugSchema.safeParse(workspaceSlug); - if (parsed.success) { - staleWorkspaceSlugs.add(parsed.data); - } - } - } - const affectedProcessNames = new Set(); - for (const [name, record] of records) { - const scopes = processWorkspaceSlugs(name, record); - for (const scope of scopes) { - if (scope !== "invalid" && !canonical.has(scope)) { - staleWorkspaceSlugs.add(scope); - } - } - if (processNeedsRemoval(name, record, canonical, changedWorkspaceSlugs)) { - affectedProcessNames.add(name); - } - } - return { affectedProcessNames, changedWorkspaceSlugs, staleWorkspaceSlugs }; -} - -function canonicalProjectPorts( - current: Record, - canonical: ReadonlySet, - canonicalForCurrent: ReadonlyMap, -): { ports: Record; removed: number } { - const ports: Record = {}; - let removed = 0; - for (const [workspaceSlug, port] of Object.entries(current)) { - const target = canonicalForCurrent.get(workspaceSlug) ?? workspaceSlug; - if (!canonical.has(target)) { - removed += 1; - continue; - } - if (ports[target] !== undefined && ports[target] !== port) { - throw transitionError("Canonical project port allocation collides with another port."); - } - if (target !== workspaceSlug) { - removed += 1; - } - ports[target] = port; - } - return { ports, removed }; -} - -function canonicalProcessPortReservations( - current: z.infer, - canonical: ReadonlySet, - affectedProcessNames: ReadonlySet, -): z.infer { - return Object.fromEntries( - Object.entries(current).filter(([processId]) => { - if (affectedProcessNames.has(processId)) { - return false; - } - const slot = previewSlotWorkspaceSlug(processId); - return slot === null || (slot !== "invalid" && canonical.has(slot)); - }), - ); -} - -function assertProjectPortTransitionSafe( - projects: WorkspaceTransitionProject[], - projectPorts: Record, -): void { - const canonical = canonicalWorkspaceSet(projects); - const canonicalForCurrent = new Map( - projects.map((project) => [project.currentWorkspaceSlug, project.canonicalWorkspaceSlug]), - ); - const ports = new Map(); - for (const [workspaceSlug, port] of Object.entries(projectPorts)) { - const target = canonicalForCurrent.get(workspaceSlug) ?? workspaceSlug; - if (!canonical.has(target)) { - continue; - } - const existing = ports.get(target); - if (existing !== undefined && existing !== port) { - throw transitionError("Canonical project port allocation collides with another port."); - } - ports.set(target, port); - } -} - -function processNeedsRemoval( - name: string, - record: ProcessRecord, - canonical: ReadonlySet, - changed: ReadonlySet, -): boolean { - const scopes = processWorkspaceSlugs(name, record); - return scopes.some((scope) => scope === "invalid" || !canonical.has(scope) || changed.has(scope)); -} - -function processWorkspaceSlugs(name: string, record: ProcessRecord): Array { - const scopes: Array = []; - const cwdSlug = workspaceSlugFromPath(record.cwd); - if (cwdSlug) { - scopes.push(cwdSlug); - } else if (record.cwd !== WORKSPACE_DIR && record.cwd.startsWith(`${WORKSPACE_DIR}/`)) { - scopes.push("invalid"); - } - const slotSlug = previewSlotWorkspaceSlug(name); - if (slotSlug !== null && !scopes.includes(slotSlug)) { - scopes.push(slotSlug); - } - return scopes; -} - -function previewSlotWorkspaceSlug(processId: string): string | "invalid" | null { - if (!processId.startsWith(APP_PREVIEW_SLOT_PREFIX)) { - return null; - } - const parsed = ProjectWorkspaceSlugSchema.safeParse( - processId.slice(APP_PREVIEW_SLOT_PREFIX.length), - ); - return parsed.success ? parsed.data : "invalid"; -} - -function canonicalWorkspaceSet(projects: WorkspaceTransitionProject[]): Set { - return new Set(projects.map((project) => project.canonicalWorkspaceSlug)); -} - -function assertCanonicalFinalizationInput(projects: WorkspaceTransitionProject[]): void { - if (projects.some((project) => project.currentWorkspaceSlug !== project.canonicalWorkspaceSlug)) { - throw transitionError("Workspace transition evidence is absent before canonical commit."); - } -} - -async function transitionIdentity( - input: InternalWorkspaceReconciliationBody, -): Promise { - const projects = [...input.projects].sort((left, right) => - left.projectId.localeCompare(right.projectId), - ); - return { - canonicalDigest: await canonicalWorkspaceDigest( - projects.map((project) => project.canonicalWorkspaceSlug), - ), - }; -} - -function parsePhase( - input: InternalWorkspaceReconciliationBody, - phase: "finalize" | "prepare", -): InternalWorkspaceReconciliationBody { - const parsed = InternalWorkspaceReconciliationBodySchema.parse(input); - if (parsed.phase !== phase) { - throw transitionError(`Workspace transition phase must be ${phase}.`); - } - return parsed; -} - -function transitionResult( - input: InternalWorkspaceReconciliationBody, - identity: WorkspaceTransitionIdentity, - transitionPhase: "completed" | "prepared", - snapshot: SandboxSnapshotReconciliation, - counts = { - processPortReservationsRemoved: 0, - processRecordsRemoved: 0, - projectPortsRemoved: 0, - }, -): InternalWorkspaceReconciliationResponse { - return { - canonicalDigest: identity.canonicalDigest, - canonicalWorkspaceCount: input.projects.length, - ...counts, - ok: true, - releaseSha: input.releaseSha, - snapshot, - transitionPhase, - verified: true, - }; -} - -function pendingSnapshot(targetSnapshot: string): SandboxSnapshotReconciliation { - return { - complete: false, - sourceSnapshot: null, - status: "upgrading", - targetSnapshot, - upgradeId: null, - workspaceDigest: null, - }; -} - -function parseJson(value: string | null | undefined): unknown { - try { - return JSON.parse(value ?? "") as unknown; - } catch { - return null; - } -} - -function assertSameSlugs(actual: readonly string[], expected: readonly string[]): void { - if ([...actual].sort().join("\n") !== [...expected].sort().join("\n")) { - throw transitionError("Project workspace folder evidence changed during transition."); - } -} - -function transitionError(message: string, output?: string | null): APIError { - return new APIError(409, "conflict_state_invalid", message, { - ...(output ? { details: { output: output.slice(-1_000) } } : {}), - retriable: false, - }); -} - -const WORKSPACE_TRANSITION_SCRIPT = ` -import base64 -import json -import os -import stat -import sys - -payload = json.loads(base64.b64decode(sys.argv[1]).decode("utf-8")) -root = "/workspace" -projects = payload["projects"] - -def path_for(slug): - return os.path.join(root, slug) - -def kind(path): - try: - metadata = os.lstat(path) - except FileNotFoundError: - return "absent" - if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISDIR(metadata.st_mode): - raise RuntimeError(f"Workspace path is not a real directory: {path}") - return "directory" - -states = [] -for project in projects: - current = project["currentWorkspaceSlug"] - canonical = project["canonicalWorkspaceSlug"] - current_kind = kind(path_for(current)) - canonical_kind = current_kind if current == canonical else kind(path_for(canonical)) - if current != canonical and current_kind == "directory" and canonical_kind == "directory": - raise RuntimeError(f"Workspace rename destination already exists: {canonical}") - states.append((current, canonical, current_kind, canonical_kind)) - -if payload["mode"] == "prepare": - for current, canonical, current_kind, canonical_kind in states: - if current != canonical and current_kind == "directory" and canonical_kind == "absent": - os.rename(path_for(current), path_for(canonical)) - -present = [] -for project in projects: - current = project["currentWorkspaceSlug"] - canonical = project["canonicalWorkspaceSlug"] - if current != canonical and kind(path_for(current)) != "absent": - raise RuntimeError(f"Noncanonical workspace still exists: {current}") - if kind(path_for(canonical)) == "directory": - present.append(canonical) - -present.sort() -print(json.dumps({"present": present}, separators=(",", ":"))) -`; diff --git a/apps/agent-worker/src/durable-objects/project-sandbox.ts b/apps/agent-worker/src/durable-objects/project-sandbox.ts index d2a028c6..6de8564c 100644 --- a/apps/agent-worker/src/durable-objects/project-sandbox.ts +++ b/apps/agent-worker/src/durable-objects/project-sandbox.ts @@ -1,9 +1,3 @@ -import type { - InternalDurableObjectStorageRequest, - InternalDurableObjectStorageResponse, -} from "@cheatcode/types"; -import { InternalWorkspaceReconciliationBodySchema } from "@cheatcode/types"; -import { reconcileProjectSandboxStorageRequest } from "./durable-storage-reconciliation"; import { ProjectSandboxContent } from "./project-sandbox-content"; import { APP_PREVIEW_SLOT_PREFIX } from "./project-sandbox-process-support"; import { ProjectWorkspaceSlugSchema, workspaceSlugFromPath } from "./project-sandbox-runtime"; @@ -14,12 +8,6 @@ import { ProjectWorkspaceSlugSchema, workspaceSlugFromPath } from "./project-san * work without holding blockConcurrencyWhile across Daytona requests. */ export class ProjectSandbox extends ProjectSandboxContent { - public reconcileStorageSchema( - value: InternalDurableObjectStorageRequest, - ): InternalDurableObjectStorageResponse { - return reconcileProjectSandboxStorageRequest(this.ctx, this.env, value); - } - public override registerOwner( ...args: Parameters ): ReturnType { @@ -41,8 +29,8 @@ export class ProjectSandbox extends ProjectSandboxContent { public override renewRun( ...args: Parameters ): ReturnType { - // Late cleanup is absorbed by account deletion; workspace transitions reject it - // because end/alarm can change Daytona activity or auto-stop during a rename. + // Cleanup signals remain admissible while account deletion drains work so + // late lease renewal and alarm delivery cannot strand Daytona activity. return this.withActiveSandboxCleanupSignal(() => super.renewRun(...args)); } @@ -274,27 +262,6 @@ export class ProjectSandbox extends ProjectSandboxContent { ): ReturnType { return this.withActiveProjectWorkspaceCleanup(() => super.cleanupProjectWorkspace(...args)); } - - public override prepareWorkspaceTransition( - ...args: Parameters - ): ReturnType { - return this.withActiveWorkspaceTransition(transitionId(args[0]), () => - super.prepareWorkspaceTransition(...args), - ); - } - - public override finalizeWorkspaceTransition( - ...args: Parameters - ): ReturnType { - return this.withActiveWorkspaceTransition(transitionId(args[0]), () => - super.finalizeWorkspaceTransition(...args), - ); - } -} - -function transitionId(input: unknown): string { - const parsed = InternalWorkspaceReconciliationBodySchema.parse(input); - return `workspace-sandbox-release:${parsed.releaseSha}`; } function workspaceSlug(value: string | undefined): string | null { diff --git a/apps/agent-worker/src/index.ts b/apps/agent-worker/src/index.ts index 5f41bb7e..f65182b7 100644 --- a/apps/agent-worker/src/index.ts +++ b/apps/agent-worker/src/index.ts @@ -8,18 +8,13 @@ import { toAPIError, withErrorHandler, } from "@cheatcode/observability"; -import { - INTERNAL_DATABASE_READINESS_PATH, - INTERNAL_DURABLE_OBJECT_STORAGE_PATH, - normalizeTelemetryPath, -} from "@cheatcode/types"; +import { INTERNAL_DATABASE_READINESS_PATH, normalizeTelemetryPath } from "@cheatcode/types"; import { type Context, Hono } from "hono"; import { routePath } from "hono/route"; import { registerAgentRunHttpRoutes } from "./agent-api-run-routes"; import { registerAgentSystemHttpRoutes } from "./agent-api-system-routes"; import type { AgentEnv } from "./agent-env"; import { registerAgentDatabaseReadinessRoute } from "./database-readiness"; -import { registerAgentDurableObjectStorageRoute } from "./durable-object-storage"; import { AgentRun } from "./durable-objects/agent-run"; import { AgentRunWorkflow } from "./durable-objects/agent-run-workflow"; import { ProjectSandbox } from "./durable-objects/project-sandbox"; @@ -76,7 +71,6 @@ agentApp.get("/health", (c) => ); registerAgentDatabaseReadinessRoute(agentApp); -registerAgentDurableObjectStorageRoute(agentApp); registerAgentSystemHttpRoutes(agentApp); registerAgentRunHttpRoutes(agentApp); registerSandboxHttpRoutes(agentApp); @@ -114,8 +108,6 @@ const agentHandler = { }, }; -const WORKSPACE_RECONCILIATION_PATH = - /^\/internal\/users\/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\/reconcile-workspaces$/u; const USER_STATE_DELETION_PATH = /^\/internal\/users\/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\/delete-state$/u; @@ -131,15 +123,14 @@ function agentReleaseGateResponse( if ( env.CHEATCODE_RELEASE_GATE === "closed" && request.method === "POST" && - (pathname === INTERNAL_DATABASE_READINESS_PATH || - pathname === INTERNAL_DURABLE_OBJECT_STORAGE_PATH) + pathname === INTERNAL_DATABASE_READINESS_PATH ) { return undefined; } if ( request.method === "POST" && - ((env.CHEATCODE_RELEASE_GATE === "draining" && USER_STATE_DELETION_PATH.test(pathname)) || - (env.CHEATCODE_RELEASE_GATE === "closed" && WORKSPACE_RECONCILIATION_PATH.test(pathname))) + env.CHEATCODE_RELEASE_GATE === "draining" && + USER_STATE_DELETION_PATH.test(pathname) ) { return undefined; } diff --git a/apps/agent-worker/src/internal-maintenance.ts b/apps/agent-worker/src/internal-maintenance.ts index 24934754..5124e273 100644 --- a/apps/agent-worker/src/internal-maintenance.ts +++ b/apps/agent-worker/src/internal-maintenance.ts @@ -41,14 +41,6 @@ export function assertAgentDatabaseReadinessCapability(request: Request): void { }); } -export function assertAgentDurableObjectStorageCapability(request: Request): void { - assertInternalMaintenanceEnvelope(request, { - audience: "agent", - capability: "durable-object-schema", - issuer: "gateway", - }); -} - export function verifyAgentLifecycleRequest(input: AgentMaintenanceRequestInput): Promise { return verifyAgentRequest(input, "agent-lifecycle"); } @@ -59,15 +51,9 @@ export function verifyAgentDatabaseReadinessRequest( return verifyAgentRequest(input, "database-readiness"); } -export function verifyAgentDurableObjectStorageRequest( - input: AgentMaintenanceRequestInput, -): Promise { - return verifyAgentRequest(input, "durable-object-schema"); -} - async function verifyAgentRequest( input: AgentMaintenanceRequestInput, - capability: "agent-lifecycle" | "database-readiness" | "durable-object-schema", + capability: "agent-lifecycle" | "database-readiness", ): Promise { const secret = await requireAgentMaintenanceSecret( capability === "agent-lifecycle" diff --git a/apps/gateway-worker/README.md b/apps/gateway-worker/README.md index 85908097..dbd4b4a9 100644 --- a/apps/gateway-worker/README.md +++ b/apps/gateway-worker/README.md @@ -89,26 +89,17 @@ Gateway emits `first_byok_key_added` after the first successful provider-key sav and accepts authenticated `/v1/user-events` activation pings from the real web UI. Production deploys bind an immutable `CHEATCODE_RELEASE_SHA` into every affected -Worker. Forward-compatible Durable Object storage changes reconcile transactionally -when an existing object is first admitted, before the operation reaches an await. -This keeps dormant objects deployable without a fleet-wide maintenance pass while -preserving every validated source row. The signed internal storage route and -`CHEATCODE_RELEASE_GATE=closed` remain available for explicit bulk verification -and schema contractions that require a coordinated maintenance window. +Worker. Each Durable Object initializes one current SQLite contract and validates +that exact contract before using existing storage. `CHEATCODE_RELEASE_GATE=open` is the steady state. A closed gateway rejects public work, and agent/webhook draining or closed gates fence new writer admissions. -The gate is an operational barrier; SQLite reconciliation itself is performed by -the object's synchronous transaction and verified against the exact schema. +The gate is an operational barrier; SQLite schema validation is synchronous. -`IdempotencyStore` owns one exact SQLite table shape in its stable namespace and -reconciles dormant objects to that shape when they are next activated. Run -creation is also durably idempotent in Postgres, so request-cache evolution -cannot create a duplicate run. - -`QuotaTracker` has no compatibility migration path. New objects initialize -directly into the current exact schema, while existing objects must already -match that schema before any quota operation is admitted. +`IdempotencyStore`, `RateLimiter`, and `QuotaTracker` each own one exact SQLite +schema. New objects initialize that schema directly; existing objects must +already match it before an operation is admitted. Run creation is also durably +idempotent in Postgres, so request-cache state cannot create a duplicate run. `/v1/tools` and `/v1/agents` read the shared framework-free capability catalog from `@cheatcode/types`. The Mastra registries are statically constrained to the diff --git a/apps/gateway-worker/src/core-http-routes.ts b/apps/gateway-worker/src/core-http-routes.ts index 791abc3c..801e1bba 100644 --- a/apps/gateway-worker/src/core-http-routes.ts +++ b/apps/gateway-worker/src/core-http-routes.ts @@ -3,7 +3,6 @@ import type { UserId } from "@cheatcode/types"; import { agentServiceRequest } from "./agent-forwarding"; import { authenticate } from "./authenticate"; import { registerGatewayDatabaseReadinessRoute } from "./database-readiness"; -import { registerGatewayDurableObjectStorageRoute } from "./durable-object-storage"; import type { GatewayApp, GatewayEnv } from "./gateway-env"; import { OPENAPI_DOCUMENT, openApiDocsHtml } from "./openapi"; import { rateLimit, rateLimitPublic, withRateLimitHeaders } from "./rate-limit"; @@ -14,7 +13,6 @@ import type { WaitUntilContext } from "./wait-until-context"; export function registerCoreHttpRoutes(app: GatewayApp): void { registerGatewayDatabaseReadinessRoute(app); - registerGatewayDurableObjectStorageRoute(app); registerHealthRoute(app); registerDiscoveryRoutes(app); registerTelemetryRoutes(app); diff --git a/apps/gateway-worker/src/durable-object-storage.ts b/apps/gateway-worker/src/durable-object-storage.ts deleted file mode 100644 index e251a916..00000000 --- a/apps/gateway-worker/src/durable-object-storage.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { - assertInternalMaintenanceEnvelope, - createInternalMaintenanceHeaders, - verifyInternalMaintenanceRequest, -} from "@cheatcode/auth"; -import { - APIError, - readBoundedRequestText, - readBoundedResponseJson, -} from "@cheatcode/observability"; -import { - INTERNAL_DURABLE_OBJECT_STORAGE_PATH, - type InternalDurableObjectStorageRequest, - InternalDurableObjectStorageRequestSchema, - type InternalDurableObjectStorageResponse, - InternalDurableObjectStorageResponseSchema, -} from "@cheatcode/types"; -import type { GatewayApp, GatewayContext, GatewayEnv } from "./gateway-env"; -import { requireDatabaseReadinessSecret } from "./internal-maintenance"; - -const MAX_STORAGE_BODY_BYTES = 4 * 1024; -const MAX_STORAGE_RESPONSE_BYTES = 16 * 1024; -const DOWNSTREAM_STORAGE_ATTESTATION_TIMEOUT_MS = 2 * 60 * 1_000; - -export function registerGatewayDurableObjectStorageRoute(app: GatewayApp): void { - app.post(INTERNAL_DURABLE_OBJECT_STORAGE_PATH, handleDurableObjectStorage); -} - -async function handleDurableObjectStorage(c: GatewayContext): Promise { - const { input, rawBody, secret } = await authenticateRequest(c); - const result = await routeStorageRequest(c.env, input, rawBody, secret); - return c.json(assertMatchingEvidence(input, result)); -} - -async function authenticateRequest(c: GatewayContext): Promise<{ - input: InternalDurableObjectStorageRequest; - rawBody: string; - secret: string; -}> { - assertClosedRelease(c.env, c.req.raw); - assertInternalMaintenanceEnvelope(c.req.raw, { - audience: "gateway", - capability: "durable-object-schema", - issuer: "release-control", - }); - const rawBody = await readBoundedRequestText( - c.req.raw, - MAX_STORAGE_BODY_BYTES, - "Durable Object storage request", - ); - const secret = await requireDatabaseReadinessSecret(c.env); - await verifyInternalMaintenanceRequest({ - expectedAudience: "gateway", - expectedCapability: "durable-object-schema", - expectedIssuer: "release-control", - expectedMethod: "POST", - expectedPathname: INTERNAL_DURABLE_OBJECT_STORAGE_PATH, - rawBody, - request: c.req.raw, - secret, - }); - const input = InternalDurableObjectStorageRequestSchema.parse(parseJson(rawBody)); - if (input.releaseSha !== c.env.CHEATCODE_RELEASE_SHA) { - throw mismatch("Durable Object request does not match the closed gateway release"); - } - return { input, rawBody, secret }; -} - -function assertClosedRelease(env: GatewayEnv, request: Request): void { - if (env.CHEATCODE_RELEASE_GATE !== "closed") { - throw mismatch("Durable Object reconciliation requires the closed release gate"); - } - const hostname = new URL(request.url).hostname; - const validHost = - env.CHEATCODE_ENVIRONMENT === "production" - ? hostname === "gateway.trycheatcode.com" - : hostname === "127.0.0.1" || hostname === "localhost"; - if (!validHost) { - throw new APIError(404, "not_found_run", "Durable Object route was not found", { - retriable: false, - }); - } -} - -async function routeStorageRequest( - env: GatewayEnv, - input: InternalDurableObjectStorageRequest, - rawBody: string, - secret: string, -): Promise { - if (input.className === "AgentRun" || input.className === "ProjectSandbox") { - return readDownstreamStorage(env.AGENT, "agent", input, rawBody, secret); - } - if (input.className === "WebhookIdempotencyStore") { - return readDownstreamStorage(env.WEBHOOKS, "webhooks", input, rawBody, secret); - } - if (input.className === "IdempotencyStore") { - const id = env.IDEMPOTENCY.idFromString(input.objectId); - return env.IDEMPOTENCY.get(id).reconcileStorageSchema(input); - } - if (input.className === "QuotaTracker") { - const id = env.QUOTA_TRACKER.idFromString(input.objectId); - return env.QUOTA_TRACKER.get(id).reconcileStorageSchema(input); - } - const id = env.RATE_LIMITER.idFromString(input.objectId); - return env.RATE_LIMITER.get(id).reconcileStorageSchema(input); -} - -async function readDownstreamStorage( - binding: Fetcher, - worker: "agent" | "webhooks", - input: InternalDurableObjectStorageRequest, - rawBody: string, - secret: string, -): Promise { - const headers = await createInternalMaintenanceHeaders({ - audience: worker, - capability: "durable-object-schema", - issuer: "gateway", - method: "POST", - pathname: INTERNAL_DURABLE_OBJECT_STORAGE_PATH, - rawBody, - secret, - }); - headers.set("content-type", "application/json"); - const response = await binding.fetch( - `https://${worker}.internal${INTERNAL_DURABLE_OBJECT_STORAGE_PATH}`, - { - body: rawBody, - headers, - method: "POST", - signal: AbortSignal.timeout(DOWNSTREAM_STORAGE_ATTESTATION_TIMEOUT_MS), - }, - ); - if (!response.ok) { - await response.body?.cancel().catch(() => undefined); - throw new APIError(503, "unavailable_maintenance", `${worker} storage attestation failed`, { - details: { status: response.status }, - retriable: true, - }); - } - return assertMatchingEvidence( - input, - InternalDurableObjectStorageResponseSchema.parse( - await readBoundedResponseJson( - response, - MAX_STORAGE_RESPONSE_BYTES, - `${worker} Durable Object storage attestation`, - ), - ), - ); -} - -function assertMatchingEvidence( - input: InternalDurableObjectStorageRequest, - evidence: InternalDurableObjectStorageResponse, -): InternalDurableObjectStorageResponse { - const parsed = InternalDurableObjectStorageResponseSchema.parse(evidence); - if ( - parsed.className !== input.className || - parsed.objectId !== input.objectId || - parsed.releaseSha !== input.releaseSha - ) { - throw mismatch("Durable Object storage evidence does not match the request"); - } - return parsed; -} - -function parseJson(rawBody: string): unknown { - try { - return JSON.parse(rawBody) as unknown; - } catch { - throw new APIError(400, "invalid_request_body", "Durable Object body must be JSON", { - retriable: false, - }); - } -} - -function mismatch(message: string): APIError { - return new APIError(409, "conflict_state_invalid", message, { retriable: false }); -} diff --git a/apps/gateway-worker/src/durable-objects/idempotency-storage.ts b/apps/gateway-worker/src/durable-objects/idempotency-storage.ts index d9abd00b..26ecfbca 100644 --- a/apps/gateway-worker/src/durable-objects/idempotency-storage.ts +++ b/apps/gateway-worker/src/durable-objects/idempotency-storage.ts @@ -1,32 +1,9 @@ import { assertExactSqliteSchema, - assertSqliteRowCountPreserved, type ExpectedSqliteObject, - reconcileExactSqliteStorage, setCurrentSqliteStorageVersion, } from "@cheatcode/durable-storage"; -interface ExpectedColumn { - defaultValue: string | null; - isNotNull: boolean; - isPrimaryKey: boolean; - name: string; - type: string; -} - -const IDEMPOTENCY_COLUMNS = [ - column("key", "TEXT", true, true), - column("body_hash", "TEXT", true), - column("claim_id", "TEXT"), - column("state", "TEXT", true), - column("response_status", "INTEGER"), - column("response_headers_json", "TEXT"), - column("response_body", "TEXT"), - column("expires_at", "INTEGER", true), -] as const; - -const REQUIRED_COLUMNS = IDEMPOTENCY_COLUMNS.filter(({ name }) => name !== "claim_id"); - const IDEMPOTENCY_TABLE_SQL = `CREATE TABLE idempotency_entry ( key TEXT PRIMARY KEY CHECK (length(key) BETWEEN 1 AND 255), body_hash TEXT NOT NULL CHECK (length(body_hash) = 64 AND body_hash NOT GLOB '*[^a-f0-9]*'), @@ -47,115 +24,19 @@ const IDEMPOTENCY_STORAGE_SCHEMA: readonly ExpectedSqliteObject[] = [ }, ]; -function initializeIdempotencyStorage(ctx: DurableObjectState): void { - normalizeIdempotencyStorage(ctx, false); - assertIdempotencyStorage(ctx); -} - -/** Opens an existing object on the exact schema before serving its next request. */ +/** Initializes a new object or verifies that an existing object is current. */ export function ensureIdempotencyStorage(ctx: DurableObjectState): void { if (!hasIdempotencyStorage(ctx)) { - initializeIdempotencyStorage(ctx); - return; + ctx.storage.sql.exec(IDEMPOTENCY_TABLE_SQL); + setCurrentSqliteStorageVersion(ctx); } - reconcileExactSqliteStorage( - "reconcile", - () => assertIdempotencyStorage(ctx), - () => reconcileIdempotencyStorage(ctx), - ); + assertIdempotencyStorage(ctx); } export function hasIdempotencyStorage(ctx: DurableObjectState): boolean { - return tableColumns(ctx, "idempotency_entry").length > 0; -} - -/** Rebuilds a supported predecessor schema while preserving every stored row. */ -export function reconcileIdempotencyStorage(ctx: DurableObjectState): void { - normalizeIdempotencyStorage(ctx, true); - assertExactSqliteSchema(ctx, IDEMPOTENCY_STORAGE_SCHEMA); + return ctx.storage.sql.exec("PRAGMA table_info(idempotency_entry)").toArray().length > 0; } -export function assertIdempotencyStorage(ctx: DurableObjectState): void { +function assertIdempotencyStorage(ctx: DurableObjectState): void { assertExactSqliteSchema(ctx, IDEMPOTENCY_STORAGE_SCHEMA); } - -function normalizeIdempotencyStorage(ctx: DurableObjectState, forceRebuild: boolean): void { - const columns = tableColumns(ctx, "idempotency_entry"); - if (columns.length === 0) { - createIdempotencyTable(ctx, "idempotency_entry"); - setCurrentSqliteStorageVersion(ctx); - return; - } - if (!forceRebuild && hasExactColumns(columns, IDEMPOTENCY_COLUMNS)) { - setCurrentSqliteStorageVersion(ctx); - return; - } - if (!REQUIRED_COLUMNS.every(({ name }) => hasColumn(columns, name))) { - throw new Error("Unsupported idempotency_entry schema; refusing lossy evolution."); - } - const claimId = hasColumn(columns, "claim_id") ? "claim_id" : "NULL"; - ctx.storage.transactionSync(() => { - ctx.storage.sql.exec("DROP TABLE IF EXISTS idempotency_entry_next"); - createIdempotencyTable(ctx, "idempotency_entry_next"); - ctx.storage.sql.exec( - `INSERT INTO idempotency_entry_next ( - key, body_hash, claim_id, state, response_status, - response_headers_json, response_body, expires_at - ) - SELECT key, body_hash, ${claimId}, state, response_status, - response_headers_json, response_body, expires_at - FROM idempotency_entry`, - ); - assertSqliteRowCountPreserved(ctx, "idempotency_entry", "idempotency_entry_next"); - ctx.storage.sql.exec("DROP TABLE idempotency_entry"); - ctx.storage.sql.exec("ALTER TABLE idempotency_entry_next RENAME TO idempotency_entry"); - }); - setCurrentSqliteStorageVersion(ctx); -} - -function createIdempotencyTable( - ctx: DurableObjectState, - table: "idempotency_entry" | "idempotency_entry_next", -): void { - ctx.storage.sql.exec(IDEMPOTENCY_TABLE_SQL.replace("idempotency_entry", table)); -} - -function tableColumns(ctx: DurableObjectState, table: string): unknown[] { - return ctx.storage.sql.exec(`PRAGMA table_info(${table})`).toArray(); -} - -function hasExactColumns(rows: unknown[], expected: readonly ExpectedColumn[]): boolean { - return ( - rows.length === expected.length && - expected.every((value, index) => { - const row = rows[index]; - return ( - isRecord(row) && - row["cid"] === index && - row["name"] === value.name && - row["type"] === value.type && - row["notnull"] === Number(value.isNotNull) && - row["pk"] === Number(value.isPrimaryKey) && - row["dflt_value"] === value.defaultValue - ); - }) - ); -} - -function hasColumn(rows: unknown[], name: string): boolean { - return rows.some((row) => isRecord(row) && row["name"] === name); -} - -function column( - name: string, - type: string, - isNotNull = false, - isPrimaryKey = false, - defaultValue: string | null = null, -): ExpectedColumn { - return { defaultValue, isNotNull, isPrimaryKey, name, type }; -} - -function isRecord(value: unknown): value is Record { - return typeof value === "object" && value !== null; -} diff --git a/apps/gateway-worker/src/durable-objects/idempotency.ts b/apps/gateway-worker/src/durable-objects/idempotency.ts index 54c74d6f..286d1524 100644 --- a/apps/gateway-worker/src/durable-objects/idempotency.ts +++ b/apps/gateway-worker/src/durable-objects/idempotency.ts @@ -1,14 +1,5 @@ import { DurableObject } from "cloudflare:workers"; -import { - assertStorageReconciliationRequest, - reconcileExactSqliteStorage, - storageSchemaEvidence, -} from "@cheatcode/durable-storage"; import { readJsonRequest } from "@cheatcode/observability"; -import type { - InternalDurableObjectStorageRequest, - InternalDurableObjectStorageResponse, -} from "@cheatcode/types"; import { z } from "zod"; import { IdempotencyBeginBodySchema, @@ -16,12 +7,7 @@ import { IdempotencyBeginResultSchema, IdempotencyCompleteBodySchema, } from "./idempotency-contract"; -import { - assertIdempotencyStorage, - ensureIdempotencyStorage, - hasIdempotencyStorage, - reconcileIdempotencyStorage, -} from "./idempotency-storage"; +import { ensureIdempotencyStorage, hasIdempotencyStorage } from "./idempotency-storage"; import { gatewayDurableObjectClosedResponse, rearmClosedGatewayDurableObjectAlarm, @@ -46,19 +32,6 @@ const MAX_IDEMPOTENCY_REQUEST_BYTES = 1024 * 1024; export class IdempotencyStore extends DurableObject { private isStorageInitialized = false; - public reconcileStorageSchema( - value: InternalDurableObjectStorageRequest, - ): InternalDurableObjectStorageResponse { - const input = assertStorageReconciliationRequest(this.ctx, this.env, value, "IdempotencyStore"); - reconcileExactSqliteStorage( - input.mode, - () => assertIdempotencyStorage(this.ctx), - () => reconcileIdempotencyStorage(this.ctx), - ); - this.isStorageInitialized = true; - return storageSchemaEvidence(input); - } - public override async fetch(request: Request): Promise { if (this.env.CHEATCODE_RELEASE_GATE === "closed") { return gatewayDurableObjectClosedResponse(); diff --git a/apps/gateway-worker/src/durable-objects/quota-tracker-storage.ts b/apps/gateway-worker/src/durable-objects/quota-tracker-storage.ts index 195f5a6a..b032fdd6 100644 --- a/apps/gateway-worker/src/durable-objects/quota-tracker-storage.ts +++ b/apps/gateway-worker/src/durable-objects/quota-tracker-storage.ts @@ -82,7 +82,7 @@ export function ensureQuotaTrackerStorage(ctx: DurableObjectState): void { assertQuotaTrackerStorage(ctx); } -export function assertQuotaTrackerStorage(ctx: DurableObjectState): void { +function assertQuotaTrackerStorage(ctx: DurableObjectState): void { assertExactSqliteSchema(ctx, QUOTA_STORAGE_SCHEMA); } diff --git a/apps/gateway-worker/src/durable-objects/quota-tracker.ts b/apps/gateway-worker/src/durable-objects/quota-tracker.ts index 93463a63..25b79293 100644 --- a/apps/gateway-worker/src/durable-objects/quota-tracker.ts +++ b/apps/gateway-worker/src/durable-objects/quota-tracker.ts @@ -1,13 +1,5 @@ import { DurableObject } from "cloudflare:workers"; -import { - assertStorageReconciliationRequest, - storageSchemaEvidence, -} from "@cheatcode/durable-storage"; import { readJsonRequest } from "@cheatcode/observability"; -import type { - InternalDurableObjectStorageRequest, - InternalDurableObjectStorageResponse, -} from "@cheatcode/types"; import { QUOTA_TRACKER_MAX_REQUEST_BYTES, type QuotaFeature, @@ -30,11 +22,7 @@ import { type QuotaSnapshotResult, QuotaSnapshotResultSchema, } from "./quota-tracker-contract"; -import { - assertQuotaTrackerStorage, - ensureQuotaTrackerStorage, - hasQuotaTrackerStorage, -} from "./quota-tracker-storage"; +import { ensureQuotaTrackerStorage, hasQuotaTrackerStorage } from "./quota-tracker-storage"; import { assertGatewayDurableObjectOpen, gatewayDurableObjectClosedResponse, @@ -125,15 +113,6 @@ function isRecord(value: unknown): value is Record { export class QuotaTracker extends DurableObject { private isStorageInitialized = false; - public reconcileStorageSchema( - value: InternalDurableObjectStorageRequest, - ): InternalDurableObjectStorageResponse { - const input = assertStorageReconciliationRequest(this.ctx, this.env, value, "QuotaTracker"); - assertQuotaTrackerStorage(this.ctx); - this.isStorageInitialized = true; - return storageSchemaEvidence(input); - } - public async tryConsume( feature: QuotaFeature, amount: number, diff --git a/apps/gateway-worker/src/durable-objects/rate-limiter-storage.ts b/apps/gateway-worker/src/durable-objects/rate-limiter-storage.ts index 3e7c4289..5466834c 100644 --- a/apps/gateway-worker/src/durable-objects/rate-limiter-storage.ts +++ b/apps/gateway-worker/src/durable-objects/rate-limiter-storage.ts @@ -1,8 +1,6 @@ import { assertExactSqliteSchema, - assertSqliteRowCountPreserved, type ExpectedSqliteObject, - reconcileExactSqliteStorage, setCurrentSqliteStorageVersion, } from "@cheatcode/durable-storage"; @@ -20,69 +18,19 @@ const RATE_LIMITER_STORAGE_SCHEMA: readonly ExpectedSqliteObject[] = [ { name: "bucket", sql: BUCKET_TABLE_SQL, tableName: "bucket", type: "table" }, ]; -function initializeRateLimiterStorage(ctx: DurableObjectState): void { - ensureRateLimiterTable(ctx); - setCurrentSqliteStorageVersion(ctx); - assertRateLimiterStorage(ctx); -} - -/** Opens an existing object on the exact schema before serving its next request. */ +/** Initializes a new object or verifies that an existing object is current. */ export function ensureRateLimiterStorage(ctx: DurableObjectState): void { if (!hasRateLimiterStorage(ctx)) { - initializeRateLimiterStorage(ctx); - return; + ctx.storage.sql.exec(BUCKET_TABLE_SQL); + setCurrentSqliteStorageVersion(ctx); } - reconcileExactSqliteStorage( - "reconcile", - () => assertRateLimiterStorage(ctx), - () => reconcileRateLimiterStorage(ctx), - ); + assertRateLimiterStorage(ctx); } export function hasRateLimiterStorage(ctx: DurableObjectState): boolean { return ctx.storage.sql.exec("PRAGMA table_info(bucket)").toArray().length > 0; } -/** Rebuilds the one live table so same-column legacy constraints cannot survive the cutover. */ -export function reconcileRateLimiterStorage(ctx: DurableObjectState): void { - ensureRateLimiterTable(ctx); - assertRateLimiterSourceRows(ctx); - ctx.storage.transactionSync(() => { - ctx.storage.sql.exec("ALTER TABLE bucket RENAME TO bucket_reconcile_source"); - ctx.storage.sql.exec(BUCKET_TABLE_SQL); - ctx.storage.sql.exec( - `INSERT INTO bucket (key, tokens, last_refill_ms, capacity, refill_per_sec) - SELECT key, tokens, last_refill_ms, capacity, refill_per_sec - FROM bucket_reconcile_source`, - ); - assertSqliteRowCountPreserved(ctx, "bucket_reconcile_source", "bucket"); - ctx.storage.sql.exec("DROP TABLE bucket_reconcile_source"); - }); - setCurrentSqliteStorageVersion(ctx); - assertRateLimiterStorage(ctx); -} - -function ensureRateLimiterTable(ctx: DurableObjectState): void { - ctx.storage.sql.exec(BUCKET_TABLE_SQL.replace("CREATE TABLE", "CREATE TABLE IF NOT EXISTS")); -} - -export function assertRateLimiterStorage(ctx: DurableObjectState): void { +function assertRateLimiterStorage(ctx: DurableObjectState): void { assertExactSqliteSchema(ctx, RATE_LIMITER_STORAGE_SCHEMA); } - -function assertRateLimiterSourceRows(ctx: DurableObjectState): void { - const invalid = ctx.storage.sql - .exec( - `SELECT 1 FROM bucket WHERE - typeof(key) <> 'text' OR length(key) NOT BETWEEN 1 AND 256 OR - typeof(tokens) NOT IN ('integer', 'real') OR tokens < 0 OR - abs(tokens) > ${MAX_FINITE_REAL} OR typeof(last_refill_ms) <> 'integer' OR - last_refill_ms < 0 OR typeof(capacity) <> 'integer' OR capacity <= 0 OR - tokens > capacity OR typeof(refill_per_sec) NOT IN ('integer', 'real') OR - refill_per_sec <= 0 OR abs(refill_per_sec) > ${MAX_FINITE_REAL} LIMIT 1`, - ) - .toArray(); - if (invalid.length > 0) { - throw new Error("Rate limiter contains invalid data; refusing lossy evolution."); - } -} diff --git a/apps/gateway-worker/src/durable-objects/rate-limiter.ts b/apps/gateway-worker/src/durable-objects/rate-limiter.ts index 21bef090..8468948c 100644 --- a/apps/gateway-worker/src/durable-objects/rate-limiter.ts +++ b/apps/gateway-worker/src/durable-objects/rate-limiter.ts @@ -1,25 +1,11 @@ import { DurableObject } from "cloudflare:workers"; -import { - assertStorageReconciliationRequest, - reconcileExactSqliteStorage, - storageSchemaEvidence, -} from "@cheatcode/durable-storage"; import { readJsonRequest } from "@cheatcode/observability"; -import type { - InternalDurableObjectStorageRequest, - InternalDurableObjectStorageResponse, -} from "@cheatcode/types"; import { type RateLimitConfig, RateLimitConsumeBodySchema, type RateLimitResult, } from "./rate-limit-contract"; -import { - assertRateLimiterStorage, - ensureRateLimiterStorage, - hasRateLimiterStorage, - reconcileRateLimiterStorage, -} from "./rate-limiter-storage"; +import { ensureRateLimiterStorage, hasRateLimiterStorage } from "./rate-limiter-storage"; import { assertGatewayDurableObjectOpen, gatewayDurableObjectClosedResponse, @@ -49,19 +35,6 @@ function isBucketRow(value: unknown): value is BucketRow { export class RateLimiter extends DurableObject { private isStorageInitialized = false; - public reconcileStorageSchema( - value: InternalDurableObjectStorageRequest, - ): InternalDurableObjectStorageResponse { - const input = assertStorageReconciliationRequest(this.ctx, this.env, value, "RateLimiter"); - reconcileExactSqliteStorage( - input.mode, - () => assertRateLimiterStorage(this.ctx), - () => reconcileRateLimiterStorage(this.ctx), - ); - this.isStorageInitialized = true; - return storageSchemaEvidence(input); - } - public async consume( key: string, cost: number, diff --git a/apps/gateway-worker/src/index.ts b/apps/gateway-worker/src/index.ts index 4b7555b0..77a3b332 100644 --- a/apps/gateway-worker/src/index.ts +++ b/apps/gateway-worker/src/index.ts @@ -8,10 +8,7 @@ import { toAPIError, withErrorHandler, } from "@cheatcode/observability"; -import { - INTERNAL_DATABASE_READINESS_PATH, - INTERNAL_DURABLE_OBJECT_STORAGE_PATH, -} from "@cheatcode/types"; +import { INTERNAL_DATABASE_READINESS_PATH } from "@cheatcode/types"; import { Hono } from "hono"; import { cors } from "hono/cors"; import { routePath } from "hono/route"; @@ -239,11 +236,7 @@ async function releaseGateResponse( return undefined; } const url = new URL(request.url); - if ( - request.method === "POST" && - (url.pathname === INTERNAL_DATABASE_READINESS_PATH || - url.pathname === INTERNAL_DURABLE_OBJECT_STORAGE_PATH) - ) { + if (request.method === "POST" && url.pathname === INTERNAL_DATABASE_READINESS_PATH) { return undefined; } const details: Record = { diff --git a/apps/webhooks-worker/src/durable-object-storage.ts b/apps/webhooks-worker/src/durable-object-storage.ts deleted file mode 100644 index 5ff5452a..00000000 --- a/apps/webhooks-worker/src/durable-object-storage.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { - assertInternalMaintenanceEnvelope, - verifyInternalMaintenanceRequest, -} from "@cheatcode/auth"; -import { APIError, readBoundedRequestText } from "@cheatcode/observability"; -import { - INTERNAL_DURABLE_OBJECT_STORAGE_PATH, - InternalDurableObjectStorageRequestSchema, - InternalDurableObjectStorageResponseSchema, -} from "@cheatcode/types"; -import type { Context, Hono } from "hono"; -import type { WebhooksEnv } from "./index"; -import { - assertWebhooksServiceHostname, - requireDatabaseReadinessSecret, -} from "./internal-maintenance"; - -const MAX_STORAGE_BODY_BYTES = 4 * 1024; -type WebhooksContext = Context<{ Bindings: WebhooksEnv }>; - -export function registerWebhooksDurableObjectStorageRoute( - app: Hono<{ Bindings: WebhooksEnv }>, -): void { - app.post(INTERNAL_DURABLE_OBJECT_STORAGE_PATH, handleDurableObjectStorage); -} - -async function handleDurableObjectStorage(c: WebhooksContext): Promise { - if (c.env.CHEATCODE_RELEASE_GATE !== "closed") { - throw releaseMismatch("Durable Object reconciliation requires the closed release gate"); - } - assertWebhooksServiceHostname(c.req.raw); - assertInternalMaintenanceEnvelope(c.req.raw, { - audience: "webhooks", - capability: "durable-object-schema", - issuer: "gateway", - }); - const rawBody = await readBoundedRequestText( - c.req.raw, - MAX_STORAGE_BODY_BYTES, - "Durable Object storage request", - ); - await verifyInternalMaintenanceRequest({ - expectedAudience: "webhooks", - expectedCapability: "durable-object-schema", - expectedIssuer: "gateway", - expectedMethod: "POST", - expectedPathname: INTERNAL_DURABLE_OBJECT_STORAGE_PATH, - rawBody, - request: c.req.raw, - secret: await requireDatabaseReadinessSecret(c.env), - }); - const input = InternalDurableObjectStorageRequestSchema.parse(parseJson(rawBody)); - if ( - input.releaseSha !== c.env.CHEATCODE_RELEASE_SHA || - input.className !== "WebhookIdempotencyStore" - ) { - throw releaseMismatch("Durable Object request does not match the webhooks release"); - } - const id = c.env.WEBHOOK_IDEMPOTENCY.idFromString(input.objectId); - return c.json( - InternalDurableObjectStorageResponseSchema.parse( - await c.env.WEBHOOK_IDEMPOTENCY.get(id).reconcileStorageSchema(input), - ), - ); -} - -function parseJson(rawBody: string): unknown { - try { - return JSON.parse(rawBody) as unknown; - } catch { - throw new APIError(400, "invalid_request_body", "Durable Object body must be JSON", { - retriable: false, - }); - } -} - -function releaseMismatch(message: string): APIError { - return new APIError(409, "conflict_state_invalid", message, { retriable: false }); -} diff --git a/apps/webhooks-worker/src/index.ts b/apps/webhooks-worker/src/index.ts index ee935d2d..ba462b0c 100644 --- a/apps/webhooks-worker/src/index.ts +++ b/apps/webhooks-worker/src/index.ts @@ -22,7 +22,6 @@ import { } from "@cheatcode/observability"; import { INTERNAL_DATABASE_READINESS_PATH, - INTERNAL_DURABLE_OBJECT_STORAGE_PATH, INTERNAL_RESOURCE_DELETION_PATH, InternalResourceDeletionRequestSchema, } from "@cheatcode/types"; @@ -37,7 +36,6 @@ import { } from "./daily-maintenance-admission"; import { registerWebhooksDatabaseReadinessRoute } from "./database-readiness"; import { DaytonaWebhookSchema, verifyDaytonaWebhook } from "./daytona"; -import { registerWebhooksDurableObjectStorageRoute } from "./durable-object-storage"; import { internalAlertEventId, verifyInternalAlert } from "./internal-alert"; import { assertWebhookReplayHostname, @@ -275,7 +273,6 @@ webhooksApp.get("/health", (c) => ); registerWebhooksDatabaseReadinessRoute(webhooksApp); -registerWebhooksDurableObjectStorageRoute(webhooksApp); webhooksApp.post("/clerk", async (c) => { const signingSecret = await clerkWebhookSigningSecret(c.env); const rawBody = await readBoundedRequestText( @@ -733,8 +730,7 @@ function webhooksReleaseGateResponse( if ( env.CHEATCODE_RELEASE_GATE === "closed" && request.method === "POST" && - (url.pathname === INTERNAL_DATABASE_READINESS_PATH || - url.pathname === INTERNAL_DURABLE_OBJECT_STORAGE_PATH) + url.pathname === INTERNAL_DATABASE_READINESS_PATH ) { return undefined; } diff --git a/apps/webhooks-worker/src/lifecycle-adapters.ts b/apps/webhooks-worker/src/lifecycle-adapters.ts index a6e7de81..df7e8fdc 100644 --- a/apps/webhooks-worker/src/lifecycle-adapters.ts +++ b/apps/webhooks-worker/src/lifecycle-adapters.ts @@ -3,16 +3,10 @@ import { ComposioClient, isComposioNotFoundError } from "@cheatcode/composio"; import { resolveWorkerSecret, type WorkerSecret } from "@cheatcode/env"; import { APIError, readBoundedResponseJson } from "@cheatcode/observability"; import { - canonicalWorkspaceDigest, type InternalAgentStateDeleteBody, InternalAgentStateDeleteBodySchema, InternalStateDeleteResponseSchema, - type InternalWorkspaceReconciliationBody, - InternalWorkspaceReconciliationBodySchema, - type InternalWorkspaceReconciliationResponse, - InternalWorkspaceReconciliationResponseSchema, internalUserStateDeletePath, - internalUserWorkspaceReconciliationPath, type UserId, } from "@cheatcode/types"; import { @@ -95,51 +89,6 @@ export async function deleteProjectAgentWorkspace( }); } -export async function reconcileUserAgentWorkspaces( - env: AgentStateDeletionEnv, - userId: UserId, - payload: InternalWorkspaceReconciliationBody, - agentLifecycleSecret: string, -): Promise { - const parsed = InternalWorkspaceReconciliationBodySchema.parse(payload); - const body = JSON.stringify(parsed); - const pathname = internalUserWorkspaceReconciliationPath(userId); - const headers = await agentLifecycleHeaders(agentLifecycleSecret, pathname, body); - const response = await env.AGENT.fetch(`https://agent.internal${pathname}`, { - body, - headers, - method: "POST", - }); - if (!response.ok) { - const status = response.status; - await response.body?.cancel().catch(() => undefined); - throw new APIError(503, "unavailable_maintenance", "Workspace reconciliation failed", { - details: { status }, - retriable: isRetriableUpstreamStatus(status), - }); - } - const result = InternalWorkspaceReconciliationResponseSchema.parse( - await readBoundedResponseJson(response, INTERNAL_AGENT_RESPONSE_MAX_BYTES, "Agent Worker"), - ); - const expectedDigest = await canonicalWorkspaceDigest( - parsed.projects.map((project) => project.canonicalWorkspaceSlug), - ); - const isExpectedPhase = - result.transitionPhase === "completed" || - (parsed.phase === "prepare" && result.transitionPhase === "prepared"); - if ( - result.canonicalDigest !== expectedDigest || - result.canonicalWorkspaceCount !== parsed.projects.length || - result.releaseSha !== parsed.releaseSha || - !isExpectedPhase - ) { - throw new APIError(409, "conflict_state_invalid", "Workspace evidence does not match request", { - retriable: false, - }); - } - return result; -} - async function deleteAgentState( env: AgentStateDeletionEnv, userId: UserId, diff --git a/apps/webhooks-worker/src/ops-workflow.ts b/apps/webhooks-worker/src/ops-workflow.ts index 67213f0b..9b6aadfc 100644 --- a/apps/webhooks-worker/src/ops-workflow.ts +++ b/apps/webhooks-worker/src/ops-workflow.ts @@ -18,15 +18,6 @@ import { } from "./user-deletion-admission"; import { processUserDeletionChunk } from "./user-deletion-workflow"; import { createDeterministicWorkflow } from "./workflow-instance"; -import { - reconcileCanonicalWorkspaces, - type WorkspaceReconciliationChunk, - type WorkspaceReconciliationPayload, - WorkspaceReconciliationPayloadSchema, - type WorkspaceReconciliationWorkflowResult, - WorkspaceReconciliationWorkflowResultSchema, - workspaceReconciliationInstanceId, -} from "./workspace-reconciliation"; const OpsMaintenancePayloadSchema = z.union([ z.object({ @@ -40,7 +31,6 @@ const OpsMaintenancePayloadSchema = z.union([ }), DailyMaintenancePayloadSchema, UserDeletionPayloadSchema, - WorkspaceReconciliationPayloadSchema, ]); export type OpsMaintenancePayload = z.infer; @@ -68,27 +58,8 @@ export class OpsMaintenanceWorkflow extends WorkflowEntrypoint< public override async run( event: Readonly>, step: WorkflowStep, - ): Promise< - | WorkspaceReconciliationWorkflowResult - | { kind: Exclude; ok: true } - > { + ): Promise<{ kind: OpsMaintenancePayload["kind"]; ok: true }> { const payload = OpsMaintenancePayloadSchema.parse(event.payload); - if (payload.kind === "workspace-reconciliation") { - if (this.env.CHEATCODE_RELEASE_GATE !== "closed") { - throw new NonRetryableError( - "Workspace reconciliation requires the closed release gate", - "WorkspaceReconciliationGateOpen", - ); - } - if (event.instanceId !== workspaceReconciliationInstanceId(payload)) { - throw new NonRetryableError( - "Workspace reconciliation instance identity is invalid", - "WorkspaceReconciliationIdentityInvalid", - ); - } - const chunk = await reconcileCanonicalWorkspaces(this.env, payload, step); - return completeOrContinueWorkspaceReconciliation(this.env, payload, chunk, step); - } if (this.env.CHEATCODE_RELEASE_GATE === "closed") { throw new NonRetryableError( "Ops maintenance is fenced by a closed release", @@ -131,55 +102,6 @@ export class OpsMaintenanceWorkflow extends WorkflowEntrypoint< } } -async function completeOrContinueWorkspaceReconciliation( - env: OpsWorkflowEnv, - payload: WorkspaceReconciliationPayload, - chunk: WorkspaceReconciliationChunk, - step: WorkflowStep, -): Promise { - if (chunk.evidence) { - return WorkspaceReconciliationWorkflowResultSchema.parse({ - continuationInstanceId: null, - evidence: chunk.evidence, - kind: "workspace-reconciliation", - ok: true, - }); - } - if (!chunk.continuation) { - throw new Error("Workspace reconciliation returned no evidence or continuation."); - } - const continuation = WorkspaceReconciliationPayloadSchema.parse(chunk.continuation); - if ( - continuation.releaseSha !== payload.releaseSha || - continuation.generation !== payload.generation + 1 - ) { - throw new Error("Workspace reconciliation continuation did not advance exactly once."); - } - const expectedId = workspaceReconciliationInstanceId(continuation); - const created = await step.do( - "enqueue workspace reconciliation continuation", - { - retries: { limit: 5, delay: "30 seconds", backoff: "exponential" }, - timeout: "2 minutes", - }, - () => - createDeterministicWorkflow(env.OPS_WORKFLOW, { - id: expectedId, - params: continuation, - retention: { errorRetention: "30 days", successRetention: "30 days" }, - }), - ); - if (created.id !== expectedId) { - throw new Error("Workspace reconciliation continuation identity changed during creation."); - } - return WorkspaceReconciliationWorkflowResultSchema.parse({ - continuationInstanceId: created.id, - evidence: null, - kind: "workspace-reconciliation", - ok: true, - }); -} - export async function enqueueAnalyticsWatchdog( env: OpsWorkflowBindings, scheduledTime: number, diff --git a/apps/webhooks-worker/src/webhook-idempotency-storage.ts b/apps/webhooks-worker/src/webhook-idempotency-storage.ts index 157c450f..746e33f5 100644 --- a/apps/webhooks-worker/src/webhook-idempotency-storage.ts +++ b/apps/webhooks-worker/src/webhook-idempotency-storage.ts @@ -1,49 +1,9 @@ import { assertExactSqliteSchema, - assertSqliteRowCountPreserved, type ExpectedSqliteObject, setCurrentSqliteStorageVersion, } from "@cheatcode/durable-storage"; -interface ExpectedColumn { - defaultValue: string | null; - isNotNull: boolean; - isPrimaryKey: boolean; - name: string; - type: string; -} - -const WEBHOOK_EVENT_COLUMNS = [ - column("event_key", "TEXT", true, true), - column("body_hash", "TEXT", true), - column("state", "TEXT", true), - column("workflow_id", "TEXT"), - column("created_at", "INTEGER", true), - column("updated_at", "INTEGER", true), - column("attempts", "INTEGER", true), - column("last_error", "TEXT"), - column("expires_at", "INTEGER", true), -] as const; - -const WEBHOOK_REQUIRED_COLUMNS = [ - "event_key", - "body_hash", - "state", - "workflow_id", - "created_at", - "expires_at", -] as const; - -const DAYTONA_STATE_COLUMNS = [ - column("sandbox_id", "TEXT", true, true), - column("updated_at", "INTEGER", true), - column("expires_at", "INTEGER", true), -] as const; - -const INTERNAL_COMMAND_COLUMNS = [ - column("command_id", "TEXT", true, true), - column("expires_at", "INTEGER", true), -] as const; const WEBHOOK_EVENT_TABLE_SQL = `CREATE TABLE webhook_event ( event_key TEXT PRIMARY KEY CHECK (length(event_key) BETWEEN 1 AND 530), body_hash TEXT NOT NULL CHECK (length(body_hash) = 64 AND body_hash NOT GLOB '*[^a-f0-9]*'), @@ -85,22 +45,14 @@ const WEBHOOK_STORAGE_SCHEMA: readonly ExpectedSqliteObject[] = [ }, ]; -/** Reconciles every dormant object to the one current persisted schema. */ +/** Initializes a new object on the current schema. */ export function initializeWebhookIdempotencyStorage(ctx: DurableObjectState): void { - reconcileWebhookEvents(ctx); - reconcileSimpleTable(ctx, "daytona_sandbox_state", DAYTONA_STATE_COLUMNS); - reconcileSimpleTable(ctx, "internal_command", INTERNAL_COMMAND_COLUMNS); - setCurrentSqliteStorageVersion(ctx); - assertWebhookIdempotencyStorage(ctx); -} - -/** Force-normalizes dormant webhook objects while provider ingress is closed. */ -export function reconcileWebhookIdempotencyStorage(ctx: DurableObjectState): void { - reconcileWebhookEvents(ctx); - reconcileSimpleTable(ctx, "daytona_sandbox_state", DAYTONA_STATE_COLUMNS); - reconcileSimpleTable(ctx, "internal_command", INTERNAL_COMMAND_COLUMNS); - ctx.storage.transactionSync(() => rebuildWebhookStorage(ctx)); - setCurrentSqliteStorageVersion(ctx); + ctx.storage.transactionSync(() => { + ctx.storage.sql.exec(WEBHOOK_EVENT_TABLE_SQL); + ctx.storage.sql.exec(DAYTONA_STATE_TABLE_SQL); + ctx.storage.sql.exec(INTERNAL_COMMAND_TABLE_SQL); + setCurrentSqliteStorageVersion(ctx); + }); assertWebhookIdempotencyStorage(ctx); } @@ -109,184 +61,5 @@ export function assertWebhookIdempotencyStorage(ctx: DurableObjectState): void { } export function hasWebhookIdempotencyStorage(ctx: DurableObjectState): boolean { - return tableColumns(ctx, "webhook_event").length > 0; -} - -function reconcileWebhookEvents(ctx: DurableObjectState): void { - const columns = tableColumns(ctx, "webhook_event"); - if (columns.length === 0) { - createWebhookEventTable(ctx, "webhook_event"); - return; - } - if (hasExactColumns(columns, WEBHOOK_EVENT_COLUMNS)) { - return; - } - if (!WEBHOOK_REQUIRED_COLUMNS.every((name) => hasColumn(columns, name))) { - throw new Error("Unsupported webhook_event schema; refusing lossy evolution."); - } - const updatedAt = timestampExpression(columns); - const attempts = hasColumn(columns, "attempts") - ? "CASE WHEN typeof(attempts) = 'integer' AND attempts > 0 THEN attempts ELSE 1 END" - : "1"; - const lastError = hasColumn(columns, "last_error") - ? "CASE WHEN last_error IS NULL OR typeof(last_error) = 'text' THEN last_error ELSE NULL END" - : "NULL"; - ctx.storage.transactionSync(() => { - ctx.storage.sql.exec("DROP TABLE IF EXISTS webhook_event_next"); - createWebhookEventTable(ctx, "webhook_event_next"); - ctx.storage.sql.exec( - `INSERT INTO webhook_event_next ( - event_key, body_hash, state, workflow_id, created_at, - updated_at, attempts, last_error, expires_at - ) - SELECT event_key, body_hash, state, workflow_id, created_at, - ${updatedAt}, ${attempts}, ${lastError}, expires_at - FROM webhook_event`, - ); - assertSqliteRowCountPreserved(ctx, "webhook_event", "webhook_event_next"); - ctx.storage.sql.exec("DROP TABLE webhook_event"); - ctx.storage.sql.exec("ALTER TABLE webhook_event_next RENAME TO webhook_event"); - }); -} - -function reconcileSimpleTable( - ctx: DurableObjectState, - table: "daytona_sandbox_state" | "internal_command", - expected: readonly ExpectedColumn[], -): void { - const columns = tableColumns(ctx, table); - if (columns.length === 0) { - createSimpleTable(ctx, table); - return; - } - if (hasExactColumns(columns, expected)) { - return; - } - if (!expected.every(({ name }) => hasColumn(columns, name))) { - throw new Error(`Unsupported ${table} schema; refusing lossy evolution.`); - } - const next = - table === "daytona_sandbox_state" ? "daytona_sandbox_state_next" : "internal_command_next"; - const names = expected.map(({ name }) => name).join(", "); - ctx.storage.transactionSync(() => { - ctx.storage.sql.exec(`DROP TABLE IF EXISTS ${next}`); - createSimpleTable(ctx, next); - ctx.storage.sql.exec(`INSERT INTO ${next} (${names}) SELECT ${names} FROM ${table}`); - assertSqliteRowCountPreserved(ctx, table, next); - ctx.storage.sql.exec(`DROP TABLE ${table}`); - ctx.storage.sql.exec(`ALTER TABLE ${next} RENAME TO ${table}`); - }); -} - -function createWebhookEventTable( - ctx: DurableObjectState, - table: "webhook_event" | "webhook_event_next", -): void { - ctx.storage.sql.exec( - WEBHOOK_EVENT_TABLE_SQL.replace("CREATE TABLE webhook_event", `CREATE TABLE ${table}`), - ); -} - -function createSimpleTable( - ctx: DurableObjectState, - table: - | "daytona_sandbox_state" - | "daytona_sandbox_state_next" - | "internal_command" - | "internal_command_next", -): void { - if (table.startsWith("daytona_sandbox_state")) { - ctx.storage.sql.exec( - DAYTONA_STATE_TABLE_SQL.replace( - "CREATE TABLE daytona_sandbox_state", - `CREATE TABLE ${table}`, - ), - ); - return; - } - ctx.storage.sql.exec( - INTERNAL_COMMAND_TABLE_SQL.replace("CREATE TABLE internal_command", `CREATE TABLE ${table}`), - ); -} - -function rebuildWebhookStorage(ctx: DurableObjectState): void { - const tables = ["webhook_event", "daytona_sandbox_state", "internal_command"] as const; - for (const table of tables) { - ctx.storage.sql.exec(`DROP TABLE IF EXISTS ${table}_next`); - ctx.storage.sql.exec(`DROP TABLE IF EXISTS ${table}_reconcile_source`); - ctx.storage.sql.exec(`ALTER TABLE ${table} RENAME TO ${table}_reconcile_source`); - } - ctx.storage.sql.exec(WEBHOOK_EVENT_TABLE_SQL); - ctx.storage.sql.exec(DAYTONA_STATE_TABLE_SQL); - ctx.storage.sql.exec(INTERNAL_COMMAND_TABLE_SQL); - ctx.storage.sql.exec( - `INSERT INTO webhook_event - (event_key, body_hash, state, workflow_id, created_at, - updated_at, attempts, last_error, expires_at) - SELECT event_key, body_hash, state, workflow_id, created_at, - updated_at, attempts, last_error, expires_at - FROM webhook_event_reconcile_source`, - ); - ctx.storage.sql.exec( - `INSERT INTO daytona_sandbox_state (sandbox_id, updated_at, expires_at) - SELECT sandbox_id, updated_at, expires_at FROM daytona_sandbox_state_reconcile_source`, - ); - ctx.storage.sql.exec( - `INSERT INTO internal_command (command_id, expires_at) - SELECT command_id, expires_at FROM internal_command_reconcile_source`, - ); - for (const table of tables) { - assertSqliteRowCountPreserved(ctx, `${table}_reconcile_source`, table); - ctx.storage.sql.exec(`DROP TABLE ${table}_reconcile_source`); - } -} - -function timestampExpression(columns: unknown[]): string { - if (hasColumn(columns, "updated_at")) { - return "CASE WHEN typeof(updated_at) = 'integer' THEN updated_at ELSE created_at END"; - } - if (hasColumn(columns, "processed_at")) { - return "CASE WHEN typeof(processed_at) = 'integer' THEN processed_at ELSE created_at END"; - } - return "created_at"; -} - -function tableColumns(ctx: DurableObjectState, table: string): unknown[] { - return ctx.storage.sql.exec(`PRAGMA table_info(${table})`).toArray(); -} - -function hasExactColumns(rows: unknown[], expected: readonly ExpectedColumn[]): boolean { - return ( - rows.length === expected.length && - expected.every((value, index) => { - const row = rows[index]; - return ( - isRecord(row) && - row["cid"] === index && - row["name"] === value.name && - row["type"] === value.type && - row["notnull"] === Number(value.isNotNull) && - row["pk"] === Number(value.isPrimaryKey) && - row["dflt_value"] === value.defaultValue - ); - }) - ); -} - -function hasColumn(rows: unknown[], name: string): boolean { - return rows.some((row) => isRecord(row) && row["name"] === name); -} - -function column( - name: string, - type: string, - isNotNull = false, - isPrimaryKey = false, - defaultValue: string | null = null, -): ExpectedColumn { - return { defaultValue, isNotNull, isPrimaryKey, name, type }; -} - -function isRecord(value: unknown): value is Record { - return typeof value === "object" && value !== null; + return ctx.storage.sql.exec("PRAGMA table_info(webhook_event)").toArray().length > 0; } diff --git a/apps/webhooks-worker/src/webhook-idempotency.ts b/apps/webhooks-worker/src/webhook-idempotency.ts index 14885e01..88b12707 100644 --- a/apps/webhooks-worker/src/webhook-idempotency.ts +++ b/apps/webhooks-worker/src/webhook-idempotency.ts @@ -1,14 +1,5 @@ import { DurableObject } from "cloudflare:workers"; -import { - assertStorageReconciliationRequest, - reconcileExactSqliteStorage, - storageSchemaEvidence, -} from "@cheatcode/durable-storage"; import { APIError, readBoundedResponseJson, readJsonRequest } from "@cheatcode/observability"; -import type { - InternalDurableObjectStorageRequest, - InternalDurableObjectStorageResponse, -} from "@cheatcode/types"; import { z } from "zod"; import { assertReleaseOpen, @@ -20,7 +11,6 @@ import { assertWebhookIdempotencyStorage, hasWebhookIdempotencyStorage, initializeWebhookIdempotencyStorage, - reconcileWebhookIdempotencyStorage, } from "./webhook-idempotency-storage"; const WEBHOOK_TTL_MS = 7 * 24 * 60 * 60 * 1000; @@ -194,24 +184,6 @@ interface WebhookIdempotencyEnv extends ReleaseGateBindings { export class WebhookIdempotencyStore extends DurableObject { private isStorageInitialized = false; - public reconcileStorageSchema( - value: InternalDurableObjectStorageRequest, - ): InternalDurableObjectStorageResponse { - const input = assertStorageReconciliationRequest( - this.ctx, - this.env, - value, - "WebhookIdempotencyStore", - ); - reconcileExactSqliteStorage( - input.mode, - () => assertWebhookIdempotencyStorage(this.ctx), - () => reconcileWebhookIdempotencyStorage(this.ctx), - ); - this.isStorageInitialized = true; - return storageSchemaEvidence(input); - } - public override async fetch(request: Request): Promise { if (this.env.CHEATCODE_RELEASE_GATE === "closed") { const response = releaseGateError("closed").toResponse( diff --git a/apps/webhooks-worker/src/workspace-reconciliation.ts b/apps/webhooks-worker/src/workspace-reconciliation.ts deleted file mode 100644 index c11dcf66..00000000 --- a/apps/webhooks-worker/src/workspace-reconciliation.ts +++ /dev/null @@ -1,468 +0,0 @@ -import type { WorkflowStep } from "cloudflare:workers"; -import { createHash } from "node:crypto"; -import { - applyCanonicalWorkspaceTransition, - createDb, - type Database, - type HyperdriveConnection, - listWorkspaceTransitionOwnerIdPage, - loadWorkspaceTransitionOwner, -} from "@cheatcode/db"; -import type { WorkerSecret } from "@cheatcode/env"; -import { createLogger } from "@cheatcode/observability"; -import { UserId } from "@cheatcode/types"; -import { z } from "zod"; -import { requireAgentLifecycleSecret } from "./internal-maintenance"; -import { type AgentStateDeletionEnv, reconcileUserAgentWorkspaces } from "./lifecycle-adapters"; - -const OWNER_PAGE_SIZE = 50; -const OWNER_PAGES_PER_GENERATION = 40; -const DB_STEP_OPTIONS = { - retries: { limit: 5, delay: "20 seconds", backoff: "exponential" }, - timeout: "2 minutes", -} as const; -const AGENT_STEP_OPTIONS = { - retries: { limit: 5, delay: "30 seconds", backoff: "exponential" }, - timeout: "10 minutes", -} as const; -const ReleaseShaSchema = z.string().regex(/^[0-9a-f]{40}$/u); -const OwnerIdPageSchema = z - .object({ - nextCursor: z.string().uuid().nullable(), - ownerIds: z.array(z.string().uuid()).max(OWNER_PAGE_SIZE), - }) - .strict(); - -export interface WorkspaceReconciliationEnv extends AgentStateDeletionEnv { - CHEATCODE_RELEASE_SHA?: string; - DATABASE_CONTEXT_SIGNING_SECRET_WEBHOOKS: WorkerSecret; - HYPERDRIVE: HyperdriveConnection; -} - -const WorkspaceReconciliationEvidenceSchema = z - .object({ - canonicalDigest: z.string().regex(/^[0-9a-f]{64}$/u), - canonicalWorkspaces: z.number().int().nonnegative(), - owners: z.number().int().nonnegative(), - processPortReservationsRemoved: z.number().int().nonnegative(), - processRecordsRemoved: z.number().int().nonnegative(), - projectPortsRemoved: z.number().int().nonnegative(), - releaseSha: ReleaseShaSchema, - rowsUpdated: z.number().int().nonnegative(), - sandboxDigest: z.string().regex(/^[0-9a-f]{64}$/u), - sandboxesAbsent: z.number().int().nonnegative(), - sandboxesCurrent: z.number().int().nonnegative(), - sandboxesUpgraded: z.number().int().nonnegative(), - targetSnapshot: z.string().min(1).nullable(), - }) - .strict() - .superRefine((evidence, context) => { - const sandboxOwners = - evidence.sandboxesAbsent + evidence.sandboxesCurrent + evidence.sandboxesUpgraded; - if (sandboxOwners !== evidence.owners) { - context.addIssue({ code: "custom", message: "Sandbox evidence does not cover every owner." }); - } - if ((evidence.owners === 0) !== (evidence.targetSnapshot === null)) { - context.addIssue({ code: "custom", message: "Snapshot target and owner evidence disagree." }); - } - }); - -type WorkspaceReconciliationEvidence = z.infer; - -const PendingOwnerEvidenceSchema = z - .object({ - canonicalDigest: z.string().regex(/^[0-9a-f]{64}$/u), - canonicalWorkspaces: z.number().int().nonnegative(), - ownerId: z.string().uuid(), - processPortReservationsRemoved: z.number().int().nonnegative(), - processRecordsRemoved: z.number().int().nonnegative(), - projectPortsRemoved: z.number().int().nonnegative(), - rowsUpdated: z.number().int().nonnegative(), - }) - .strict(); -type PendingOwnerEvidence = z.infer; - -export const WorkspaceReconciliationPayloadSchema = z - .object({ - cursor: z.string().uuid().nullable(), - evidence: WorkspaceReconciliationEvidenceSchema.nullable(), - generation: z.number().int().nonnegative(), - kind: z.literal("workspace-reconciliation"), - pendingOwner: PendingOwnerEvidenceSchema.nullable(), - releaseSha: ReleaseShaSchema, - }) - .strict() - .superRefine((payload, context) => { - const isInitial = payload.generation === 0; - if ( - isInitial !== - (payload.cursor === null && payload.evidence === null && payload.pendingOwner === null) - ) { - context.addIssue({ - code: "custom", - message: "Only generation zero may start without reconciliation progress.", - }); - } - if (payload.evidence && payload.evidence.releaseSha !== payload.releaseSha) { - context.addIssue({ code: "custom", message: "Reconciliation evidence changed release." }); - } - }); - -export type WorkspaceReconciliationPayload = z.infer; - -export const WorkspaceReconciliationWorkflowResultSchema = z - .object({ - continuationInstanceId: z.string().min(1).max(100).nullable(), - evidence: WorkspaceReconciliationEvidenceSchema.nullable(), - kind: z.literal("workspace-reconciliation"), - ok: z.literal(true), - }) - .strict() - .refine( - (result) => (result.evidence === null) !== (result.continuationInstanceId === null), - "A reconciliation generation must either continue or produce final evidence.", - ); - -export type WorkspaceReconciliationWorkflowResult = z.infer< - typeof WorkspaceReconciliationWorkflowResultSchema ->; - -export interface WorkspaceReconciliationChunk { - continuation: WorkspaceReconciliationPayload | null; - evidence: WorkspaceReconciliationEvidence | null; -} - -export async function reconcileCanonicalWorkspaces( - env: WorkspaceReconciliationEnv, - payloadInput: WorkspaceReconciliationPayload, - step: WorkflowStep, -): Promise { - const payload = WorkspaceReconciliationPayloadSchema.parse(payloadInput); - assertReleaseIdentity(env, payload.releaseSha); - const agentLifecycleSecret = await requireAgentLifecycleSecret(env); - return reconcileWorkspaceGeneration(env, payload, step, agentLifecycleSecret); -} - -async function reconcileWorkspaceGeneration( - env: WorkspaceReconciliationEnv, - payload: WorkspaceReconciliationPayload, - step: WorkflowStep, - agentLifecycleSecret: string, -): Promise { - const evidence = payload.evidence - ? WorkspaceReconciliationEvidenceSchema.parse({ ...payload.evidence }) - : emptyEvidence(payload.releaseSha); - let cursor = payload.cursor ?? undefined; - let pendingOwner = payload.pendingOwner; - for (let page = 1; page <= OWNER_PAGES_PER_GENERATION; page += 1) { - const pageCursor = cursor; - const ownerPage = await loadOwnerIdPage(env, step, pageCursor, page); - for (const [index, ownerId] of ownerPage.ownerIds.entries()) { - const label = `${payload.generation}.${page}.${index + 1}`; - if (pendingOwner && pendingOwner.ownerId !== ownerId) { - throw new Error("Pending sandbox owner does not match the reconciliation cursor."); - } - const owner = await reconcileWorkspaceOwner( - env, - payload.releaseSha, - step, - ownerId, - label, - pendingOwner, - agentLifecycleSecret, - ); - if (!owner.snapshot.complete) { - return continuationChunk( - payload, - cursor ?? null, - evidence, - pendingOwnerEvidence(ownerId, owner), - ); - } - mergeOwnerEvidence(evidence, ownerId, owner); - pendingOwner = null; - cursor = ownerId; - } - assertCursorAdvanced(pageCursor, ownerPage.nextCursor); - if (!ownerPage.nextCursor) { - return completedChunk(await recordWorkspaceEvidence(evidence, step)); - } - cursor = ownerPage.nextCursor; - } - return { - continuation: WorkspaceReconciliationPayloadSchema.parse({ - cursor, - evidence, - generation: payload.generation + 1, - kind: "workspace-reconciliation", - pendingOwner: null, - releaseSha: payload.releaseSha, - }), - evidence: null, - }; -} - -async function loadOwnerIdPage( - env: WorkspaceReconciliationEnv, - step: WorkflowStep, - cursor: string | undefined, - page: number, -) { - const value = await step.do(`load workspace owner ids page ${page}`, DB_STEP_OPTIONS, () => - withDatabase(env, (db) => - listWorkspaceTransitionOwnerIdPage(db, { - ...(cursor ? { cursor: UserId(cursor) } : {}), - limit: OWNER_PAGE_SIZE, - }), - ), - ); - return OwnerIdPageSchema.parse(value); -} - -async function reconcileWorkspaceOwner( - env: WorkspaceReconciliationEnv, - releaseSha: string, - step: WorkflowStep, - ownerId: string, - label: string, - pendingOwner: PendingOwnerEvidence | null, - agentLifecycleSecret: string, -) { - const userId = UserId(ownerId); - if (pendingOwner) { - const finalized = await finalizeWorkspaceOwner( - env, - releaseSha, - step, - userId, - label, - agentLifecycleSecret, - ); - return { ...pendingOwner, snapshot: finalized.snapshot }; - } - const prepared = await step.do( - `prepare workspace owner ${label}`, - AGENT_STEP_OPTIONS, - async () => { - const owner = await requireWorkspaceOwner(env, userId); - return reconcileUserAgentWorkspaces( - env, - userId, - { - phase: "prepare", - projects: owner.projects, - releaseSha, - }, - agentLifecycleSecret, - ); - }, - ); - const update = await step.do(`commit workspace owner ${label}`, DB_STEP_OPTIONS, async () => { - const owner = await requireWorkspaceOwner(env, userId); - return withDatabase(env, (db) => - applyCanonicalWorkspaceTransition(db, { projects: owner.projects, userId }), - ); - }); - const finalized = await finalizeWorkspaceOwner( - env, - releaseSha, - step, - userId, - label, - agentLifecycleSecret, - ); - return { - ...prepared, - canonicalWorkspaces: prepared.canonicalWorkspaceCount, - rowsUpdated: update.updated, - snapshot: finalized.snapshot, - }; -} - -function finalizeWorkspaceOwner( - env: WorkspaceReconciliationEnv, - releaseSha: string, - step: WorkflowStep, - userId: UserId, - label: string, - agentLifecycleSecret: string, -) { - return step.do(`finalize workspace owner ${label}`, AGENT_STEP_OPTIONS, async () => { - const owner = await requireWorkspaceOwner(env, userId); - return reconcileUserAgentWorkspaces( - env, - userId, - { - phase: "finalize", - projects: owner.projects, - releaseSha, - }, - agentLifecycleSecret, - ); - }); -} - -function pendingOwnerEvidence( - ownerId: string, - owner: Awaited>, -): PendingOwnerEvidence { - return PendingOwnerEvidenceSchema.parse({ - canonicalDigest: owner.canonicalDigest, - canonicalWorkspaces: owner.canonicalWorkspaces, - ownerId, - processPortReservationsRemoved: owner.processPortReservationsRemoved, - processRecordsRemoved: owner.processRecordsRemoved, - projectPortsRemoved: owner.projectPortsRemoved, - rowsUpdated: owner.rowsUpdated, - }); -} - -async function requireWorkspaceOwner(env: WorkspaceReconciliationEnv, userId: UserId) { - const owner = await withDatabase(env, (db) => loadWorkspaceTransitionOwner(db, userId)); - if (!owner) { - throw new Error("Workspace owner disappeared during the closed reconciliation window."); - } - return owner; -} - -function mergeOwnerEvidence( - evidence: WorkspaceReconciliationEvidence, - ownerId: string, - owner: Awaited>, -): void { - evidence.canonicalDigest = extendDigest( - evidence.canonicalDigest, - `${ownerId}:${owner.canonicalDigest}`, - ); - evidence.owners += 1; - evidence.canonicalWorkspaces += owner.canonicalWorkspaces; - evidence.processPortReservationsRemoved += owner.processPortReservationsRemoved; - evidence.processRecordsRemoved += owner.processRecordsRemoved; - evidence.projectPortsRemoved += owner.projectPortsRemoved; - evidence.rowsUpdated += owner.rowsUpdated; - mergeSnapshotEvidence(evidence, ownerId, owner.snapshot); -} - -function mergeSnapshotEvidence( - evidence: WorkspaceReconciliationEvidence, - ownerId: string, - snapshot: Awaited>["snapshot"], -): void { - if (!snapshot.complete || snapshot.status === "upgrading") { - throw new Error("Incomplete sandbox snapshot evidence cannot be recorded."); - } - if (evidence.targetSnapshot && evidence.targetSnapshot !== snapshot.targetSnapshot) { - throw new Error("Sandbox snapshot target changed during release reconciliation."); - } - evidence.targetSnapshot = snapshot.targetSnapshot; - evidence.sandboxDigest = extendDigest( - evidence.sandboxDigest, - [ - ownerId, - snapshot.status, - snapshot.targetSnapshot, - snapshot.upgradeId, - snapshot.workspaceDigest, - ].join(":"), - ); - if (snapshot.status === "absent") evidence.sandboxesAbsent += 1; - if (snapshot.status === "current") evidence.sandboxesCurrent += 1; - if (snapshot.status === "upgraded") evidence.sandboxesUpgraded += 1; -} - -async function recordWorkspaceEvidence( - evidence: WorkspaceReconciliationEvidence, - step: WorkflowStep, -): Promise { - const verified = WorkspaceReconciliationEvidenceSchema.parse(evidence); - const recorded = await step.do( - "record workspace and sandbox reconciliation evidence", - DB_STEP_OPTIONS, - async () => verified, - ); - createLogger().info("workspace_sandbox_reconciliation_completed", { ...recorded }); - return WorkspaceReconciliationEvidenceSchema.parse(recorded); -} - -async function withDatabase( - env: WorkspaceReconciliationEnv, - operation: (db: Database) => Promise, -): Promise { - const { db, close } = createDb(env.HYPERDRIVE, { - audience: "app_webhooks", - signingSecret: env.DATABASE_CONTEXT_SIGNING_SECRET_WEBHOOKS, - }); - try { - return await operation(db); - } finally { - await close(); - } -} - -function assertReleaseIdentity(env: WorkspaceReconciliationEnv, releaseSha: string): void { - if (env.CHEATCODE_RELEASE_SHA !== releaseSha) { - throw new Error("Webhooks release does not match workspace reconciliation request."); - } -} - -function assertCursorAdvanced(previous: string | undefined, next: string | null): void { - if (next && next === previous) { - throw new Error("Workspace owner cursor did not advance."); - } -} - -function completedChunk(evidence: WorkspaceReconciliationEvidence): WorkspaceReconciliationChunk { - return { continuation: null, evidence }; -} - -function continuationChunk( - payload: WorkspaceReconciliationPayload, - cursor: string | null, - evidence: WorkspaceReconciliationEvidence, - pendingOwner: PendingOwnerEvidence, -): WorkspaceReconciliationChunk { - return { - continuation: WorkspaceReconciliationPayloadSchema.parse({ - cursor, - evidence, - generation: payload.generation + 1, - kind: "workspace-reconciliation", - pendingOwner, - releaseSha: payload.releaseSha, - }), - evidence: null, - }; -} - -function emptyEvidence(releaseSha: string): WorkspaceReconciliationEvidence { - return { - canonicalDigest: createHash("sha256").digest("hex"), - canonicalWorkspaces: 0, - owners: 0, - processPortReservationsRemoved: 0, - processRecordsRemoved: 0, - projectPortsRemoved: 0, - releaseSha, - rowsUpdated: 0, - sandboxDigest: createHash("sha256").digest("hex"), - sandboxesAbsent: 0, - sandboxesCurrent: 0, - sandboxesUpgraded: 0, - targetSnapshot: null, - }; -} - -function extendDigest(previous: string, entry: string): string { - return createHash("sha256").update(previous).update("\n").update(entry).digest("hex"); -} - -export function workspaceReconciliationInstanceId( - payloadInput: WorkspaceReconciliationPayload, -): string { - const payload = WorkspaceReconciliationPayloadSchema.parse(payloadInput); - const instanceId = `workspace-sandboxes-${payload.releaseSha}-${payload.generation}`; - if (instanceId.length > 100) { - throw new Error("Workspace reconciliation Workflow identity is too long."); - } - return instanceId; -} diff --git a/compose.yaml b/compose.yaml index d98331fd..666e55d7 100644 --- a/compose.yaml +++ b/compose.yaml @@ -30,7 +30,6 @@ services: - .turbo/ - .vercel/ - .wrangler/ - - infra/supabase/migrations/ - package.json - packages/db/drizzle/ - pnpm-lock.yaml @@ -41,9 +40,6 @@ services: - "**/dist/" - "**/node_modules/" - node_modules/ - - action: sync+restart - path: infra/supabase/migrations - target: /workspace/infra/supabase/migrations - action: sync+restart path: packages/db/drizzle target: /workspace/packages/db/drizzle diff --git a/infra/containers/sandbox/app-generators/package-lock.json b/infra/containers/sandbox/app-generators/package-lock.json index 4436818d..ca0df9fa 100644 --- a/infra/containers/sandbox/app-generators/package-lock.json +++ b/infra/containers/sandbox/app-generators/package-lock.json @@ -8,16 +8,16 @@ "name": "@cheatcode/sandbox-app-generators", "version": "0.0.0", "dependencies": { - "create-next-app": "16.2.10" + "create-next-app": "16.2.11" }, "engines": { "node": "22.22.2" } }, "node_modules/create-next-app": { - "version": "16.2.10", - "resolved": "https://registry.npmjs.org/create-next-app/-/create-next-app-16.2.10.tgz", - "integrity": "sha512-Hm/vtawpvcBcXoz3aHUVV5y70AU8SbjPRUVbGUFpYARUbekfzEjPCeNfhUBxl2qC6Y1v9zFTVQ3wHokYBEP4MQ==", + "version": "16.2.11", + "resolved": "https://registry.npmjs.org/create-next-app/-/create-next-app-16.2.11.tgz", + "integrity": "sha512-HNqxzvt83W6f1EXVDqbtVwiTDHfXyf70tqVQ120M854RDPj/TyLpvAPX6C1rK3jbKyQ8hF77xa7vfE2/ZW3F3w==", "license": "MIT", "bin": { "create-next-app": "dist/index.js" diff --git a/infra/containers/sandbox/app-generators/package.json b/infra/containers/sandbox/app-generators/package.json index 6ebee8b3..23a6b7ad 100644 --- a/infra/containers/sandbox/app-generators/package.json +++ b/infra/containers/sandbox/app-generators/package.json @@ -6,6 +6,6 @@ "node": "22.22.2" }, "dependencies": { - "create-next-app": "16.2.10" + "create-next-app": "16.2.11" } } diff --git a/infra/containers/sandbox/app-templates/next/package.json b/infra/containers/sandbox/app-templates/next/package.json index 0c0f8e26..908c0e1c 100644 --- a/infra/containers/sandbox/app-templates/next/package.json +++ b/infra/containers/sandbox/app-templates/next/package.json @@ -14,7 +14,7 @@ "format": "biome format --write" }, "dependencies": { - "next": "16.2.10", + "next": "16.2.11", "react": "19.2.7", "react-dom": "19.2.7" }, diff --git a/infra/containers/sandbox/app-templates/next/pnpm-lock.yaml b/infra/containers/sandbox/app-templates/next/pnpm-lock.yaml index 973eb642..3982e979 100644 --- a/infra/containers/sandbox/app-templates/next/pnpm-lock.yaml +++ b/infra/containers/sandbox/app-templates/next/pnpm-lock.yaml @@ -5,7 +5,7 @@ settings: excludeLinksFromLockfile: false overrides: - postcss@<8.5.10: 8.5.15 + postcss@<8.5.18: 8.5.18 sharp@<0.35.0: 0.35.0 importers: @@ -13,8 +13,8 @@ importers: .: dependencies: next: - specifier: 16.2.10 - version: 16.2.10(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + specifier: 16.2.11 + version: 16.2.11(react-dom@19.2.7(react@19.2.7))(react@19.2.7) react: specifier: 19.2.7 version: 19.2.7 @@ -288,57 +288,57 @@ packages: '@jridgewell/trace-mapping@0.3.31': resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} - '@next/env@16.2.10': - resolution: {integrity: sha512-zLPxg9M0MEHmygpj5OuxjQ+vHMiy/K7cSp74G8ecYolmgUWw0RwN02tF56npup/+qaI8JB97hQgS/r2Hb6QwVA==} + '@next/env@16.2.11': + resolution: {integrity: sha512-0do5A3BJ2gxWr0ZCMcD6BhW+e595jyxdTl3rXTS6lOtD8ektMiW6CO+EPwt1Eca1DBnm90r/7GdiKWBKxH++DA==} - '@next/swc-darwin-arm64@16.2.10': - resolution: {integrity: sha512-v9IdJCa0H0mbo+8z5zwUpOk1Vj7RjkcI5uNYf5Ws1y6szf/p3Mzl9hLaST8SCt6L9h8NGnruZcd2+o0NTNwDhA==} + '@next/swc-darwin-arm64@16.2.11': + resolution: {integrity: sha512-wryL4pjKmDwGv2ox6+GZDFxvmtSRLqApBR8kL1j4+vhB7Z5vJC/zAnXpiR9Xkfzl0AS8WLMnsuGV/UKI67/rrw==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@next/swc-darwin-x64@16.2.10': - resolution: {integrity: sha512-17IS0jJRViROGmA9uGdNR8VPJpfbnaVG7E9qhso5jDLkmyd0lSDORWxbcKINzcFqzZqGwGtMSnrFRxBpuUYjLQ==} + '@next/swc-darwin-x64@16.2.11': + resolution: {integrity: sha512-aZl2j4f/fLyjQvOhv0Oe9UaMAQHolYpKhctsoYzplSumKJKPUmgjcf6545aBtysLTcu994TREd0+pSgNE4ohmg==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@next/swc-linux-arm64-gnu@16.2.10': - resolution: {integrity: sha512-GRQRsRtuciNJvB54AvvuQTiq0oZtFwa1owQqtZD8wwnGpM2L39MV22kpI72YSXLKIyY40LC66EiLFv4PiicXxg==} + '@next/swc-linux-arm64-gnu@16.2.11': + resolution: {integrity: sha512-5jEriyEnH/LWFy27L2ZG0XaLlyEJIjhsImEsiS9P563PKEVp2BVups/xfOucIrsvVntp11oNcZwjHvaDPYVB5g==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [glibc] - '@next/swc-linux-arm64-musl@16.2.10': - resolution: {integrity: sha512-zkN9MQYS7UQBro+FnISUq1itaQjXI9xqISzuQ+2bc921NcJ1x4yPCqrn77tVN6/dOOXaaWVX3k6/bR07pPwK+A==} + '@next/swc-linux-arm64-musl@16.2.11': + resolution: {integrity: sha512-eIjcpx2fnnFSSkZDbTxy74KnokUXDjfoLClpWelfgHLf621aTqswhwXQ7GkD5K5rplrS6LZ/Bj+mVuvzluBOEg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [musl] - '@next/swc-linux-x64-gnu@16.2.10': - resolution: {integrity: sha512-iCVJnwvrPYECvA6WM/7+oo+OiTvedIKLxtCLAZP4xZR3nXa1zmzZyLPbYCmWvpd4CvMYF1EMTafd0ii3DygLvA==} + '@next/swc-linux-x64-gnu@16.2.11': + resolution: {integrity: sha512-8WgzpaWMs46qJT9kiV47cje86L0x/Mu9t8/Gwj+pnbgW3rETVfCnaScPjlYUwNScpOozdcIMHWmAvuZJUonR2w==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [glibc] - '@next/swc-linux-x64-musl@16.2.10': - resolution: {integrity: sha512-ov2g4H0dHY9bPoOU83m91hWT7Iq5qy13bUnyyshLU3HGR1Ownn0X9QpmDPc5iIUaahTp7f7LeGAhV4DSFtackw==} + '@next/swc-linux-x64-musl@16.2.11': + resolution: {integrity: sha512-I3UgPds7G4ZYnTb/H+5GBGuUT2DhAk6j0mL6A4s63RjFs74wB2hOWP0vaxsK+3NJraExt3eYEPQ/UtT0x/64Nw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [musl] - '@next/swc-win32-arm64-msvc@16.2.10': - resolution: {integrity: sha512-DwAnhLX76HQiFFQNgWlcK+JzlnD1rZ+UK/WY0ZMI/deXpvgnesjNYrqcfo1JzBuz4Kf7o3brIBL0glI1junatA==} + '@next/swc-win32-arm64-msvc@16.2.11': + resolution: {integrity: sha512-n89CjtcThnjrwgJMAiI5xbqwLY51zvwC9tSlArmVndAJLYVl9T9UAdlkXTmZvE++idoXe8KdglQlhNRdUp1c6g==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@next/swc-win32-x64-msvc@16.2.10': - resolution: {integrity: sha512-0JXq3b85Jk9Jg4ntLUbXSPvoDw3gpZou7twuKdoFG2jOw635v7+IiXfTaa0TxVMyx78pUjnrVYwLgjKfX4e6/A==} + '@next/swc-win32-x64-msvc@16.2.11': + resolution: {integrity: sha512-md8CLNggS1Dx9pUgApzps5uAf+N8GN9xywzmNx9vHAWo94HtBwCCqkSnhIrdfQe83Dhz8Lfo/20Nb1Zxal092w==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -560,8 +560,8 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - next@16.2.10: - resolution: {integrity: sha512-2som5AVXb3kE6Yjine3/mNbBayYF58eguBWIVVUdr1y/L426xyVEgYxgBG+1QC34P2x5E+tcDup6XkuOAX3dCA==} + next@16.2.11: + resolution: {integrity: sha512-B339zaqbyK8cmxhoAvLrcwoabwCP1wz21zSzfqxqXAemTu2BXnH7tQnfcglKv1vnMUIDBc+Hth7XODQriTZiRQ==} engines: {node: '>=20.9.0'} hasBin: true peerDependencies: @@ -584,8 +584,8 @@ packages: picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} - postcss@8.5.15: - resolution: {integrity: sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==} + postcss@8.5.18: + resolution: {integrity: sha512-xdB1oSLHbz1vRWgCDalrCqEFTWzFlhqFC5tIHLMOSUIjhm3XXQ1qrFy8S/ESr1JYRRXqM3c1QFiMZUJdUTqyMQ==} engines: {node: ^10 || ^12 || >=14} react-dom@19.2.7: @@ -814,30 +814,30 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.5 - '@next/env@16.2.10': {} + '@next/env@16.2.11': {} - '@next/swc-darwin-arm64@16.2.10': + '@next/swc-darwin-arm64@16.2.11': optional: true - '@next/swc-darwin-x64@16.2.10': + '@next/swc-darwin-x64@16.2.11': optional: true - '@next/swc-linux-arm64-gnu@16.2.10': + '@next/swc-linux-arm64-gnu@16.2.11': optional: true - '@next/swc-linux-arm64-musl@16.2.10': + '@next/swc-linux-arm64-musl@16.2.11': optional: true - '@next/swc-linux-x64-gnu@16.2.10': + '@next/swc-linux-x64-gnu@16.2.11': optional: true - '@next/swc-linux-x64-musl@16.2.10': + '@next/swc-linux-x64-musl@16.2.11': optional: true - '@next/swc-win32-arm64-msvc@16.2.10': + '@next/swc-win32-arm64-msvc@16.2.11': optional: true - '@next/swc-win32-x64-msvc@16.2.10': + '@next/swc-win32-x64-msvc@16.2.11': optional: true '@swc/helpers@0.5.15': @@ -910,7 +910,7 @@ snapshots: '@alloc/quick-lru': 5.2.0 '@tailwindcss/node': 4.3.2 '@tailwindcss/oxide': 4.3.2 - postcss: 8.5.15 + postcss: 8.5.18 tailwindcss: 4.3.2 '@types/node@22.20.1': @@ -999,25 +999,25 @@ snapshots: nanoid@3.3.16: {} - next@16.2.10(react-dom@19.2.7(react@19.2.7))(react@19.2.7): + next@16.2.11(react-dom@19.2.7(react@19.2.7))(react@19.2.7): dependencies: - '@next/env': 16.2.10 + '@next/env': 16.2.11 '@swc/helpers': 0.5.15 baseline-browser-mapping: 2.10.43 caniuse-lite: 1.0.30001805 - postcss: 8.5.15 + postcss: 8.5.18 react: 19.2.7 react-dom: 19.2.7(react@19.2.7) styled-jsx: 5.1.6(react@19.2.7) optionalDependencies: - '@next/swc-darwin-arm64': 16.2.10 - '@next/swc-darwin-x64': 16.2.10 - '@next/swc-linux-arm64-gnu': 16.2.10 - '@next/swc-linux-arm64-musl': 16.2.10 - '@next/swc-linux-x64-gnu': 16.2.10 - '@next/swc-linux-x64-musl': 16.2.10 - '@next/swc-win32-arm64-msvc': 16.2.10 - '@next/swc-win32-x64-msvc': 16.2.10 + '@next/swc-darwin-arm64': 16.2.11 + '@next/swc-darwin-x64': 16.2.11 + '@next/swc-linux-arm64-gnu': 16.2.11 + '@next/swc-linux-arm64-musl': 16.2.11 + '@next/swc-linux-x64-gnu': 16.2.11 + '@next/swc-linux-x64-musl': 16.2.11 + '@next/swc-win32-arm64-msvc': 16.2.11 + '@next/swc-win32-x64-msvc': 16.2.11 sharp: 0.35.0 transitivePeerDependencies: - '@babel/core' @@ -1025,7 +1025,7 @@ snapshots: picocolors@1.1.1: {} - postcss@8.5.15: + postcss@8.5.18: dependencies: nanoid: 3.3.16 picocolors: 1.1.1 diff --git a/infra/containers/sandbox/app-templates/next/pnpm-workspace.yaml b/infra/containers/sandbox/app-templates/next/pnpm-workspace.yaml index a2ca4d9c..03e7c3dd 100644 --- a/infra/containers/sandbox/app-templates/next/pnpm-workspace.yaml +++ b/infra/containers/sandbox/app-templates/next/pnpm-workspace.yaml @@ -5,5 +5,5 @@ allowBuilds: sharp: false overrides: - 'postcss@<8.5.10': 8.5.15 + 'postcss@<8.5.18': 8.5.18 'sharp@<0.35.0': 0.35.0 diff --git a/infra/supabase/migrations/drizzle-ledger-exceptions.json b/infra/supabase/migrations/drizzle-ledger-exceptions.json deleted file mode 100644 index c6e32e18..00000000 --- a/infra/supabase/migrations/drizzle-ledger-exceptions.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "packages/db/drizzle/0006_dashing_magneto.sql": { - "databaseSha256": "4bb1acdcb8fb931db0d03cdfc1d0946f5607b19fcfc566416dd73a7e2b685b05", - "reason": "The applied blob omitted the terminal newline required by repository formatting; both byte identities are pinned.", - "sourceSha256": "7ea1401c85ee4459c361afb060be60adb61dd8c88dab11cea886e5d8ed3e6cd2" - }, - "packages/db/drizzle/0016_early_cargill.sql": { - "databaseSha256": "24d53786bae1900dc688441e6c2de53a005f31cee6ae2c775c9b2dd54f60fbee", - "reason": "The original applied SQL blob is unavailable; pin both observed identities so any further drift fails closed.", - "sourceSha256": "716a7cd8752b0d54066b9c510f4a33d349a68fcd292e6a37997a0831f32bc536" - }, - "packages/db/drizzle/0046_dry_jubilee.sql": { - "databaseSha256": "e5c1de5c849882dc8b8bc19c97659f1e5bb66fc3ab627ed31306480d3ff5f598", - "reason": "The applied blob omitted the terminal newline required by repository formatting; both byte identities are pinned.", - "sourceSha256": "d33a7ae25c1f34e73faaa4303083a7efb3722458aa425d3be42fde2c9d53f4f6" - } -} diff --git a/infra/supabase/migrations/post/0010_indexes.sql b/infra/supabase/migrations/post/0010_indexes.sql deleted file mode 100644 index 73dcd077..00000000 --- a/infra/supabase/migrations/post/0010_indexes.sql +++ /dev/null @@ -1,8 +0,0 @@ -create index if not exists v2_projects_user_created_idx on v2_projects (user_id, created_at desc) where deleted_at is null; -create index if not exists v2_threads_user_project_created_idx on v2_threads (user_id, project_id, created_at desc) where deleted_at is null; -create index if not exists v2_messages_thread_created_idx on v2_messages (thread_id, created_at); -create index if not exists v2_agent_runs_thread_started_idx on v2_agent_runs (thread_id, started_at desc); -create unique index if not exists v2_provider_keys_user_provider_idx on v2_provider_keys (user_id, provider) where deleted_at is null; -create index if not exists v2_generated_outputs_user_created_idx on v2_generated_outputs (user_id, created_at desc); -create index if not exists v2_usage_events_user_created_idx on v2_usage_events (user_id, created_at desc); -create index if not exists v2_audit_log_user_created_idx on v2_audit_log (user_id, created_at desc); diff --git a/infra/supabase/migrations/post/0011_triggers.sql b/infra/supabase/migrations/post/0011_triggers.sql deleted file mode 100644 index cbb58c67..00000000 --- a/infra/supabase/migrations/post/0011_triggers.sql +++ /dev/null @@ -1,39 +0,0 @@ -create or replace function public.v2_touch_updated_at() returns trigger -language plpgsql -set search_path = '' -as $$ -begin - new.updated_at := pg_catalog.now(); - return new; -end -$$; - -create trigger trg_v2_users_updated before update on v2_users - for each row execute function public.v2_touch_updated_at(); -create trigger trg_v2_projects_updated before update on v2_projects - for each row execute function public.v2_touch_updated_at(); -create trigger trg_v2_threads_updated before update on v2_threads - for each row execute function public.v2_touch_updated_at(); -create trigger trg_v2_user_integrations_updated before update on v2_user_integrations - for each row execute function public.v2_touch_updated_at(); - -create or replace function v2_audit_provider_key_change() returns trigger as $$ -begin - insert into v2_audit_log (user_id, action, resource_type, resource_id, metadata) - values ( - coalesce(NEW.user_id, OLD.user_id), - case TG_OP - when 'INSERT' then 'provider_key.create' - when 'UPDATE' then 'provider_key.update' - when 'DELETE' then 'provider_key.delete' - end, - 'provider_key', - coalesce(NEW.provider, OLD.provider), - jsonb_build_object('fingerprint', coalesce(NEW.fingerprint, OLD.fingerprint)) - ); - return coalesce(NEW, OLD); -end $$ language plpgsql; - -create trigger trg_v2_audit_provider_keys - after insert or update or delete on v2_provider_keys - for each row execute function v2_audit_provider_key_change(); diff --git a/infra/supabase/migrations/post/0012_rls.sql b/infra/supabase/migrations/post/0012_rls.sql deleted file mode 100644 index 20137100..00000000 --- a/infra/supabase/migrations/post/0012_rls.sql +++ /dev/null @@ -1,16 +0,0 @@ -alter table v2_provider_keys enable row level security; -alter table v2_audit_log enable row level security; - -create policy v2_provider_keys_select_own on v2_provider_keys - for select using (user_id::text = current_setting('app.user_id', true)); -create policy v2_provider_keys_insert_own on v2_provider_keys - for insert with check (user_id::text = current_setting('app.user_id', true)); -create policy v2_provider_keys_update_own on v2_provider_keys - for update using (user_id::text = current_setting('app.user_id', true)); -create policy v2_provider_keys_delete_own on v2_provider_keys - for delete using (user_id::text = current_setting('app.user_id', true)); - -create policy v2_audit_log_select_own on v2_audit_log - for select using (user_id::text = current_setting('app.user_id', true)); -create policy v2_audit_log_insert_system on v2_audit_log - for insert with check (true); diff --git a/infra/supabase/migrations/post/0013_byok.sql b/infra/supabase/migrations/post/0013_byok.sql deleted file mode 100644 index 76e2a2c9..00000000 --- a/infra/supabase/migrations/post/0013_byok.sql +++ /dev/null @@ -1,85 +0,0 @@ -create or replace function current_app_user() returns uuid -language plpgsql stable security definer set search_path = '' as $$ -declare v uuid; -begin - v := nullif(current_setting('app.user_id', true), '')::uuid; - if v is null then - raise exception 'app.user_id not set - refusing BYOK operation'; - end if; - return v; -end $$; - -create or replace function set_provider_key(p_provider text, p_key text) -returns uuid language plpgsql security definer set search_path = '' as $$ -declare - v_user uuid := public.current_app_user(); - v_secret_id uuid; - v_fingerprint text; - v_row_id uuid; -begin - v_fingerprint := substring( - encode(extensions.digest(convert_to(p_key, 'UTF8'), 'sha256'), 'hex') - for 12 - ); - update public.v2_provider_keys - set deleted_at = now() - where user_id = v_user and provider = p_provider and deleted_at is null; - insert into vault.secrets (secret, name) - values (p_key, v_user::text || ':' || p_provider || ':' || extract(epoch from now())::text) - returning id into v_secret_id; - insert into public.v2_provider_keys (user_id, provider, vault_secret_id, fingerprint) - values (v_user, p_provider, v_secret_id, v_fingerprint) - returning id into v_row_id; - return v_row_id; -end $$; - -create or replace function get_provider_key(p_provider text) -returns text language plpgsql security definer set search_path = '' as $$ -declare - v_user uuid := public.current_app_user(); - v_key text; - v_row_id uuid; -begin - select pk.id, ds.decrypted_secret into v_row_id, v_key - from public.v2_provider_keys pk - join vault.decrypted_secrets ds on ds.id = pk.vault_secret_id - where pk.user_id = v_user - and pk.provider = p_provider - and pk.deleted_at is null - and pk.disabled_at is null - order by pk.created_at desc - limit 1; - if v_row_id is not null then - update public.v2_provider_keys set last_used_at = now() where id = v_row_id; - end if; - return v_key; -end $$; - -create or replace function delete_provider_key(p_provider text) -returns void language plpgsql security definer set search_path = '' as $$ -declare - v_user uuid := public.current_app_user(); - v_secret_id uuid; -begin - select vault_secret_id into v_secret_id - from public.v2_provider_keys - where user_id = v_user and provider = p_provider and deleted_at is null; - if v_secret_id is not null then - update public.v2_provider_keys set deleted_at = now() - where user_id = v_user and provider = p_provider; - delete from vault.secrets where id = v_secret_id; - end if; -end $$; - -revoke all on function - public.current_app_user(), - public.set_provider_key(text, text), - public.get_provider_key(text), - public.delete_provider_key(text) -from public, app_worker; - -grant execute on function - public.set_provider_key(text, text), - public.get_provider_key(text), - public.delete_provider_key(text) -to app_worker; diff --git a/infra/supabase/migrations/post/0014_v2_grants.sql b/infra/supabase/migrations/post/0014_v2_grants.sql deleted file mode 100644 index a314e263..00000000 --- a/infra/supabase/migrations/post/0014_v2_grants.sql +++ /dev/null @@ -1,27 +0,0 @@ -alter table v2_audit_log enable row level security; - -drop policy if exists v2_audit_log_select_own on v2_audit_log; -drop policy if exists v2_audit_log_insert_system on v2_audit_log; - -create policy v2_audit_log_select_own on v2_audit_log - for select using (user_id::text = current_setting('app.user_id', true)); -create policy v2_audit_log_insert_system on v2_audit_log - for insert with check (true); - -revoke select, insert, update, delete on all tables in schema public from app_worker; - -grant select, insert, update, delete on table - v2_users, - v2_projects, - v2_threads, - v2_messages, - v2_agent_runs, - v2_provider_keys, - v2_user_integrations, - v2_generated_outputs, - v2_usage_events, - v2_usage_daily_totals, - v2_entitlements, - v2_billing_events, - v2_audit_log -to app_worker; diff --git a/infra/supabase/migrations/post/0015_v2_advisor_fixes.sql b/infra/supabase/migrations/post/0015_v2_advisor_fixes.sql deleted file mode 100644 index c92438a8..00000000 --- a/infra/supabase/migrations/post/0015_v2_advisor_fixes.sql +++ /dev/null @@ -1,52 +0,0 @@ -create index if not exists v2_agent_runs_user_started_idx on v2_agent_runs (user_id, started_at desc); -create index if not exists v2_billing_events_user_processed_idx on v2_billing_events (user_id, processed_at desc) where user_id is not null; -create index if not exists v2_generated_outputs_agent_run_idx on v2_generated_outputs (agent_run_id) where agent_run_id is not null; -create index if not exists v2_generated_outputs_project_created_idx on v2_generated_outputs (project_id, created_at desc) where project_id is not null; -create index if not exists v2_messages_user_created_idx on v2_messages (user_id, created_at desc); -create index if not exists v2_threads_project_created_idx on v2_threads (project_id, created_at desc) where deleted_at is null; -create index if not exists v2_audit_log_action_created_idx on v2_audit_log (action, created_at desc); -create index if not exists v2_audit_log_created_brin_idx on v2_audit_log using brin (created_at); - -create or replace function v2_audit_provider_key_change() returns trigger -language plpgsql -set search_path = '' -as $$ -begin - insert into public.v2_audit_log (user_id, action, resource_type, resource_id, metadata) - values ( - coalesce(NEW.user_id, OLD.user_id), - case TG_OP - when 'INSERT' then 'provider_key.create' - when 'UPDATE' then 'provider_key.update' - when 'DELETE' then 'provider_key.delete' - end, - 'provider_key', - coalesce(NEW.provider, OLD.provider), - jsonb_build_object('fingerprint', coalesce(NEW.fingerprint, OLD.fingerprint)) - ); - return coalesce(NEW, OLD); -end -$$; - -alter table v2_provider_keys enable row level security; -alter table v2_audit_log enable row level security; - -drop policy if exists v2_provider_keys_select_own on v2_provider_keys; -drop policy if exists v2_provider_keys_insert_own on v2_provider_keys; -drop policy if exists v2_provider_keys_update_own on v2_provider_keys; -drop policy if exists v2_provider_keys_delete_own on v2_provider_keys; -drop policy if exists v2_audit_log_select_own on v2_audit_log; -drop policy if exists v2_audit_log_insert_system on v2_audit_log; - -create policy v2_provider_keys_select_own on v2_provider_keys - for select using (user_id::text = (select current_setting('app.user_id', true))); -create policy v2_provider_keys_insert_own on v2_provider_keys - for insert with check (user_id::text = (select current_setting('app.user_id', true))); -create policy v2_provider_keys_update_own on v2_provider_keys - for update using (user_id::text = (select current_setting('app.user_id', true))); -create policy v2_provider_keys_delete_own on v2_provider_keys - for delete using (user_id::text = (select current_setting('app.user_id', true))); -create policy v2_audit_log_select_own on v2_audit_log - for select using (user_id::text = (select current_setting('app.user_id', true))); -create policy v2_audit_log_insert_system on v2_audit_log - for insert with check (true); diff --git a/infra/supabase/migrations/post/0016_v2_vault_grants.sql b/infra/supabase/migrations/post/0016_v2_vault_grants.sql deleted file mode 100644 index 70cf0ddf..00000000 --- a/infra/supabase/migrations/post/0016_v2_vault_grants.sql +++ /dev/null @@ -1,29 +0,0 @@ -create or replace function set_provider_key(p_provider text, p_key text) -returns uuid language plpgsql security definer set search_path = '' as $$ -declare - v_user uuid := public.current_app_user(); - v_secret_id uuid; - v_fingerprint text; - v_row_id uuid; -begin - v_fingerprint := substring( - encode(extensions.digest(convert_to(p_key, 'UTF8'), 'sha256'), 'hex') - for 12 - ); - update public.v2_provider_keys - set deleted_at = now() - where user_id = v_user and provider = p_provider and deleted_at is null; - v_secret_id := vault.create_secret( - p_key, - v_user::text || ':' || p_provider || ':' || extract(epoch from now())::text, - 'Cheatcode V2 BYOK provider key', - null - ); - insert into public.v2_provider_keys (user_id, provider, vault_secret_id, fingerprint) - values (v_user, p_provider, v_secret_id, v_fingerprint) - returning id into v_row_id; - return v_row_id; -end $$; - -revoke all on function public.set_provider_key(text, text) from public, app_worker; -grant execute on function public.set_provider_key(text, text) to app_worker; diff --git a/infra/supabase/migrations/post/0017_v2_billing_triggers.sql b/infra/supabase/migrations/post/0017_v2_billing_triggers.sql deleted file mode 100644 index 19b258c5..00000000 --- a/infra/supabase/migrations/post/0017_v2_billing_triggers.sql +++ /dev/null @@ -1,4 +0,0 @@ -drop trigger if exists trg_v2_entitlements_updated on v2_entitlements; - -create trigger trg_v2_entitlements_updated before update on v2_entitlements - for each row execute function public.v2_touch_updated_at(); diff --git a/infra/supabase/migrations/post/0018_v2_byok_vault_cleanup.sql b/infra/supabase/migrations/post/0018_v2_byok_vault_cleanup.sql deleted file mode 100644 index b5b648f7..00000000 --- a/infra/supabase/migrations/post/0018_v2_byok_vault_cleanup.sql +++ /dev/null @@ -1,86 +0,0 @@ -create or replace function set_provider_key(p_provider text, p_key text) -returns uuid language plpgsql security definer set search_path = '' as $$ -declare - v_user uuid := public.current_app_user(); - v_secret_id uuid; - v_fingerprint text; - v_row_id uuid; - v_old_secret_ids uuid[]; -begin - select coalesce(array_agg(vault_secret_id), '{}'::uuid[]) - into v_old_secret_ids - from public.v2_provider_keys - where user_id = v_user and provider = p_provider and deleted_at is null; - - v_fingerprint := substring( - encode(extensions.digest(convert_to(p_key, 'UTF8'), 'sha256'), 'hex') - for 12 - ); - - update public.v2_provider_keys - set deleted_at = now() - where user_id = v_user and provider = p_provider and deleted_at is null; - - v_secret_id := vault.create_secret( - p_key, - v_user::text || ':' || p_provider || ':' || extract(epoch from now())::text, - 'Cheatcode V2 BYOK provider key' - ); - - insert into public.v2_provider_keys (user_id, provider, vault_secret_id, fingerprint) - values (v_user, p_provider, v_secret_id, v_fingerprint) - returning id into v_row_id; - - delete from vault.secrets where id = any(v_old_secret_ids); - return v_row_id; -end $$; - -create or replace function delete_provider_key(p_provider text) -returns void language plpgsql security definer set search_path = '' as $$ -declare - v_user uuid := public.current_app_user(); - v_secret_ids uuid[]; -begin - select coalesce(array_agg(vault_secret_id), '{}'::uuid[]) - into v_secret_ids - from public.v2_provider_keys - where user_id = v_user and provider = p_provider; - - update public.v2_provider_keys - set deleted_at = coalesce(deleted_at, now()) - where user_id = v_user and provider = p_provider; - - delete from vault.secrets where id = any(v_secret_ids); -end $$; - -create or replace function delete_all_provider_keys() -returns integer language plpgsql security definer set search_path = '' as $$ -declare - v_user uuid := public.current_app_user(); - v_secret_ids uuid[]; - v_deleted_count integer; -begin - select coalesce(array_agg(vault_secret_id), '{}'::uuid[]), count(*)::integer - into v_secret_ids, v_deleted_count - from public.v2_provider_keys - where user_id = v_user; - - update public.v2_provider_keys - set deleted_at = coalesce(deleted_at, now()) - where user_id = v_user; - - delete from vault.secrets where id = any(v_secret_ids); - return v_deleted_count; -end $$; - -revoke all on function - public.set_provider_key(text, text), - public.delete_provider_key(text), - public.delete_all_provider_keys() -from public, app_worker; - -grant execute on function - public.set_provider_key(text, text), - public.delete_provider_key(text), - public.delete_all_provider_keys() -to app_worker; diff --git a/infra/supabase/migrations/post/0019_v2_entitlement_cancel_state.sql b/infra/supabase/migrations/post/0019_v2_entitlement_cancel_state.sql deleted file mode 100644 index f7ad0ab7..00000000 --- a/infra/supabase/migrations/post/0019_v2_entitlement_cancel_state.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table if exists v2_entitlements - add column if not exists cancel_at_period_end boolean not null default false; diff --git a/infra/supabase/migrations/post/0020_v2_downgrade_resource_state.sql b/infra/supabase/migrations/post/0020_v2_downgrade_resource_state.sql deleted file mode 100644 index dca10d61..00000000 --- a/infra/supabase/migrations/post/0020_v2_downgrade_resource_state.sql +++ /dev/null @@ -1,33 +0,0 @@ -alter table if exists public.v2_projects - add column if not exists over_quota boolean not null default false, - add column if not exists archived_pending_action boolean not null default false, - add column if not exists archive_after timestamptz; - -alter table if exists public.v2_provider_keys - add column if not exists disabled_at timestamptz, - add column if not exists disabled_reason text; - -create or replace function get_provider_key(p_provider text) -returns text language plpgsql security definer set search_path = '' as $$ -declare - v_user uuid := public.current_app_user(); - v_key text; - v_row_id uuid; -begin - select pk.id, ds.decrypted_secret into v_row_id, v_key - from public.v2_provider_keys pk - join vault.decrypted_secrets ds on ds.id = pk.vault_secret_id - where pk.user_id = v_user - and pk.provider = p_provider - and pk.deleted_at is null - and pk.disabled_at is null - order by pk.created_at desc - limit 1; - if v_row_id is not null then - update public.v2_provider_keys set last_used_at = now() where id = v_row_id; - end if; - return v_key; -end $$; - -revoke all on function public.get_provider_key(text) from public, app_worker; -grant execute on function public.get_provider_key(text) to app_worker; diff --git a/infra/supabase/migrations/post/0021_v2_user_profile_sync.sql b/infra/supabase/migrations/post/0021_v2_user_profile_sync.sql deleted file mode 100644 index ddcc1ba3..00000000 --- a/infra/supabase/migrations/post/0021_v2_user_profile_sync.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table public.v2_users - add column if not exists display_name text, - add column if not exists avatar_url text; diff --git a/infra/supabase/migrations/post/0022_v2_byok_revalidation_inventory.sql b/infra/supabase/migrations/post/0022_v2_byok_revalidation_inventory.sql deleted file mode 100644 index 1b8646b6..00000000 --- a/infra/supabase/migrations/post/0022_v2_byok_revalidation_inventory.sql +++ /dev/null @@ -1,26 +0,0 @@ -create or replace function list_provider_key_revalidation_targets(p_limit integer) -returns table ( - user_id uuid, - provider text, - fingerprint text -) -language sql -security definer -set search_path = '' -as $$ - select - pk.user_id, - pk.provider, - pk.fingerprint - from public.v2_provider_keys pk - where pk.deleted_at is null - and pk.disabled_at is null - order by - coalesce(pk.last_used_at, pk.created_at) asc, - pk.created_at asc, - pk.id asc - limit least(greatest(coalesce(p_limit, 250), 1), 1000) -$$; - -revoke all on function public.list_provider_key_revalidation_targets(integer) from public, app_worker; -grant execute on function public.list_provider_key_revalidation_targets(integer) to app_worker; diff --git a/infra/supabase/migrations/post/0023_v2_user_profiles.sql b/infra/supabase/migrations/post/0023_v2_user_profiles.sql deleted file mode 100644 index 0916b34f..00000000 --- a/infra/supabase/migrations/post/0023_v2_user_profiles.sql +++ /dev/null @@ -1,10 +0,0 @@ --- Post-migration for v2_user_profiles (Drizzle migration 0002 creates the table). --- Grants the app_worker role (Workers never use service_role) and wires the updated_at trigger. --- The blanket revoke in 0014_v2_grants.sql already ran, so this grant is additive. - -grant select, insert, update, delete on table v2_user_profiles to app_worker; - -drop trigger if exists trg_v2_user_profiles_updated on v2_user_profiles; -create trigger trg_v2_user_profiles_updated - before update on v2_user_profiles - for each row execute function public.v2_touch_updated_at(); diff --git a/infra/supabase/migrations/post/0024_v2_billing_tier_and_usage.sql b/infra/supabase/migrations/post/0024_v2_billing_tier_and_usage.sql deleted file mode 100644 index 10b2adc0..00000000 --- a/infra/supabase/migrations/post/0024_v2_billing_tier_and_usage.sql +++ /dev/null @@ -1,17 +0,0 @@ --- billing-credits cluster post-migration. --- --- The v2_entitlements tier CHECK swap (free|pro|premium|ultra|max) and the --- team->premium / enterprise->max data mapping live in the cluster's own --- generated Drizzle migration drizzle/0003_v2_billing_tier_premium_ultra_max.sql --- (hand-edited to interleave the UPDATEs before the new constraint). They are --- forced into the Drizzle phase because drizzle-kit tracks the check constraint --- in its snapshot; duplicating them here would double-apply. --- --- This raw post migration carries only the index the Activity punchcard --- (GET /v1/usage/daily runs[]) needs: a user-scoped started_at range scan. --- The existing v2_agent_runs (thread_id, started_at desc) index is thread-scoped --- and does not cover a per-user range query. app_worker already holds select on --- v2_agent_runs, so no new grants and no RLS changes are required. - -create index if not exists v2_agent_runs_user_started_idx - on v2_agent_runs (user_id, started_at desc); diff --git a/infra/supabase/migrations/post/0027_v2_user_skills_grants.sql b/infra/supabase/migrations/post/0027_v2_user_skills_grants.sql deleted file mode 100644 index f070b784..00000000 --- a/infra/supabase/migrations/post/0027_v2_user_skills_grants.sql +++ /dev/null @@ -1,11 +0,0 @@ --- User-created skills grants. Same posture as the other per-user tables: no --- row-level security (RLS stays limited to v2_provider_keys + v2_audit_log), with --- per-user isolation enforced in application code via withUserContext + userId --- filters. Skill bodies are user-authored markdown — no provider secrets at rest. --- --- DSR / account deletion: the user_id foreign key cascades on delete, so removing --- a v2_users row tears down its custom skills automatically. - -grant select, insert, update, delete on table - v2_user_skills -to app_worker; diff --git a/infra/supabase/migrations/post/0028_v2_security_integrity.sql b/infra/supabase/migrations/post/0028_v2_security_integrity.sql deleted file mode 100644 index 2645e8c8..00000000 --- a/infra/supabase/migrations/post/0028_v2_security_integrity.sql +++ /dev/null @@ -1,401 +0,0 @@ --- Pre-deploy-safe security and integrity expansion overlay. Drizzle owns table shape; --- this file adds cross-tenant invariants, privileged audit functions, and resumable --- operational retention state without removing application-facing schema. - -do $$ -declare - violation_count bigint; -begin - select count(*) into violation_count - from public.v2_threads child - left join public.v2_projects parent on parent.id = child.project_id - where child.project_id is not null - and (parent.id is null or parent.user_id <> child.user_id); - if violation_count > 0 then - raise exception 'tenant integrity preflight failed: % thread/project rows', violation_count; - end if; - - select count(*) into violation_count - from public.v2_messages child - left join public.v2_threads parent on parent.id = child.thread_id - where parent.id is null or parent.user_id <> child.user_id; - if violation_count > 0 then - raise exception 'tenant integrity preflight failed: % message/thread rows', violation_count; - end if; - - select count(*) into violation_count - from public.v2_messages child - left join public.v2_agent_runs parent on parent.id = child.agent_run_id - where child.agent_run_id is not null - and ( - parent.id is null - or parent.user_id <> child.user_id - or parent.thread_id <> child.thread_id - ); - if violation_count > 0 then - raise exception 'tenant integrity preflight failed: % message/run rows', violation_count; - end if; - - select count(*) into violation_count - from public.v2_agent_runs child - left join public.v2_threads parent on parent.id = child.thread_id - where parent.id is null or parent.user_id <> child.user_id; - if violation_count > 0 then - raise exception 'tenant integrity preflight failed: % run/thread rows', violation_count; - end if; - - select count(*) into violation_count - from public.v2_threads child - left join public.v2_agent_runs parent on parent.id = child.active_run_id - where child.active_run_id is not null - and ( - parent.id is null - or parent.user_id <> child.user_id - or parent.thread_id <> child.id - ); - if violation_count > 0 then - raise exception 'tenant integrity preflight failed: % thread/active-run rows', violation_count; - end if; - - select count(*) into violation_count - from public.v2_generated_outputs child - left join public.v2_projects parent on parent.id = child.project_id - where child.project_id is not null - and (parent.id is null or parent.user_id <> child.user_id); - if violation_count > 0 then - raise exception 'tenant integrity preflight failed: % output/project rows', violation_count; - end if; - - select count(*) into violation_count - from public.v2_generated_outputs child - left join public.v2_agent_runs parent on parent.id = child.agent_run_id - where child.agent_run_id is not null - and (parent.id is null or parent.user_id <> child.user_id); - if violation_count > 0 then - raise exception 'tenant integrity preflight failed: % output/run rows', violation_count; - end if; - - select count(*) into violation_count - from public.v2_generated_outputs - where sha256 is null - or sha256 !~ '^[0-9a-f]{64}$' - or size_bytes <= 0 - or btrim(r2_bucket) = '' - or length(r2_bucket) > 255 - or btrim(r2_key) = '' - or length(r2_key) > 1024 - or btrim(filename) = '' - or length(filename) > 255 - or btrim(mime_type) = '' - or length(mime_type) > 255 - or kind not in ('audio', 'docx', 'image', 'pdf', 'slide', 'video', 'xlsx') - or jsonb_typeof(metadata) <> 'object' - or expires_at is null - or expires_at <= created_at; - if violation_count > 0 then - raise exception 'output integrity preflight failed: % invalid output rows; backfill before retrying', violation_count; - end if; - - select count(*) into violation_count - from ( - select r2_bucket, r2_key - from public.v2_generated_outputs - group by r2_bucket, r2_key - having count(*) > 1 - ) duplicates; - if violation_count > 0 then - raise exception 'output integrity preflight failed: % duplicate R2 object keys', violation_count; - end if; - - -- This allowlist is the database counterpart of packages/types ProviderSchema. - select count(*) into violation_count - from public.v2_provider_keys - where provider not in ( - 'anthropic', - 'openai', - 'google', - 'openrouter', - 'deepseek', - 'exa', - 'firecrawl', - 'llamaparse' - ); - if violation_count > 0 then - raise exception 'provider key integrity preflight failed: % unknown providers', violation_count; - end if; -end -$$; - -alter table public.v2_projects - add constraint v2_projects_id_user_id_key unique (id, user_id); -alter table public.v2_threads - add constraint v2_threads_id_user_id_key unique (id, user_id); -alter table public.v2_agent_runs - add constraint v2_agent_runs_id_user_id_key unique (id, user_id), - add constraint v2_agent_runs_id_user_id_thread_id_key unique (id, user_id, thread_id); - -alter table public.v2_threads - add constraint v2_threads_project_user_fk - foreign key (project_id, user_id) - references public.v2_projects (id, user_id) - on delete cascade; -alter table public.v2_messages - add constraint v2_messages_thread_user_fk - foreign key (thread_id, user_id) - references public.v2_threads (id, user_id) - on delete cascade; -alter table public.v2_messages - add constraint v2_messages_agent_run_scope_fk - foreign key (agent_run_id, user_id, thread_id) - references public.v2_agent_runs (id, user_id, thread_id) - on delete set null (agent_run_id); -alter table public.v2_agent_runs - add constraint v2_agent_runs_thread_user_fk - foreign key (thread_id, user_id) - references public.v2_threads (id, user_id) - on delete cascade; -alter table public.v2_threads - add constraint v2_threads_active_run_scope_fk - foreign key (active_run_id, user_id, id) - references public.v2_agent_runs (id, user_id, thread_id) - on delete set null (active_run_id); -alter table public.v2_generated_outputs - add constraint v2_generated_outputs_project_user_fk - foreign key (project_id, user_id) - references public.v2_projects (id, user_id) - on delete cascade; -alter table public.v2_generated_outputs - add constraint v2_generated_outputs_agent_run_user_fk - foreign key (agent_run_id, user_id) - references public.v2_agent_runs (id, user_id) - on delete set null (agent_run_id); - -alter table public.v2_generated_outputs - add constraint v2_generated_outputs_size_check check (size_bytes > 0), - add constraint v2_generated_outputs_sha256_check check (sha256 ~ '^[0-9a-f]{64}$'), - add constraint v2_generated_outputs_bucket_check - check (btrim(r2_bucket) <> '' and length(r2_bucket) <= 255), - add constraint v2_generated_outputs_key_check - check (btrim(r2_key) <> '' and length(r2_key) <= 1024), - add constraint v2_generated_outputs_filename_check - check (btrim(filename) <> '' and length(filename) <= 255), - add constraint v2_generated_outputs_mime_type_check - check (btrim(mime_type) <> '' and length(mime_type) <= 255), - add constraint v2_generated_outputs_kind_check - check (kind in ('audio', 'docx', 'image', 'pdf', 'slide', 'video', 'xlsx')), - add constraint v2_generated_outputs_metadata_check check (jsonb_typeof(metadata) = 'object'), - add constraint v2_generated_outputs_expiry_check check (expires_at > created_at), - add constraint v2_generated_outputs_r2_object_key unique (r2_bucket, r2_key); - -alter table public.v2_provider_keys - add constraint v2_provider_keys_provider_check - check ( - provider in ( - 'anthropic', - 'openai', - 'google', - 'openrouter', - 'deepseek', - 'exa', - 'firecrawl', - 'llamaparse' - ) - ); - -create or replace function public.append_v2_audit_event( - p_action text, - p_resource_type text default null, - p_resource_id text default null, - p_metadata jsonb default '{}'::jsonb -) returns uuid -language plpgsql -security definer -set search_path = '' -as $$ -declare - actor_id uuid; - audit_id uuid; -begin - actor_id := nullif(current_setting('app.user_id', true), '')::uuid; - if actor_id is null then - raise exception 'app.user_id must be set before appending an audit event'; - end if; - if p_action is null or p_action !~ '^[a-z0-9_.:-]{3,100}$' then - raise exception 'invalid audit action'; - end if; - if p_resource_type is not null and length(p_resource_type) > 100 then - raise exception 'audit resource type is too long'; - end if; - if p_resource_id is not null and length(p_resource_id) > 256 then - raise exception 'audit resource id is too long'; - end if; - if p_metadata is null or jsonb_typeof(p_metadata) <> 'object' then - raise exception 'audit metadata must be a JSON object'; - end if; - - insert into public.v2_audit_log (user_id, action, resource_type, resource_id, metadata) - values (actor_id, p_action, p_resource_type, p_resource_id, p_metadata) - returning id into audit_id; - return audit_id; -end -$$; - -revoke all on function public.append_v2_audit_event(text, text, text, jsonb) from public; -grant execute on function public.append_v2_audit_event(text, text, text, jsonb) to app_worker; - -create or replace function public.scrub_current_user_audit() returns bigint -language plpgsql -security definer -set search_path = '' -as $$ -declare - actor_id uuid; - scrubbed_count bigint; -begin - actor_id := nullif(current_setting('app.user_id', true), '')::uuid; - if actor_id is null then - raise exception 'app.user_id must be set before scrubbing audit records'; - end if; - - update public.v2_audit_log - set user_id = null, - resource_id = null, - metadata = jsonb_build_object('subject_erased', true), - ip_address = null, - user_agent = null - where user_id = actor_id; - get diagnostics scrubbed_count = row_count; - return scrubbed_count; -end -$$; - -revoke all on function public.scrub_current_user_audit() from public; -grant execute on function public.scrub_current_user_audit() to app_worker; - -create or replace function public.v2_audit_provider_key_change() returns trigger -language plpgsql -security definer -set search_path = '' -as $$ -begin - insert into public.v2_audit_log (user_id, action, resource_type, resource_id, metadata) - values ( - coalesce(NEW.user_id, OLD.user_id), - case TG_OP - when 'INSERT' then 'provider_key.create' - when 'UPDATE' then 'provider_key.update' - when 'DELETE' then 'provider_key.delete' - end, - 'provider_key', - coalesce(NEW.provider, OLD.provider), - jsonb_build_object('fingerprint', coalesce(NEW.fingerprint, OLD.fingerprint)) - ); - return coalesce(NEW, OLD); -end -$$; - -create or replace function public.v2_audit_entitlement_change() returns trigger -language plpgsql -security definer -set search_path = '' -as $$ -begin - if TG_OP = 'UPDATE' and - (NEW.tier, NEW.subscription_status, NEW.cancel_at_period_end) - is not distinct from - (OLD.tier, OLD.subscription_status, OLD.cancel_at_period_end) then - return NEW; - end if; - insert into public.v2_audit_log (user_id, action, resource_type, resource_id, metadata) - values ( - coalesce(NEW.user_id, OLD.user_id), - 'billing.entitlement.' || lower(TG_OP), - 'entitlement', - null, - jsonb_strip_nulls(jsonb_build_object( - 'tier', case when TG_OP = 'DELETE' then OLD.tier else NEW.tier end, - 'subscription_status', - case when TG_OP = 'DELETE' then OLD.subscription_status else NEW.subscription_status end, - 'cancel_at_period_end', - case when TG_OP = 'DELETE' then OLD.cancel_at_period_end else NEW.cancel_at_period_end end - )) - ); - return coalesce(NEW, OLD); -end -$$; - -create trigger v2_audit_entitlement_change_trigger -after insert or update or delete on public.v2_entitlements -for each row execute function public.v2_audit_entitlement_change(); - -create or replace function public.v2_audit_integration_change() returns trigger -language plpgsql -security definer -set search_path = '' -as $$ -begin - insert into public.v2_audit_log (user_id, action, resource_type, resource_id, metadata) - values ( - coalesce(NEW.user_id, OLD.user_id), - 'integration.' || lower(TG_OP), - 'integration', - coalesce(NEW.integration, OLD.integration), - jsonb_build_object('status', coalesce(NEW.status, OLD.status)) - ); - return coalesce(NEW, OLD); -end -$$; - -create trigger v2_audit_integration_change_trigger -after insert or update or delete on public.v2_user_integrations -for each row execute function public.v2_audit_integration_change(); - -create table if not exists public._audit_archive_manifest ( - partition_name text primary key check (partition_name ~ '^v2_audit_log_[0-9]{4}_(0[1-9]|1[0-2])$'), - month_start date not null unique, - bucket text not null check (bucket ~ '^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$'), - format_version integer not null default 1 check (format_version = 1), - object_key text unique, - row_count bigint check (row_count >= 0), - size_bytes bigint check (size_bytes >= 0), - sha256 text check (sha256 ~ '^[0-9a-f]{64}$'), - state text not null check (state in ('detached', 'verified', 'dropped')), - detached_at timestamptz not null, - verified_at timestamptz, - dropped_at timestamptz, - check ( - object_key is null - or object_key ~ ('^[0-9]{4}-(0[1-9]|1[0-2])/audit_log-' || sha256 || '\.ndjson\.gz$') - ), - check ( - ( - state = 'detached' - and object_key is null - and row_count is null - and size_bytes is null - and sha256 is null - and verified_at is null - and dropped_at is null - ) - or ( - state = 'verified' - and object_key is not null - and row_count is not null - and size_bytes is not null - and sha256 is not null - and verified_at is not null - and dropped_at is null - ) - or ( - state = 'dropped' - and object_key is not null - and row_count is not null - and size_bytes is not null - and sha256 is not null - and verified_at is not null - and dropped_at is not null - ) - ) -); - -revoke all on public._audit_archive_manifest from public, app_worker; diff --git a/infra/supabase/migrations/post/0029_remove_token_cost_accounting.sql b/infra/supabase/migrations/post/0029_remove_token_cost_accounting.sql deleted file mode 100644 index 7e53da6b..00000000 --- a/infra/supabase/migrations/post/0029_remove_token_cost_accounting.sql +++ /dev/null @@ -1,25 +0,0 @@ --- Contract only after the token-accounting-free backend release is live. --- DROP remains non-CASCADE so unexpected dependencies stop for review. -drop table if exists public.v2_usage_daily_totals; -drop table if exists public.v2_usage_events; - -alter table if exists public.v2_agent_runs - drop column if exists tokens_in, - drop column if exists tokens_out, - drop column if exists tokens_cached, - drop column if exists cost_usd; - -alter table if exists public.v2_entitlements - drop column if exists free_deepseek_tokens_used; - -update public.v2_projects -set settings = settings - 'budgetCapUsd' -where settings ? 'budgetCapUsd'; - -update public.v2_agent_runs -set config = config - array['budgetCapUsd', 'stepCap', 'workflowName'] -where config ?| array['budgetCapUsd', 'stepCap', 'workflowName']; - -update public.v2_agent_runs -set error = error - 'stepNumber' -where error ? 'stepNumber'; diff --git a/infra/supabase/migrations/post/0030_remove_obsolete_entitlement_scaffolding.sql b/infra/supabase/migrations/post/0030_remove_obsolete_entitlement_scaffolding.sql deleted file mode 100644 index c324479e..00000000 --- a/infra/supabase/migrations/post/0030_remove_obsolete_entitlement_scaffolding.sql +++ /dev/null @@ -1,8 +0,0 @@ --- Contract only after every Worker reads the reduced entitlement projection. --- DROP remains non-CASCADE so unexpected dependencies stop for review. -alter table if exists public.v2_entitlements - drop column if exists max_concurrent_sandboxes, - drop column if exists max_seats, - drop column if exists quota_deployments, - drop column if exists flag_private_projects, - drop column if exists flag_sso; diff --git a/infra/supabase/migrations/post/0031_enforce_composio_connection_identity.sql b/infra/supabase/migrations/post/0031_enforce_composio_connection_identity.sql deleted file mode 100644 index 71c1d6ea..00000000 --- a/infra/supabase/migrations/post/0031_enforce_composio_connection_identity.sql +++ /dev/null @@ -1,36 +0,0 @@ --- Composio exposes connected accounts through an ID-only retrieval endpoint and --- expiry webhooks identify the account by that same ID. Refuse ambiguous existing --- rows before making that provider identity globally unique in Cheatcode. -do $$ -begin - if exists ( - select 1 - from public.v2_user_integrations - where integration !~ '^[a-z0-9_]{1,64}$' - ) then - raise exception 'invalid Composio toolkit slugs must be resolved before migration' - using errcode = '23514'; - end if; - if exists ( - select 1 - from public.v2_user_integrations - where composio_connection_id <> btrim(composio_connection_id) - or length(composio_connection_id) not between 1 and 256 - ) then - raise exception 'invalid Composio connection IDs must be resolved before migration' - using errcode = '23514'; - end if; - if exists ( - select 1 - from public.v2_user_integrations - group by composio_connection_id - having count(*) > 1 - ) then - raise exception 'duplicate Composio connection IDs must be resolved before migration' - using errcode = '23505'; - end if; -end -$$; - -create unique index v2_user_integrations_composio_connection_id_unique_idx - on public.v2_user_integrations (composio_connection_id); diff --git a/infra/supabase/migrations/post/0032_finalize_composio_connection_identity.sql b/infra/supabase/migrations/post/0032_finalize_composio_connection_identity.sql deleted file mode 100644 index 17923f2b..00000000 --- a/infra/supabase/migrations/post/0032_finalize_composio_connection_identity.sql +++ /dev/null @@ -1,64 +0,0 @@ --- New Workers preserve ownership/toolkit identity on conflict and maintain an --- active default. Repair historical state before enforcing those final rules. -update public.v2_user_integrations - set is_default = false, - updated_at = now() - where is_default = true - and lower(status) not in ('active', 'authorized', 'connected', 'enabled'); - -with missing_defaults as ( - select distinct on (candidate.user_id, candidate.integration) - candidate.composio_connection_id - from public.v2_user_integrations candidate - where lower(candidate.status) in ('active', 'authorized', 'connected', 'enabled') - and not exists ( - select 1 - from public.v2_user_integrations existing - where existing.user_id = candidate.user_id - and existing.integration = candidate.integration - and existing.is_default = true - ) - order by candidate.user_id, - candidate.integration, - candidate.updated_at desc, - candidate.composio_connection_id -) -update public.v2_user_integrations target - set is_default = true, - updated_at = now() - from missing_defaults - where target.composio_connection_id = missing_defaults.composio_connection_id; - -alter table public.v2_user_integrations - drop constraint v2_user_integrations_user_id_composio_connection_id_pk; - -alter table public.v2_user_integrations - add constraint v2_user_integrations_composio_connection_id_pk - primary key using index v2_user_integrations_composio_connection_id_unique_idx; - -alter table public.v2_user_integrations - add constraint v2_user_integrations_default_active_check - check ( - not is_default - or lower(status) in ('active', 'authorized', 'connected', 'enabled') - ) not valid; - -alter table public.v2_user_integrations - validate constraint v2_user_integrations_default_active_check; - -alter table public.v2_user_integrations - add constraint v2_user_integrations_connection_id_check - check ( - composio_connection_id = btrim(composio_connection_id) - and length(composio_connection_id) between 1 and 256 - ) not valid; - -alter table public.v2_user_integrations - validate constraint v2_user_integrations_connection_id_check; - -alter table public.v2_user_integrations - add constraint v2_user_integrations_integration_check - check (integration ~ '^[a-z0-9_]{1,64}$') not valid; - -alter table public.v2_user_integrations - validate constraint v2_user_integrations_integration_check; diff --git a/infra/supabase/migrations/post/0033_clerk_deletion_tombstone_access.sql b/infra/supabase/migrations/post/0033_clerk_deletion_tombstone_access.sql deleted file mode 100644 index 7c91a6ae..00000000 --- a/infra/supabase/migrations/post/0033_clerk_deletion_tombstone_access.sql +++ /dev/null @@ -1,16 +0,0 @@ -alter table public.v2_deleted_clerk_identities enable row level security; - -create policy v2_deleted_clerk_identities_select - on public.v2_deleted_clerk_identities - for select - to app_worker - using (true); - -create policy v2_deleted_clerk_identities_insert - on public.v2_deleted_clerk_identities - for insert - to app_worker - with check (clerk_identity_hash ~ '^[0-9a-f]{64}$'); - -revoke all on table public.v2_deleted_clerk_identities from app_worker; -grant select, insert on table public.v2_deleted_clerk_identities to app_worker; diff --git a/infra/supabase/migrations/post/0034_remove_superseded_thread_index.sql b/infra/supabase/migrations/post/0034_remove_superseded_thread_index.sql deleted file mode 100644 index dcd44503..00000000 --- a/infra/supabase/migrations/post/0034_remove_superseded_thread_index.sql +++ /dev/null @@ -1,3 +0,0 @@ --- The keyset-ready replacement is created expand-only by Drizzle migration 0023. --- Remove the narrower superseded index only after the matching application is live. -drop index if exists public.v2_threads_user_recent_idx; diff --git a/infra/supabase/migrations/post/0035_finalize_security_integrity.sql b/infra/supabase/migrations/post/0035_finalize_security_integrity.sql deleted file mode 100644 index 19b9302c..00000000 --- a/infra/supabase/migrations/post/0035_finalize_security_integrity.sql +++ /dev/null @@ -1,25 +0,0 @@ --- The pre-deploy overlay rejects invalid historical rows, installs checks for new --- writes, and creates the privileged audit API. Tighten the remaining physical --- and privilege contracts only after matching Workers have been verified. -alter table public.v2_generated_outputs - alter column sha256 set not null, - alter column expires_at set not null; - -alter table public.v2_threads - drop constraint v2_threads_project_id_v2_projects_id_fk; -alter table public.v2_messages - drop constraint v2_messages_thread_id_v2_threads_id_fk; -alter table public.v2_agent_runs - drop constraint v2_agent_runs_thread_id_v2_threads_id_fk; -alter table public.v2_generated_outputs - drop constraint v2_generated_outputs_project_id_v2_projects_id_fk, - drop constraint v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk; - -alter table public.v2_provider_keys enable row level security; -alter table public.v2_provider_keys force row level security; -alter table public.v2_audit_log enable row level security; -alter table public.v2_audit_log force row level security; - -drop policy if exists v2_audit_log_insert_system on public.v2_audit_log; -revoke insert, update, delete, truncate on public.v2_audit_log from public, app_worker; -grant select on public.v2_audit_log to app_worker; diff --git a/infra/supabase/migrations/post/0036_remove_project_backup_scaffolding.sql b/infra/supabase/migrations/post/0036_remove_project_backup_scaffolding.sql deleted file mode 100644 index cb4adef9..00000000 --- a/infra/supabase/migrations/post/0036_remove_project_backup_scaffolding.sql +++ /dev/null @@ -1,5 +0,0 @@ --- Daytona owns the persistent per-user workspace. No live V2 code reads or writes --- the superseded directory-backup handle, so remove it only after matching Workers --- have been deployed and verified. -alter table public.v2_projects - drop column if exists container_backup; diff --git a/infra/supabase/migrations/post/0037_backfill_first_artifact_milestone.sql b/infra/supabase/migrations/post/0037_backfill_first_artifact_milestone.sql deleted file mode 100644 index f66deda5..00000000 --- a/infra/supabase/migrations/post/0037_backfill_first_artifact_milestone.sql +++ /dev/null @@ -1,14 +0,0 @@ --- Reconcile historical outputs after the insertion bridge is active. Keeping --- this scan outside the column-add transaction bounds the v2_users DDL lock. -update public.v2_users as users - set first_artifact_at = first_output.created_at - from ( - select user_id, min(created_at) as created_at - from public.v2_generated_outputs - group by user_id - ) as first_output - where users.id = first_output.user_id - and ( - users.first_artifact_at is null - or users.first_artifact_at > first_output.created_at - ); diff --git a/infra/supabase/migrations/post/0038_remove_first_artifact_bridge.sql b/infra/supabase/migrations/post/0038_remove_first_artifact_bridge.sql deleted file mode 100644 index 63e3cdb5..00000000 --- a/infra/supabase/migrations/post/0038_remove_first_artifact_bridge.sql +++ /dev/null @@ -1,17 +0,0 @@ --- New Workers set the first-artifact milestone transactionally. Reconcile the --- deployment window once more, then remove the temporary old-writer bridge. -update public.v2_users as users - set first_artifact_at = first_output.created_at - from ( - select user_id, min(created_at) as created_at - from public.v2_generated_outputs - group by user_id - ) as first_output - where users.id = first_output.user_id - and ( - users.first_artifact_at is null - or users.first_artifact_at > first_output.created_at - ); - -drop trigger v2_capture_first_artifact_trigger on public.v2_generated_outputs; -drop function public.v2_capture_first_artifact(); diff --git a/infra/supabase/migrations/post/0039_remove_retired_automations.sql b/infra/supabase/migrations/post/0039_remove_retired_automations.sql deleted file mode 100644 index de27542b..00000000 --- a/infra/supabase/migrations/post/0039_remove_retired_automations.sql +++ /dev/null @@ -1,5 +0,0 @@ --- Contract only after the automation-free Workers and Vercel frontend are live. --- DROP remains non-CASCADE so unexpected external dependencies stop for review. -drop table if exists public.v2_retired_automation_run_requests_20260715; -drop table if exists public.v2_retired_automation_runs_20260715; -drop table if exists public.v2_retired_automations_20260715; diff --git a/infra/supabase/migrations/post/0040_remove_dead_persisted_fields.sql b/infra/supabase/migrations/post/0040_remove_dead_persisted_fields.sql deleted file mode 100644 index e61225b1..00000000 --- a/infra/supabase/migrations/post/0040_remove_dead_persisted_fields.sql +++ /dev/null @@ -1,50 +0,0 @@ --- Contract only after the schema-clean Workers and Vercel frontend are live. --- These fields have no remaining runtime readers or writers. -alter table public.v2_agent_runs - drop column if exists config; - -alter table public.v2_projects - drop column if exists sandbox_id; - --- A project-backed thread derives its mode from the project. Keeping the --- pre-project launch payload would preserve two competing sources of truth. -update public.v2_threads - set launch_intent = null, - updated_at = now() - where project_id is not null - and launch_intent is not null; - --- `web` was the V1 spelling for the web app-builder surface. Normalize the --- existing rows before the canonical constraint is validated; do not silently --- coerce any other unexpected value. -update public.v2_projects - set mode = 'app-builder', - updated_at = now() - where mode = 'web'; - -do $$ -begin - if exists ( - select 1 - from public.v2_projects - where mode not in ('app-builder', 'app-builder-mobile', 'general') - ) then - raise exception 'v2_projects contains an unsupported project mode'; - end if; -end -$$; - -alter table public.v2_projects - add constraint v2_projects_mode_check - check (mode in ('app-builder', 'app-builder-mobile', 'general')) - not valid; - -alter table public.v2_projects - validate constraint v2_projects_mode_check; - --- Clerk identity lives on v2_users; entitlement rows contain only the current --- commercial state used to authorize product capabilities. -alter table public.v2_entitlements - drop column if exists polar_customer_id, - drop column if exists webhook_event_id, - drop column if exists source; diff --git a/infra/supabase/migrations/post/0041_finalize_agent_run_model_attribution.sql b/infra/supabase/migrations/post/0041_finalize_agent_run_model_attribution.sql deleted file mode 100644 index dbe65f73..00000000 --- a/infra/supabase/migrations/post/0041_finalize_agent_run_model_attribution.sql +++ /dev/null @@ -1,112 +0,0 @@ --- Contract only after Workers persist a canonical logical model for every run. --- Existing automatic selections predate that invariant and cannot be --- reconstructed after the fact, so attribute NULLs to the production plan. --- Known provider-local historical values retain their exact suffix. -create function pg_temp.cheatcode_canonical_model_id(candidate text) -returns text -language sql -immutable -parallel safe -as $function$ - select case - when candidate is null then null - when btrim(candidate) ~ '^claude-' then 'anthropic/' || btrim(candidate) - when btrim(candidate) ~ '^(gpt-|chatgpt-|o[0-9]+(-|$))' then 'openai/' || btrim(candidate) - when btrim(candidate) ~ '^gemini-' then 'google/' || btrim(candidate) - when btrim(candidate) ~ '^deepseek-' then 'deepseek/' || btrim(candidate) - else btrim(candidate) - end -$function$; - -update public.v2_agent_runs - set model_id = coalesce( - pg_temp.cheatcode_canonical_model_id(model_id), - 'anthropic/claude-sonnet-4-6' - ) - where model_id is distinct from coalesce( - pg_temp.cheatcode_canonical_model_id(model_id), - 'anthropic/claude-sonnet-4-6' - ); - -update public.v2_projects - set settings = jsonb_set( - settings, - '{defaultModel}', - to_jsonb(pg_temp.cheatcode_canonical_model_id(settings ->> 'defaultModel')), - false - ) - where jsonb_typeof(settings -> 'defaultModel') = 'string' - and settings ->> 'defaultModel' is distinct from - pg_temp.cheatcode_canonical_model_id(settings ->> 'defaultModel'); - -update public.v2_threads - set launch_intent = jsonb_set( - launch_intent, - '{defaultModel}', - to_jsonb(pg_temp.cheatcode_canonical_model_id(launch_intent ->> 'defaultModel')), - false - ) - where jsonb_typeof(launch_intent -> 'defaultModel') = 'string' - and launch_intent ->> 'defaultModel' is distinct from - pg_temp.cheatcode_canonical_model_id(launch_intent ->> 'defaultModel'); - -do $validation$ -begin - if exists ( - select 1 - from public.v2_projects - where settings ? 'defaultModel' - and settings -> 'defaultModel' <> 'null'::jsonb - and ( - jsonb_typeof(settings -> 'defaultModel') <> 'string' - or char_length(settings ->> 'defaultModel') > 200 - or settings ->> 'defaultModel' - !~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$' - ) - ) then - raise exception 'v2_projects.settings.defaultModel contains a noncanonical model id' - using errcode = '23514'; - end if; - - if exists ( - select 1 - from public.v2_threads - where launch_intent ? 'defaultModel' - and launch_intent -> 'defaultModel' <> 'null'::jsonb - and ( - jsonb_typeof(launch_intent -> 'defaultModel') <> 'string' - or char_length(launch_intent ->> 'defaultModel') > 200 - or launch_intent ->> 'defaultModel' - !~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$' - ) - ) then - raise exception 'v2_threads.launch_intent.defaultModel contains a noncanonical model id' - using errcode = '23514'; - end if; -end -$validation$; - -alter table public.v2_agent_runs - add constraint v2_agent_runs_model_id_canonical_check - check ( - char_length(model_id) <= 200 - and model_id ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$' - ) - not valid; - -alter table public.v2_agent_runs - validate constraint v2_agent_runs_model_id_canonical_check; - -alter table public.v2_agent_runs - add constraint v2_agent_runs_model_id_not_null_check - check (model_id is not null) - not valid; - -alter table public.v2_agent_runs - validate constraint v2_agent_runs_model_id_not_null_check; - -alter table public.v2_agent_runs - alter column model_id set not null; - -alter table public.v2_agent_runs - drop constraint v2_agent_runs_model_id_not_null_check; diff --git a/infra/supabase/migrations/post/0042_harden_byok_and_data_api_boundary.sql b/infra/supabase/migrations/post/0042_harden_byok_and_data_api_boundary.sql deleted file mode 100644 index 81248fbb..00000000 --- a/infra/supabase/migrations/post/0042_harden_byok_and_data_api_boundary.sql +++ /dev/null @@ -1,592 +0,0 @@ --- Keep the old Worker RPC signatures live during the release window while --- making Vault ownership, revalidation claims, and direct-table access strict. - -do $preflight$ -declare - invalid_count bigint; -begin - select count(*) - into invalid_count - from public.v2_provider_keys key - left join vault.secrets secret on secret.id = key.vault_secret_id - where key.deleted_at is null - and ( - secret.id is null - or secret.name not like key.user_id::text || ':' || key.provider || ':%' - ); - if invalid_count > 0 then - raise exception - 'BYOK preflight failed: % live provider keys lack their own Vault secret', - invalid_count; - end if; - - select count(*) - into invalid_count - from public.v2_provider_keys key - join vault.secrets secret on secret.id = key.vault_secret_id - where secret.name not like key.user_id::text || ':' || key.provider || ':%'; - if invalid_count > 0 then - raise exception - 'BYOK preflight failed: % provider keys reference a Vault secret with mismatched ownership metadata', - invalid_count; - end if; - - select count(*) - into invalid_count - from ( - select vault_secret_id - from public.v2_provider_keys - group by vault_secret_id - having count(*) > 1 - ) duplicate_references; - if invalid_count > 0 then - raise exception - 'BYOK preflight failed: % Vault secrets are referenced by multiple provider-key rows', - invalid_count; - end if; -end -$preflight$; - --- The user/provider-prefixed name is the ownership proof. Normalize only those --- verified references so the deletion trigger can require one exact marker. --- Supabase Vault intentionally withholds direct UPDATE access from its --- migration role. Use the extension's SECURITY DEFINER API so this remains --- compatible with managed Vault while preserving the ownership preflight. -do $normalize_vault_descriptions$ -declare - provider_secret_id uuid; -begin - for provider_secret_id in - select secret.id - from public.v2_provider_keys key - join vault.secrets secret on secret.id = key.vault_secret_id - where secret.name like key.user_id::text || ':' || key.provider || ':%' - and secret.description is distinct from 'Cheatcode V2 BYOK provider key' - loop - perform vault.update_secret( - provider_secret_id, - new_description => 'Cheatcode V2 BYOK provider key' - ); - end loop; -end -$normalize_vault_descriptions$; - -create unique index v2_provider_keys_vault_secret_uidx - on public.v2_provider_keys (vault_secret_id); - -create index if not exists v2_provider_keys_revalidation_idx - on public.v2_provider_keys ( - last_revalidated_at nulls first, - created_at, - user_id, - provider - ) - where disabled_at is null; - -do $constraint$ -begin - if not exists ( - select 1 - from pg_constraint - where conrelid = 'public.v2_provider_keys'::regclass - and conname = 'v2_provider_keys_disabled_pair_check' - ) then - alter table public.v2_provider_keys - add constraint v2_provider_keys_disabled_pair_check - check ( - (disabled_at is null and disabled_reason is null) - or (disabled_at is not null and disabled_reason is not null) - ) - not valid; - end if; -end -$constraint$; - -alter table public.v2_provider_keys - validate constraint v2_provider_keys_disabled_pair_check; - -create or replace function public.v2_delete_provider_vault_secret() returns trigger -language plpgsql -security definer -set search_path = '' -as $function$ -declare - secret_name text; - secret_description text; -begin - select secret.name, secret.description - into secret_name, secret_description - from vault.secrets secret - where secret.id = old.vault_secret_id - for update; - - if not found then - -- Historical soft-deletes already removed their Vault payload. A missing - -- payload for a live row is corruption and must never be hidden. - if old.deleted_at is null then - raise exception 'refusing to delete a live provider key with a missing Vault secret'; - end if; - return old; - end if; - - if secret_name not like old.user_id::text || ':' || old.provider || ':%' - or secret_description is distinct from 'Cheatcode V2 BYOK provider key' then - raise exception 'refusing to delete a provider key with mismatched Vault ownership metadata'; - end if; - - delete from vault.secrets where id = old.vault_secret_id; - if not found then - raise exception 'provider Vault secret disappeared while it was locked for deletion'; - end if; - return old; -end -$function$; - -create trigger trg_v2_provider_keys_delete_vault -before delete on public.v2_provider_keys -for each row execute function public.v2_delete_provider_vault_secret(); - -create or replace function public.set_provider_key(p_provider text, p_key text) -returns uuid -language plpgsql -security definer -set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); - secret_id uuid; - key_fingerprint text; - row_id uuid; -begin - if p_provider is null or p_provider not in ( - 'anthropic', - 'openai', - 'google', - 'openrouter', - 'deepseek', - 'exa', - 'firecrawl', - 'llamaparse' - ) then - raise exception 'unsupported provider'; - end if; - if p_key is null or btrim(p_key) = '' or octet_length(p_key) > 65536 then - raise exception 'provider key must contain between 1 and 65536 bytes'; - end if; - - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended( - 'cheatcode:provider-keys:' || actor_id::text, - 0 - ) - ); - - key_fingerprint := substring( - encode(extensions.digest(convert_to(p_key, 'UTF8'), 'sha256'), 'hex') - for 12 - ); - - delete from public.v2_provider_keys - where user_id = actor_id and provider = p_provider; - - secret_id := vault.create_secret( - p_key, - actor_id::text || ':' || p_provider || ':' || public.uuidv7()::text, - 'Cheatcode V2 BYOK provider key' - ); - - insert into public.v2_provider_keys ( - user_id, - provider, - vault_secret_id, - fingerprint - ) values ( - actor_id, - p_provider, - secret_id, - key_fingerprint - ) - returning id into row_id; - - return row_id; -end -$function$; - -create or replace function public.get_provider_key(p_provider text) returns text -language sql -stable -security definer -set search_path = '' -as $function$ - select secret.decrypted_secret - from public.v2_provider_keys key - join vault.decrypted_secrets secret on secret.id = key.vault_secret_id - where key.user_id = public.current_app_user() - and key.provider = p_provider - and key.deleted_at is null - and key.disabled_at is null - order by key.created_at desc - limit 1 -$function$; - -create or replace function public.delete_provider_key(p_provider text) returns void -language plpgsql -security definer -set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); -begin - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended( - 'cheatcode:provider-keys:' || actor_id::text, - 0 - ) - ); - delete from public.v2_provider_keys - where user_id = actor_id and provider = p_provider; -end -$function$; - -create or replace function public.delete_all_provider_keys() returns integer -language plpgsql -security definer -set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); - deleted_count integer; -begin - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended( - 'cheatcode:provider-keys:' || actor_id::text, - 0 - ) - ); - delete from public.v2_provider_keys where user_id = actor_id; - get diagnostics deleted_count = row_count; - return deleted_count; -end -$function$; - -create or replace function public.list_provider_key_revalidation_targets(p_limit integer) -returns table (user_id uuid, provider text, fingerprint text) -language sql -security definer -set search_path = '' -as $function$ - with targets as ( - select key.id - from public.v2_provider_keys key - where key.deleted_at is null - and key.disabled_at is null - and ( - key.last_revalidated_at is null - or key.last_revalidated_at < pg_catalog.now() - interval '23 hours' - ) - and ( - key.revalidation_claimed_at is null - or key.revalidation_claimed_at < pg_catalog.now() - interval '15 minutes' - ) - order by - key.last_revalidated_at asc nulls first, - key.revalidation_claimed_at asc nulls first, - key.created_at, - key.user_id, - key.provider - for update skip locked - limit least(greatest(coalesce(p_limit, 10), 1), 10) - ), claimed as ( - update public.v2_provider_keys key - set revalidation_claimed_at = pg_catalog.now(), - revalidation_lease_token = public.uuidv7() - from targets - where key.id = targets.id - returning key.user_id, key.provider, key.fingerprint - ) - select claimed.user_id, claimed.provider, claimed.fingerprint - from claimed -$function$; - -create or replace function public.claim_provider_key_revalidation_targets(p_limit integer) -returns table (user_id uuid, provider text, fingerprint text, lease_token uuid) -language sql -security definer -set search_path = '' -as $function$ - with targets as ( - select key.id - from public.v2_provider_keys key - where key.deleted_at is null - and key.disabled_at is null - and ( - key.last_revalidated_at is null - or key.last_revalidated_at < pg_catalog.now() - interval '23 hours' - ) - and ( - key.revalidation_claimed_at is null - or key.revalidation_claimed_at < pg_catalog.now() - interval '15 minutes' - ) - order by - key.last_revalidated_at asc nulls first, - key.revalidation_claimed_at asc nulls first, - key.created_at, - key.user_id, - key.provider - for update skip locked - limit least(greatest(coalesce(p_limit, 10), 1), 10) - ), claimed as ( - update public.v2_provider_keys key - set revalidation_claimed_at = pg_catalog.now(), - revalidation_lease_token = public.uuidv7() - from targets - where key.id = targets.id - returning key.user_id, key.provider, key.fingerprint, key.revalidation_lease_token - ) - select claimed.user_id, claimed.provider, claimed.fingerprint, claimed.revalidation_lease_token - from claimed -$function$; - -create or replace function public.scrub_current_user_audit() returns bigint -language plpgsql -security definer -set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); - scrubbed_count bigint; -begin - update public.v2_audit_log - set user_id = null, - resource_id = null, - metadata = jsonb_build_object('subject_erased', true) - where user_id = actor_id; - get diagnostics scrubbed_count = row_count; - return scrubbed_count; -end -$function$; - -create or replace function public.v2_audit_provider_key_change() returns trigger -language plpgsql -security definer -set search_path = '' -as $function$ -declare - audit_action text; -begin - if tg_op = 'UPDATE' - and (to_jsonb(new) - array[ - 'last_revalidated_at', - 'revalidation_claimed_at', - 'revalidation_lease_token' - ]) is not distinct from (to_jsonb(old) - array[ - 'last_revalidated_at', - 'revalidation_claimed_at', - 'revalidation_lease_token' - ]) then - return new; - end if; - - audit_action := case - when tg_op = 'INSERT' then 'provider_key.create' - when tg_op = 'DELETE' then 'provider_key.delete' - when old.deleted_at is null and new.deleted_at is not null then 'provider_key.delete' - when old.disabled_at is null and new.disabled_at is not null then 'provider_key.disable' - when old.disabled_at is not null and new.disabled_at is null then 'provider_key.enable' - else 'provider_key.update' - end; - - insert into public.v2_audit_log ( - user_id, - action, - resource_type, - resource_id, - metadata - ) values ( - coalesce(new.user_id, old.user_id), - audit_action, - 'provider_key', - coalesce(new.provider, old.provider), - jsonb_build_object('fingerprint', coalesce(new.fingerprint, old.fingerprint)) - ); - return coalesce(new, old); -end -$function$; - -create or replace function public.v2_audit_integration_change() returns trigger -language plpgsql -security definer -set search_path = '' -as $function$ -begin - if tg_op = 'UPDATE' - and (new.status, new.is_default) is not distinct from (old.status, old.is_default) then - return new; - end if; - - insert into public.v2_audit_log ( - user_id, - action, - resource_type, - resource_id, - metadata - ) values ( - coalesce(new.user_id, old.user_id), - 'integration.' || lower(tg_op), - 'integration', - coalesce(new.integration, old.integration), - jsonb_build_object('status', coalesce(new.status, old.status)) - ); - return coalesce(new, old); -end -$function$; - --- Supabase's Data API is not an application boundary for Cheatcode. Revoke all --- existing public-schema access for its standard roles; dashboard disablement is --- a separate platform switch verified during release QA. -revoke all privileges on all tables in schema public from public; -revoke all privileges on all sequences in schema public from public; - -do $data_api$ -declare - role_name text; - procedure_record record; -begin - for role_name in - select rolname - from pg_roles - where rolname in ('anon', 'authenticated', 'service_role') - loop - execute format( - 'revoke all privileges on all tables in schema public from %I', - role_name - ); - execute format( - 'revoke all privileges on all sequences in schema public from %I', - role_name - ); - end loop; - - for procedure_record in - select procedure.oid::regprocedure::text as identity - from pg_proc procedure - join pg_namespace namespace on namespace.oid = procedure.pronamespace - left join pg_depend extension_dependency - on extension_dependency.classid = 'pg_proc'::regclass - and extension_dependency.objid = procedure.oid - and extension_dependency.deptype = 'e' - where namespace.nspname = 'public' - and extension_dependency.objid is null - loop - execute format( - 'revoke execute on function %s from public', - procedure_record.identity - ); - for role_name in - select rolname - from pg_roles - where rolname in ('anon', 'authenticated', 'service_role') - loop - execute format( - 'revoke execute on function %s from %I', - procedure_record.identity, - role_name - ); - end loop; - end loop; -end -$data_api$; - --- New postgres-owned public objects must inherit the same closed Data API --- posture. Supabase-owned defaults are platform-managed and remain untouched. -alter default privileges for role postgres revoke all on tables from public; -alter default privileges for role postgres revoke all on sequences from public; -alter default privileges for role postgres revoke execute on functions from public; -alter default privileges for role postgres in schema public revoke all on tables from public; -alter default privileges for role postgres in schema public revoke all on sequences from public; -alter default privileges for role postgres in schema public revoke execute on functions from public; - -do $default_acl$ -declare - role_name text; -begin - for role_name in - select rolname - from pg_roles - where rolname in ('anon', 'authenticated', 'service_role') - loop - execute format( - 'alter default privileges for role postgres revoke all on tables from %I', - role_name - ); - execute format( - 'alter default privileges for role postgres revoke all on sequences from %I', - role_name - ); - execute format( - 'alter default privileges for role postgres revoke execute on functions from %I', - role_name - ); - execute format( - 'alter default privileges for role postgres in schema public revoke all on tables from %I', - role_name - ); - execute format( - 'alter default privileges for role postgres in schema public revoke all on sequences from %I', - role_name - ); - execute format( - 'alter default privileges for role postgres in schema public revoke execute on functions from %I', - role_name - ); - end loop; -end -$default_acl$; - -revoke all on table public.v2_provider_keys from app_worker; -grant select on table public.v2_provider_keys to app_worker; -grant update ( - disabled_at, - disabled_reason, - last_revalidated_at, - revalidation_claimed_at, - revalidation_lease_token -) on table public.v2_provider_keys to app_worker; - -revoke all on table public.v2_audit_log from app_worker; - -revoke all on schema extensions, vault from app_worker; -revoke create on schema public from app_worker; -grant usage on schema public to app_worker; - -revoke all on function - public.current_app_user(), - public.append_v2_audit_event(text, text, text, jsonb), - public.v2_delete_provider_vault_secret(), - public.v2_audit_provider_key_change(), - public.v2_audit_entitlement_change(), - public.v2_audit_integration_change(), - public.v2_touch_updated_at() -from app_worker; - -revoke all on function - public.uuidv7(), - public.set_provider_key(text, text), - public.get_provider_key(text), - public.delete_provider_key(text), - public.delete_all_provider_keys(), - public.list_provider_key_revalidation_targets(integer), - public.claim_provider_key_revalidation_targets(integer), - public.scrub_current_user_audit() -from app_worker; - -grant execute on function - public.uuidv7(), - public.set_provider_key(text, text), - public.get_provider_key(text), - public.delete_provider_key(text), - public.delete_all_provider_keys(), - public.list_provider_key_revalidation_targets(integer), - public.claim_provider_key_revalidation_targets(integer), - public.scrub_current_user_audit() -to app_worker; diff --git a/infra/supabase/migrations/post/0043_finalize_provider_keys_and_audit.sql b/infra/supabase/migrations/post/0043_finalize_provider_keys_and_audit.sql deleted file mode 100644 index 9ee74edc..00000000 --- a/infra/supabase/migrations/post/0043_finalize_provider_keys_and_audit.sql +++ /dev/null @@ -1,345 +0,0 @@ --- Run only after the hard-delete BYOK release is live. Historical tombstones --- are database-only state; install the managed-Vault-compatible hard-delete --- trigger before removing those rows so their encrypted payloads cannot remain. -create or replace function public.v2_delete_provider_vault_secret() returns trigger -language plpgsql -security definer -set search_path = '' -as $function$ -declare - secret_name text; - secret_description text; -begin - delete from vault.secrets - where id = old.vault_secret_id - returning name, description into secret_name, secret_description; - - if not found then - raise exception 'refusing to delete a provider key with a missing Vault secret'; - end if; - if secret_name not like old.user_id::text || ':' || old.provider || ':%' - or secret_description is distinct from 'Cheatcode V2 BYOK provider key' then - raise exception 'refusing to delete a provider key with mismatched Vault ownership metadata'; - end if; - return old; -end -$function$; - -delete from public.v2_provider_keys where deleted_at is not null; - -do $vault_contract$ -declare - invalid_count bigint; -begin - select count(*) - into invalid_count - from public.v2_provider_keys key - left join vault.secrets secret on secret.id = key.vault_secret_id - where secret.id is null - or secret.name not like key.user_id::text || ':' || key.provider || ':%' - or secret.description is distinct from 'Cheatcode V2 BYOK provider key'; - if invalid_count > 0 then - raise exception - 'BYOK contraction refused: % provider keys lack an exact owned Vault secret', - invalid_count; - end if; - - select count(*) - into invalid_count - from vault.secrets secret - where secret.description = 'Cheatcode V2 BYOK provider key' - and not exists ( - select 1 - from public.v2_provider_keys key - where key.vault_secret_id = secret.id - ); - if invalid_count > 0 then - raise exception - 'BYOK contraction refused: % unreferenced Cheatcode Vault secrets require review', - invalid_count; - end if; -end -$vault_contract$; - -drop function public.set_provider_key(text, text); - -create function public.set_provider_key(p_provider text, p_key text) returns void -language plpgsql -security definer -set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); - secret_id uuid; - key_fingerprint text; -begin - if p_provider is null or p_provider not in ( - 'anthropic', - 'openai', - 'google', - 'openrouter', - 'deepseek', - 'exa', - 'firecrawl', - 'llamaparse' - ) then - raise exception 'unsupported provider'; - end if; - if p_key is null or btrim(p_key) = '' or octet_length(p_key) > 65536 then - raise exception 'provider key must contain between 1 and 65536 bytes'; - end if; - - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended( - 'cheatcode:provider-keys:' || actor_id::text, - 0 - ) - ); - - key_fingerprint := substring( - encode(extensions.digest(convert_to(p_key, 'UTF8'), 'sha256'), 'hex') - for 12 - ); - - delete from public.v2_provider_keys - where user_id = actor_id and provider = p_provider; - - secret_id := vault.create_secret( - p_key, - actor_id::text || ':' || p_provider || ':' || public.uuidv7()::text, - 'Cheatcode V2 BYOK provider key' - ); - - insert into public.v2_provider_keys ( - user_id, - provider, - vault_secret_id, - fingerprint - ) values ( - actor_id, - p_provider, - secret_id, - key_fingerprint - ); -end -$function$; - -create or replace function public.get_provider_key(p_provider text) returns text -language sql -stable -security definer -set search_path = '' -as $function$ - select secret.decrypted_secret - from public.v2_provider_keys key - join vault.decrypted_secrets secret on secret.id = key.vault_secret_id - where key.user_id = public.current_app_user() - and key.provider = p_provider - and key.disabled_at is null -$function$; - -create or replace function public.delete_provider_key(p_provider text) returns void -language plpgsql -security definer -set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); -begin - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended( - 'cheatcode:provider-keys:' || actor_id::text, - 0 - ) - ); - delete from public.v2_provider_keys - where user_id = actor_id and provider = p_provider; -end -$function$; - -create or replace function public.delete_all_provider_keys() returns integer -language plpgsql -security definer -set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); - deleted_count integer; -begin - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended( - 'cheatcode:provider-keys:' || actor_id::text, - 0 - ) - ); - delete from public.v2_provider_keys where user_id = actor_id; - get diagnostics deleted_count = row_count; - return deleted_count; -end -$function$; - -create or replace function public.claim_provider_key_revalidation_targets(p_limit integer) -returns table (user_id uuid, provider text, fingerprint text, lease_token uuid) -language sql -security definer -set search_path = '' -as $function$ - with targets as ( - select key.user_id, key.provider - from public.v2_provider_keys key - where key.disabled_at is null - and ( - key.last_revalidated_at is null - or key.last_revalidated_at < pg_catalog.now() - interval '23 hours' - ) - and ( - key.revalidation_claimed_at is null - or key.revalidation_claimed_at < pg_catalog.now() - interval '15 minutes' - ) - order by - key.last_revalidated_at asc nulls first, - key.revalidation_claimed_at asc nulls first, - key.created_at, - key.user_id, - key.provider - for update skip locked - limit least(greatest(coalesce(p_limit, 10), 1), 10) - ), claimed as ( - update public.v2_provider_keys key - set revalidation_claimed_at = pg_catalog.now(), - revalidation_lease_token = public.uuidv7() - from targets - where key.user_id = targets.user_id - and key.provider = targets.provider - returning key.user_id, key.provider, key.fingerprint, key.revalidation_lease_token - ) - select claimed.user_id, claimed.provider, claimed.fingerprint, claimed.revalidation_lease_token - from claimed -$function$; - -drop function public.list_provider_key_revalidation_targets(integer); - -create or replace function public.v2_audit_provider_key_change() returns trigger -language plpgsql -security definer -set search_path = '' -as $function$ -declare - audit_action text; -begin - if tg_op = 'UPDATE' - and (to_jsonb(new) - array[ - 'last_revalidated_at', - 'revalidation_claimed_at', - 'revalidation_lease_token' - ]) is not distinct from (to_jsonb(old) - array[ - 'last_revalidated_at', - 'revalidation_claimed_at', - 'revalidation_lease_token' - ]) then - return new; - end if; - - audit_action := case - when tg_op = 'INSERT' then 'provider_key.create' - when tg_op = 'DELETE' then 'provider_key.delete' - when old.disabled_at is null and new.disabled_at is not null then 'provider_key.disable' - when old.disabled_at is not null and new.disabled_at is null then 'provider_key.enable' - else 'provider_key.update' - end; - - insert into public.v2_audit_log ( - user_id, - action, - resource_type, - resource_id, - metadata - ) values ( - coalesce(new.user_id, old.user_id), - audit_action, - 'provider_key', - coalesce(new.provider, old.provider), - jsonb_build_object('fingerprint', coalesce(new.fingerprint, old.fingerprint)) - ); - return coalesce(new, old); -end -$function$; - -alter table public.v2_provider_keys - drop constraint v2_provider_keys_pkey; - -drop index if exists public.v2_provider_keys_user_provider_idx; - -alter table public.v2_provider_keys - drop column id, - drop column last_used_at, - drop column deleted_at, - add constraint v2_provider_keys_pkey primary key (user_id, provider); - -drop policy if exists v2_provider_keys_select_own on public.v2_provider_keys; -drop policy if exists v2_provider_keys_insert_own on public.v2_provider_keys; -drop policy if exists v2_provider_keys_update_own on public.v2_provider_keys; -drop policy if exists v2_provider_keys_delete_own on public.v2_provider_keys; - -create policy v2_provider_keys_select_own - on public.v2_provider_keys - for select - to app_worker - using (user_id::text = (select current_setting('app.user_id', true))); - -create policy v2_provider_keys_update_own - on public.v2_provider_keys - for update - to app_worker - using (user_id::text = (select current_setting('app.user_id', true))) - with check (user_id::text = (select current_setting('app.user_id', true))); - -revoke all on table public.v2_provider_keys from app_worker; -grant select on table public.v2_provider_keys to app_worker; -grant update ( - disabled_at, - disabled_reason, - last_revalidated_at, - revalidation_claimed_at, - revalidation_lease_token -) on table public.v2_provider_keys to app_worker; - -revoke all on function - public.set_provider_key(text, text), - public.get_provider_key(text), - public.delete_provider_key(text), - public.delete_all_provider_keys(), - public.claim_provider_key_revalidation_targets(integer) -from app_worker; - -grant execute on function - public.set_provider_key(text, text), - public.get_provider_key(text), - public.delete_provider_key(text), - public.delete_all_provider_keys(), - public.claim_provider_key_revalidation_targets(integer) -to app_worker; - --- Custom skills have no external payload. Their only historical tombstone is --- safe to remove before enforcing the canonical full unique key. -delete from public.v2_user_skills where deleted_at is not null; - -drop index if exists public.v2_user_skills_user_name_idx; -drop index if exists public.v2_user_skills_user_idx; - -alter table public.v2_user_skills drop column deleted_at; - -create unique index v2_user_skills_user_name_idx - on public.v2_user_skills (user_id, name); - --- Audit events are an operational sink. Application reads and the generic --- append escape hatch are intentionally removed; only narrow trigger/RPC writes --- remain. -drop policy if exists v2_audit_log_select_own on public.v2_audit_log; -drop policy if exists v2_audit_log_insert_system on public.v2_audit_log; -revoke all on table public.v2_audit_log from app_worker; -drop function public.append_v2_audit_event(text, text, text, jsonb); - -alter table public.v2_audit_log - drop column ip_address, - drop column user_agent; diff --git a/infra/supabase/migrations/post/0044_finalize_generated_output_ownership.sql b/infra/supabase/migrations/post/0044_finalize_generated_output_ownership.sql deleted file mode 100644 index e1c0519e..00000000 --- a/infra/supabase/migrations/post/0044_finalize_generated_output_ownership.sql +++ /dev/null @@ -1,48 +0,0 @@ --- Every retained artifact must belong to the run that created it. Historical --- rows with no run are R2-backed and must be removed object-first by the --- deployed retention workflow; this migration never deletes them silently. -do $output_preflight$ -declare - ownerless_count bigint; -begin - select count(*) - into ownerless_count - from public.v2_generated_outputs - where agent_run_id is null; - if ownerless_count > 0 then - raise exception - 'generated-output contraction refused: % rows have no agent_run_id; delete their R2 objects before their database rows and retry', - ownerless_count; - end if; -end -$output_preflight$; - -alter table public.v2_generated_outputs - drop constraint v2_generated_outputs_project_user_fk, - drop constraint v2_generated_outputs_agent_run_user_fk, - drop constraint v2_generated_outputs_size_check, - drop constraint v2_generated_outputs_sha256_check, - drop constraint v2_generated_outputs_kind_check, - drop constraint v2_generated_outputs_metadata_check; - -drop index if exists public.v2_generated_outputs_project_created_idx; -drop index if exists public.v2_generated_outputs_agent_run_idx; -drop index if exists public.v2_generated_outputs_expiry_idx; - -alter table public.v2_generated_outputs - alter column agent_run_id set not null, - drop column project_id, - drop column kind, - drop column size_bytes, - drop column sha256, - drop column metadata, - add constraint v2_generated_outputs_agent_run_user_fk - foreign key (agent_run_id, user_id) - references public.v2_agent_runs (id, user_id) - on delete restrict; - -create index v2_generated_outputs_agent_run_idx - on public.v2_generated_outputs (agent_run_id); - -create index v2_generated_outputs_expiry_idx - on public.v2_generated_outputs (expires_at, id); diff --git a/infra/supabase/migrations/post/0045_remove_unused_v2_state.sql b/infra/supabase/migrations/post/0045_remove_unused_v2_state.sql deleted file mode 100644 index 63277054..00000000 --- a/infra/supabase/migrations/post/0045_remove_unused_v2_state.sql +++ /dev/null @@ -1,123 +0,0 @@ --- Drop retired V2 product surfaces that have no external resource ownership. --- Generated outputs, projects, and integrations are deliberately absent here: --- their R2, Daytona, and Composio cleanup is handled by deployed workflows. -drop table if exists public.v2_scheduled_run_history restrict; -drop table if exists public.v2_scheduled_agents restrict; -drop table if exists public.v2_notifications restrict; -drop table if exists public.v2_push_subscriptions restrict; -drop table if exists public.v2_usage_daily_totals restrict; -drop table if exists public.v2_usage_events restrict; - -drop trigger if exists trg_v2_users_updated on public.v2_users; - -alter table public.v2_users - drop column if exists updated_at; - -alter table public.v2_user_profiles - drop column if exists created_at; - -alter table public.v2_deleted_clerk_identities - drop column if exists deleted_at; - -alter table public.v2_agent_runs - drop column if exists share_token, - drop column if exists error; - -alter table public.v2_projects - drop column if exists archived_pending_action, - drop column if exists workspace_cleanup_requested_at, - drop column if exists workspace_cleanup_completed_at; - -alter table public.v2_entitlements - drop column if exists max_projects, - drop column if exists quota_sandbox_hours, - drop column if exists quota_scheduled_runs, - drop column if exists quota_composio_calls; - --- Workflow generations cross the Worker boundary as JavaScript Dates. Store --- the same millisecond precision in Postgres so a retry can compare the exact --- immutable generation instead of losing server-side microseconds in transit. -alter table public.v2_projects - alter column deleted_at type timestamptz(3) - using date_trunc('milliseconds', deleted_at); - -alter table public.v2_threads - alter column deleted_at type timestamptz(3) - using date_trunc('milliseconds', deleted_at); - --- The keyset indexes are the only listing paths retained by the current code. -drop index if exists public.v2_projects_user_created_idx; -drop index if exists public.v2_threads_user_project_created_idx; -drop index if exists public.v2_threads_project_created_idx; -drop index if exists public.v2_messages_thread_created_idx; -drop index if exists public.v2_messages_user_created_idx; -drop index if exists public.v2_threads_user_recent_idx; -drop index if exists public.v2_user_skills_user_idx; - -create index v2_projects_deletion_queue_idx - on public.v2_projects (deleted_at, id) - where deleted_at is not null; - -create index v2_threads_project_delete_idx - on public.v2_threads (user_id, project_id, id); - -create index v2_threads_deletion_queue_idx - on public.v2_threads (deleted_at, id) - where deleted_at is not null; - -create index v2_agent_runs_thread_delete_page_idx - on public.v2_agent_runs (user_id, thread_id, id); - --- Replace the historical blanket CRUD grant with the least-privilege set used --- by the current query modules. Column-level billing SELECT is intentional: --- retention and deletion need identity/timestamps, never webhook payloads. -revoke all on table - public._audit_archive_manifest, - public._raw_migrations, - public.v2_agent_runs, - public.v2_audit_log, - public.v2_billing_events, - public.v2_deleted_clerk_identities, - public.v2_entitlements, - public.v2_generated_outputs, - public.v2_messages, - public.v2_projects, - public.v2_provider_keys, - public.v2_threads, - public.v2_user_integrations, - public.v2_user_profiles, - public.v2_user_skills, - public.v2_users -from app_worker; - -grant select, insert, update on table - public.v2_agent_runs, - public.v2_entitlements, - public.v2_user_profiles -to app_worker; - -grant select, insert on table public.v2_messages to app_worker; - -grant select, insert, delete on table public.v2_generated_outputs to app_worker; - -grant select, insert, update, delete on table - public.v2_projects, - public.v2_threads, - public.v2_user_integrations, - public.v2_user_skills, - public.v2_users -to app_worker; - -grant insert, update, delete on table public.v2_billing_events to app_worker; -grant select (id, processed_at, user_id) on table public.v2_billing_events to app_worker; - -grant select, insert on table public.v2_deleted_clerk_identities to app_worker; - -grant select on table public.v2_provider_keys to app_worker; -grant update ( - disabled_at, - disabled_reason, - last_revalidated_at, - revalidation_claimed_at, - revalidation_lease_token -) on table public.v2_provider_keys to app_worker; diff --git a/infra/supabase/migrations/post/0046_remove_v1_database_surface.sql b/infra/supabase/migrations/post/0046_remove_v1_database_surface.sql deleted file mode 100644 index 3a8203a5..00000000 --- a/infra/supabase/migrations/post/0046_remove_v1_database_surface.sql +++ /dev/null @@ -1,331 +0,0 @@ --- V1 project rows are the durable inventory for externally owned Daytona and --- Vercel resources. Refuse to erase that inventory unless the --- migration runner supplies a fresh, database-bound cleanup attestation from --- the protected production environment. A clean V2-only database has no V1 --- projects table and needs no one-time attestation. -do $external_cleanup_attestation$ -declare - attestation jsonb; - attestation_keys text[]; - checked_at timestamptz; - database_keys text[]; - expected_reference_count bigint; - expires_at timestamptz; - inventory_keys text[]; - inventory_count bigint; - inventory_sha256 text; - migration_sha256 text; - provider text; - provider_keys text[]; - proof jsonb; - proof_keys text[]; - raw_attestation text; -begin - if to_regclass('public.projects') is null then - return; - end if; - - raw_attestation := current_setting('cheatcode.migration_attestation', true); - migration_sha256 := current_setting('cheatcode.migration_sha256', true); - if nullif(btrim(raw_attestation), '') is null - or length(raw_attestation) > 65536 - or migration_sha256 !~ '^[0-9a-f]{64}$' then - raise exception 'V1 external cleanup attestation is required'; - end if; - - begin - attestation := raw_attestation::jsonb; - exception when others then - raise exception 'V1 external cleanup attestation is not valid JSON'; - end; - - if jsonb_typeof(attestation) is distinct from 'object' then - raise exception 'V1 external cleanup attestation must be an object'; - end if; - - select array_agg(attestation_key order by attestation_key) - into attestation_keys - from jsonb_object_keys(attestation) attestation_key; - if attestation_keys is distinct from array[ - 'database', - 'expiresAt', - 'inventory', - 'migration', - 'migrationSha256', - 'providers', - 'schemaVersion', - 'scope' - ]::text[] - or jsonb_typeof(attestation->'schemaVersion') is distinct from 'number' - or jsonb_typeof(attestation->'scope') is distinct from 'string' - or jsonb_typeof(attestation->'migration') is distinct from 'string' - or jsonb_typeof(attestation->'migrationSha256') is distinct from 'string' - or jsonb_typeof(attestation->'expiresAt') is distinct from 'string' - or jsonb_typeof(attestation->'database') is distinct from 'object' - or jsonb_typeof(attestation->'inventory') is distinct from 'object' - or jsonb_typeof(attestation->'providers') is distinct from 'object' - or attestation->>'schemaVersion' is distinct from '1' - or attestation->>'scope' is distinct from 'v1-external-cleanup' - or attestation->>'migration' is distinct from - 'infra/supabase/migrations/post/0046_remove_v1_database_surface.sql' - or attestation->>'migrationSha256' is distinct from migration_sha256 then - raise exception 'V1 external cleanup attestation identity does not match this migration target'; - end if; - - select array_agg(database_key order by database_key) - into database_keys - from jsonb_object_keys(attestation->'database') database_key; - select array_agg(inventory_key order by inventory_key) - into inventory_keys - from jsonb_object_keys(attestation->'inventory') inventory_key; - if database_keys is distinct from array['name', 'systemIdentifier']::text[] - or inventory_keys is distinct from array['count', 'sha256']::text[] - or jsonb_typeof(attestation#>'{database,name}') is distinct from 'string' - or jsonb_typeof(attestation#>'{database,systemIdentifier}') is distinct from 'string' - or jsonb_typeof(attestation#>'{inventory,count}') is distinct from 'number' - or jsonb_typeof(attestation#>'{inventory,sha256}') is distinct from 'string' - or attestation#>>'{database,name}' is distinct from current_database() - or attestation#>>'{database,systemIdentifier}' is distinct from - (select system_identifier::text from pg_control_system()) then - raise exception 'V1 external cleanup attestation database inventory identity is invalid'; - end if; - - select - count(*), - encode( - extensions.digest( - convert_to( - coalesce( - jsonb_agg(to_jsonb(project_record) order by project_record.project_id), - '[]'::jsonb - )::text, - 'UTF8' - ), - 'sha256' - ), - 'hex' - ) - into inventory_count, inventory_sha256 - from public.projects project_record; - - if attestation#>>'{inventory,count}' is distinct from inventory_count::text - or attestation#>>'{inventory,sha256}' is distinct from inventory_sha256 then - raise exception 'V1 external cleanup attestation does not match the live project inventory'; - end if; - - begin - expires_at := (attestation->>'expiresAt')::timestamptz; - exception when others then - raise exception 'V1 external cleanup attestation has an invalid expiry'; - end; - if attestation->>'expiresAt' !~ - '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[.][0-9]{3}Z$' - or expires_at <= clock_timestamp() - or expires_at > clock_timestamp() + interval '7 days' then - raise exception 'V1 external cleanup attestation is expired or valid for too long'; - end if; - - select array_agg(provider_name order by provider_name) - into provider_keys - from jsonb_object_keys(attestation->'providers') provider_name; - if provider_keys is distinct from array['daytona', 'vercel']::text[] then - raise exception 'V1 external cleanup attestation must cover Daytona and Vercel'; - end if; - - foreach provider in array provider_keys - loop - proof := attestation->'providers'->provider; - expected_reference_count := case provider - when 'daytona' then 297 - when 'vercel' then 9 - end; - if jsonb_typeof(proof) is distinct from 'object' then - raise exception 'V1 % cleanup proof must be an object', provider; - end if; - select array_agg(proof_key order by proof_key) - into proof_keys - from jsonb_object_keys(proof) proof_key; - if proof_keys is distinct from array[ - 'checkedAt', - 'evidenceReference', - 'evidenceSha256', - 'referencedResourceCount', - 'remainingResourceCount', - 'status' - ]::text[] - or jsonb_typeof(proof->'checkedAt') is distinct from 'string' - or jsonb_typeof(proof->'evidenceReference') is distinct from 'string' - or jsonb_typeof(proof->'evidenceSha256') is distinct from 'string' - or jsonb_typeof(proof->'referencedResourceCount') is distinct from 'number' - or jsonb_typeof(proof->'remainingResourceCount') is distinct from 'number' - or jsonb_typeof(proof->'status') is distinct from 'string' then - raise exception 'V1 % cleanup proof shape is invalid', provider; - end if; - begin - checked_at := (proof->>'checkedAt')::timestamptz; - exception when others then - raise exception 'V1 % cleanup proof has an invalid check time', provider; - end; - if proof->>'checkedAt' !~ - '^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}[.][0-9]{3}Z$' - or proof->>'status' is distinct from 'verified-clean' - or proof->>'referencedResourceCount' is distinct from expected_reference_count::text - or proof->>'remainingResourceCount' is distinct from '0' - or proof->>'evidenceSha256' !~ '^[0-9a-f]{64}$' - or proof->>'evidenceSha256' ~ '^0{64}$' - or length(btrim(coalesce(proof->>'evidenceReference', ''))) not between 1 and 512 - or proof->>'evidenceReference' is distinct from btrim(proof->>'evidenceReference') - or checked_at < clock_timestamp() - interval '7 days' - or checked_at > clock_timestamp() + interval '5 minutes' then - raise exception 'V1 % external cleanup proof is incomplete, stale, or not clean', provider; - end if; - end loop; -end -$external_cleanup_attestation$; - --- The V1 runtime was permanently removed. Unschedule its only database cron --- entry before dropping the exact legacy function set. -do $cron_cleanup$ -declare - job_record record; - was_unscheduled boolean; -begin - if to_regprocedure('cron.unschedule(bigint)') is not null - and to_regclass('cron.job') is not null then - for job_record in execute - $query$ - select jobid - from cron.job - where jobname = 'reset-expired-quotas' - or command ~ 'public\.(reset_expired_quotas|reset_monthly_token_quotas)\s*\(' - $query$ - loop - execute 'select cron.unschedule($1)' into was_unscheduled using job_record.jobid; - if was_unscheduled is distinct from true then - raise exception 'failed to unschedule obsolete cron job %', job_record.jobid; - end if; - end loop; - end if; -end -$cron_cleanup$; - --- Trigger dependencies must go before their exact backing functions. Guard --- every relation so the same migration also works on a clean V2-only database. -do $legacy_triggers$ -begin - if to_regclass('public.agent_runs') is not null then - execute 'drop trigger if exists update_agent_runs_updated_at on public.agent_runs'; - end if; - if to_regclass('public.messages') is not null then - execute 'drop trigger if exists update_messages_updated_at on public.messages'; - end if; - if to_regclass('public.projects') is not null then - execute 'drop trigger if exists update_projects_updated_at on public.projects'; - end if; - if to_regclass('public.threads') is not null then - execute 'drop trigger if exists update_threads_updated_at on public.threads'; - end if; - if to_regclass('public.user_mcp_credential_profiles') is not null then - execute 'drop trigger if exists trigger_auto_enable_dashboard_mcp on public.user_mcp_credential_profiles'; - execute 'drop trigger if exists trigger_auto_enable_dashboard_mcp_on_update on public.user_mcp_credential_profiles'; - execute 'drop trigger if exists trigger_ensure_single_default_profile on public.user_mcp_credential_profiles'; - execute 'drop trigger if exists trigger_update_credential_profile_timestamp on public.user_mcp_credential_profiles'; - end if; - if to_regclass('public.user_dashboard_mcp_preferences') is not null then - execute 'drop trigger if exists trigger_update_dashboard_mcp_preference_timestamp on public.user_dashboard_mcp_preferences'; - end if; -end -$legacy_triggers$; - --- Resolve signatures through pg_catalog instead of spelling removed composite --- or vector types in DROP statements. This keeps clean local databases valid --- while still dropping only the 41 production-audited V1 identities. -do $legacy_functions$ -declare - function_record record; - original_search_path text := current_setting('search_path'); -begin - -- `oidvectortypes` omits schema qualifiers for visible types. Pin an empty - -- path while resolving the audited signatures so matching is independent of - -- the migration client's ambient search_path. - perform set_config('search_path', '', true); - for function_record in - with legacy_function(name, arguments) as ( - values - ('auto_enable_dashboard_mcp_on_credential_add', ''), - ('calculate_kb_entry_tokens', ''), - ('check_and_reset_quotas', ''), - ('consume_tokens_atomic', 'text, integer, text, text, text, integer, integer, numeric'), - ('consume_tokens_atomic', 'text, integer, uuid, uuid, text, integer, integer, numeric, text'), - ('count_deployed_projects_for_account', 'text'), - ('create_account', 'text, text'), - ('create_clerk_user_account', 'text, text, text'), - ('ensure_single_default_profile', ''), - ('get_account_billing_status', 'text'), - ('get_account_by_slug', 'text'), - ('get_account_id', 'text'), - ('get_account_id_for_clerk_user', 'text'), - ('get_account_members', 'text, integer, integer'), - ('get_accounts', ''), - ('get_current_clerk_user_id', ''), - ('get_llm_formatted_messages', 'uuid'), - ('get_missing_credentials_for_template', 'uuid, text'), - ('get_or_create_user', 'text, text'), - ('get_personal_account', ''), - ('get_user_billing', 'text'), - ('get_user_enabled_dashboard_mcps', 'text'), - ('has_freestyle_deployment', 'public.projects'), - ('install_template_as_instance', 'uuid, text, character varying'), - ('match_components', 'public.vector, double precision, integer'), - ('match_mobile_components', 'public.vector, double precision, integer'), - ('remove_account_member', 'text, text'), - ('reset_expired_quotas', ''), - ('reset_monthly_token_quotas', ''), - ('service_role_upsert_customer_subscription', 'text, jsonb, jsonb'), - ('sync_clerk_email_to_billing', 'text'), - ('sync_clerk_email_to_billing_with_params', 'text, text'), - ('sync_clerk_user_data', ''), - ('update_account', 'text, text, text, jsonb, boolean'), - ('update_credential_profile_timestamp', ''), - ('update_dashboard_mcp_preference_timestamp', ''), - ('update_kb_entry_timestamp', ''), - ('update_project_deployment_metadata', 'text, text, text, text[], text, boolean'), - ('update_updated_at_column', ''), - ('update_updated_at_timestamp', ''), - ('update_user_tokens', 'text, integer') - ) - select procedure.oid::regprocedure::text as identity - from legacy_function - join pg_proc procedure - on procedure.proname = legacy_function.name - and pg_catalog.oidvectortypes(procedure.proargtypes) = legacy_function.arguments - join pg_namespace namespace - on namespace.oid = procedure.pronamespace - and namespace.nspname = 'public' - left join pg_depend extension_dependency - on extension_dependency.classid = 'pg_proc'::regclass - and extension_dependency.objid = procedure.oid - and extension_dependency.deptype = 'e' - where extension_dependency.objid is null - loop - execute format('drop function %s restrict', function_record.identity); - end loop; - perform set_config('search_path', original_search_path, true); -end -$legacy_functions$; - --- Child-first order is explicit; RESTRICT turns any unknown dependency into a --- release-stopping review instead of widening the deletion boundary. -drop table if exists public.agent_runs restrict; -drop table if exists public.messages restrict; -drop table if exists public.threads restrict; -drop table if exists public.projects restrict; -drop table if exists public.component_index restrict; -drop table if exists public.mobile_component_index restrict; -drop table if exists public.token_usage_log restrict; -drop table if exists public.user_dashboard_mcp_preferences restrict; -drop table if exists public.user_mcp_credential_profiles restrict; -drop table if exists public.user_openrouter_keys restrict; -drop table if exists public.user_provider_keys restrict; -drop table if exists public.user_subscriptions restrict; -drop table if exists public.users restrict; diff --git a/infra/supabase/migrations/post/0047_remove_mastra_persistence.sql b/infra/supabase/migrations/post/0047_remove_mastra_persistence.sql deleted file mode 100644 index 594baf44..00000000 --- a/infra/supabase/migrations/post/0047_remove_mastra_persistence.sql +++ /dev/null @@ -1,41 +0,0 @@ --- Mastra runs with the in-memory storage boundary in the current Worker. The --- old Postgres store is therefore dead state, including five abandoned thread --- rows. Enumerate every audited relation and keep RESTRICT throughout. -drop table if exists mastra.cheatcode_memory_messages restrict; -drop table if exists mastra.mastra_agent_versions restrict; -drop table if exists mastra.mastra_agents restrict; -drop table if exists mastra.mastra_ai_spans restrict; -drop table if exists mastra.mastra_background_tasks restrict; -drop table if exists mastra.mastra_channel_config restrict; -drop table if exists mastra.mastra_channel_installations restrict; -drop table if exists mastra.mastra_dataset_items restrict; -drop table if exists mastra.mastra_dataset_versions restrict; -drop table if exists mastra.mastra_datasets restrict; -drop table if exists mastra.mastra_experiment_results restrict; -drop table if exists mastra.mastra_experiments restrict; -drop table if exists mastra.mastra_favorites restrict; -drop table if exists mastra.mastra_mcp_client_versions restrict; -drop table if exists mastra.mastra_mcp_clients restrict; -drop table if exists mastra.mastra_mcp_server_versions restrict; -drop table if exists mastra.mastra_mcp_servers restrict; -drop table if exists mastra.mastra_messages restrict; -drop table if exists mastra.mastra_observational_memory restrict; -drop table if exists mastra.mastra_prompt_block_versions restrict; -drop table if exists mastra.mastra_prompt_blocks restrict; -drop table if exists mastra.mastra_resources restrict; -drop table if exists mastra.mastra_schedule_triggers restrict; -drop table if exists mastra.mastra_schedules restrict; -drop table if exists mastra.mastra_scorer_definition_versions restrict; -drop table if exists mastra.mastra_scorer_definitions restrict; -drop table if exists mastra.mastra_scorers restrict; -drop table if exists mastra.mastra_skill_blobs restrict; -drop table if exists mastra.mastra_skill_versions restrict; -drop table if exists mastra.mastra_skills restrict; -drop table if exists mastra.mastra_threads restrict; -drop table if exists mastra.mastra_workflow_snapshot restrict; -drop table if exists mastra.mastra_workspace_versions restrict; -drop table if exists mastra.mastra_workspaces restrict; - -drop sequence if exists mastra.cheatcode_memory_messages_id_seq restrict; -drop function if exists mastra.trigger_set_timestamps() restrict; -drop schema if exists mastra restrict; diff --git a/infra/supabase/migrations/post/0048_remove_unused_extensions.sql b/infra/supabase/migrations/post/0048_remove_unused_extensions.sql deleted file mode 100644 index be56b183..00000000 --- a/infra/supabase/migrations/post/0048_remove_unused_extensions.sql +++ /dev/null @@ -1,25 +0,0 @@ --- These extensions have no surviving application or platform dependency after --- the V2 cleanup. RESTRICT is intentional: unexpected managed dependencies --- must stop the release for review. `vector` remains because Supabase's managed --- storage.vector_indexes relation depends on its public.vector type. `pg_cron` --- remains as the database-owned audit-partition scheduler. -create extension if not exists pg_cron; - -drop extension if exists moddatetime restrict; -drop extension if exists pg_trgm restrict; -drop extension if exists "uuid-ossp" restrict; -drop extension if exists wrappers restrict; - -do $vector_schema$ -begin - if exists ( - select 1 - from pg_extension extension - join pg_namespace namespace on namespace.oid = extension.extnamespace - where extension.extname = 'vector' - and namespace.nspname <> 'extensions' - ) then - execute 'alter extension vector set schema extensions'; - end if; -end -$vector_schema$; diff --git a/infra/supabase/migrations/post/0050_finalize_canonical_project_workspaces.sql b/infra/supabase/migrations/post/0050_finalize_canonical_project_workspaces.sql deleted file mode 100644 index 54c9dcd7..00000000 --- a/infra/supabase/migrations/post/0050_finalize_canonical_project_workspaces.sql +++ /dev/null @@ -1,38 +0,0 @@ --- The release-owned workspace reconciliation Workflow must complete while the --- gateway is closed before this contraction runs. The migration never renames --- a live folder or rewrites a project path; it verifies the generic invariant --- across every remaining row and makes that invariant permanent. -do $preflight$ -declare - noncanonical_count bigint; -begin - select count(*) - into noncanonical_count - from public.v2_projects project - where not ( - octet_length(project.workspace_slug) between 38 and 64 - and right(project.workspace_slug, 37) = '-' || project.id::text - and left(project.workspace_slug, length(project.workspace_slug) - 37) - ~ '^[a-z0-9]+(-[a-z0-9]+)*$' - ); - - if noncanonical_count > 0 then - raise exception - 'canonical workspace reconciliation is incomplete for % projects', - noncanonical_count; - end if; -end -$preflight$; - -alter table public.v2_projects - add constraint v2_projects_workspace_slug_canonical_check - check ( - octet_length(workspace_slug) between 38 and 64 - and right(workspace_slug, 37) = '-' || id::text - and left(workspace_slug, length(workspace_slug) - 37) - ~ '^[a-z0-9]+(-[a-z0-9]+)*$' - ) - not valid; - -alter table public.v2_projects - validate constraint v2_projects_workspace_slug_canonical_check; diff --git a/infra/supabase/migrations/post/0051_resource_deletion_jobs.sql b/infra/supabase/migrations/post/0051_resource_deletion_jobs.sql deleted file mode 100644 index 03a45103..00000000 --- a/infra/supabase/migrations/post/0051_resource_deletion_jobs.sql +++ /dev/null @@ -1,51 +0,0 @@ -create table public.v2_resource_deletion_jobs ( - id uuid primary key default public.uuidv7(), - user_id uuid not null - constraint v2_resource_deletion_jobs_user_id_v2_users_id_fk - references public.v2_users(id) on delete cascade, - kind text not null, - resource_id uuid not null, - generation timestamptz(3) not null, - phase text not null default 'runs', - cursor uuid, - continuation integer not null default 0, - status text not null default 'queued', - lease_token uuid, - lease_expires_at timestamptz(3), - failure_count integer not null default 0, - next_attempt_at timestamptz(3) not null default now(), - last_error_code text, - constraint v2_resource_deletion_jobs_kind_check - check (kind in ('project-deletion', 'thread-deletion')), - constraint v2_resource_deletion_jobs_phase_check - check (phase in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')), - constraint v2_resource_deletion_jobs_status_check - check (status in ('queued', 'leased', 'quarantined')), - constraint v2_resource_deletion_jobs_counter_check - check (continuation >= 0 and failure_count >= 0), - constraint v2_resource_deletion_jobs_lease_check - check ( - (status = 'leased' and lease_token is not null and lease_expires_at is not null) - or - (status <> 'leased' and lease_token is null and lease_expires_at is null) - ) -); - -create unique index v2_resource_deletion_jobs_generation_uidx - on public.v2_resource_deletion_jobs (kind, resource_id, generation); - -create index v2_resource_deletion_jobs_user_idx - on public.v2_resource_deletion_jobs (user_id); - -create index v2_resource_deletion_jobs_ready_idx - on public.v2_resource_deletion_jobs (next_attempt_at, id) - where status = 'queued'; - -create index v2_resource_deletion_jobs_lease_idx - on public.v2_resource_deletion_jobs (lease_expires_at, id) - where status = 'leased'; - -revoke all on table public.v2_resource_deletion_jobs -from public, anon, authenticated, service_role, app_worker; - -grant select, insert, update, delete on table public.v2_resource_deletion_jobs to app_worker; diff --git a/infra/supabase/migrations/post/0052_remove_relational_residue.sql b/infra/supabase/migrations/post/0052_remove_relational_residue.sql deleted file mode 100644 index 24882723..00000000 --- a/infra/supabase/migrations/post/0052_remove_relational_residue.sql +++ /dev/null @@ -1,25 +0,0 @@ --- Generated outputs are stored exclusively in the R2 bucket bound as --- `R2_OUTPUTS` (`cheatcode-outputs`). Persisting the deployment-level bucket --- identity created a second source of truth without supporting another bucket. -do $$ -begin - if exists ( - select 1 - from public.v2_generated_outputs - where r2_bucket is distinct from 'cheatcode-outputs' - ) then - raise exception 'v2_generated_outputs contains an unexpected R2 bucket'; - end if; -end -$$; - -alter table public.v2_generated_outputs - drop constraint v2_generated_outputs_r2_object_key, - drop constraint v2_generated_outputs_bucket_check, - drop column r2_bucket, - add constraint v2_generated_outputs_r2_key_unique unique (r2_key); - --- Webhook acceptance, replay, and idempotency are owned by the --- WebhookIdempotencyStore Durable Object. This table was a write-only, --- short-lived diagnostic copy and had no billing reconciliation reader. -drop table public.v2_billing_events restrict; diff --git a/infra/supabase/migrations/post/0053_finalize_assistant_transcript_segments.sql b/infra/supabase/migrations/post/0053_finalize_assistant_transcript_segments.sql deleted file mode 100644 index 604b5a6a..00000000 --- a/infra/supabase/migrations/post/0053_finalize_assistant_transcript_segments.sql +++ /dev/null @@ -1,28 +0,0 @@ --- The additive Drizzle migration leaves the former one-row-per-run identity in --- place so the old Worker remains safe during rollout. The segmented Worker --- hides non-final rows and retries conflicts until this closed-gate contraction --- removes that obsolete identity. -lock table public.v2_agent_runs in share row exclusive mode; -lock table public.v2_messages in share row exclusive mode; - -do $$ -begin - if to_regclass('public.v2_messages_agent_run_segment_assistant_uidx') is null - or to_regclass('public.v2_messages_agent_run_final_assistant_uidx') is null then - raise exception - 'assistant transcript contraction refused: segmented-message indexes are missing'; - end if; - - if exists ( - select 1 - from public.v2_agent_runs - where status is null - or status not in ('completed', 'failed', 'canceled') - ) then - raise exception - 'assistant transcript contraction refused: active AgentRuns must drain before the old identity is removed'; - end if; -end -$$; - -drop index public.v2_messages_agent_run_assistant_uidx; diff --git a/infra/supabase/migrations/post/0054_finalize_provider_key_revalidation_lease.sql b/infra/supabase/migrations/post/0054_finalize_provider_key_revalidation_lease.sql deleted file mode 100644 index 999fde1c..00000000 --- a/infra/supabase/migrations/post/0054_finalize_provider_key_revalidation_lease.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Contract only after the lease-aware Worker release is serving every claim. -drop index if exists public.v2_provider_keys_revalidation_idx; diff --git a/infra/supabase/migrations/post/0055_finalize_message_roles.sql b/infra/supabase/migrations/post/0055_finalize_message_roles.sql deleted file mode 100644 index 3f4820ad..00000000 --- a/infra/supabase/migrations/post/0055_finalize_message_roles.sql +++ /dev/null @@ -1,22 +0,0 @@ --- V2 persists only user prompts and assistant transcript segments. Remove rows --- from superseded experimental roles before making that exact contract valid. -lock table public.v2_messages in share row exclusive mode; - -do $$ -begin - if not exists ( - select 1 - from pg_constraint - where conrelid = 'public.v2_messages'::regclass - and conname = 'v2_messages_role_check' - ) then - raise exception 'message-role contraction refused: role constraint is missing'; - end if; -end -$$; - -delete from public.v2_messages - where role not in ('assistant', 'user'); - -alter table public.v2_messages - validate constraint v2_messages_role_check; diff --git a/infra/supabase/migrations/post/0056_remove_unused_llamaparse_provider.sql b/infra/supabase/migrations/post/0056_remove_unused_llamaparse_provider.sql deleted file mode 100644 index ae5bba7d..00000000 --- a/infra/supabase/migrations/post/0056_remove_unused_llamaparse_provider.sql +++ /dev/null @@ -1,149 +0,0 @@ --- LlamaParse has no V2 runtime consumer. Remove its inert BYOK rows (the --- guarded delete trigger also removes each owned Vault secret), then contract --- both the table and security-definer write boundary to live providers only. -lock table public.v2_provider_keys in share row exclusive mode; - -create temporary table llamaparse_affected_users ( - user_id uuid primary key -) on commit drop; - -insert into llamaparse_affected_users (user_id) -select user_id - from public.v2_provider_keys - where provider = 'llamaparse'; - -delete from public.v2_provider_keys - where provider = 'llamaparse'; - --- Removing a ranked key can promote the next provider into the user's tier --- allowance. Reapply the exact runtime ranking while preserving disables that --- came from provider revalidation rather than the tier-slot policy. -with ranked as ( - select - key.user_id, - key.provider, - row_number() over ( - partition by key.user_id - order by key.created_at asc, key.provider asc - ) as provider_rank, - case coalesce(entitlement.tier, 'free') - when 'free' then 3 - when 'pro' then 10 - else null - end as provider_limit - from public.v2_provider_keys key - join llamaparse_affected_users affected on affected.user_id = key.user_id - left join public.v2_entitlements entitlement on entitlement.user_id = key.user_id -) -update public.v2_provider_keys key - set disabled_at = case - when ranked.provider_limit is null - and key.disabled_reason = 'tier_slot_limit' then null - when ranked.provider_rank <= ranked.provider_limit - and key.disabled_reason = 'tier_slot_limit' then null - when ranked.provider_rank > ranked.provider_limit - and key.disabled_at is null then now() - else key.disabled_at - end, - disabled_reason = case - when ranked.provider_limit is null - and key.disabled_reason = 'tier_slot_limit' then null - when ranked.provider_rank <= ranked.provider_limit - and key.disabled_reason = 'tier_slot_limit' then null - when ranked.provider_rank > ranked.provider_limit - and key.disabled_at is null then 'tier_slot_limit' - else key.disabled_reason - end - from ranked - where key.user_id = ranked.user_id - and key.provider = ranked.provider - and ( - (ranked.provider_limit is null and key.disabled_reason = 'tier_slot_limit') - or ( - ranked.provider_limit is not null - and ranked.provider_rank <= ranked.provider_limit - and key.disabled_reason = 'tier_slot_limit' - ) - or ( - ranked.provider_limit is not null - and ranked.provider_rank > ranked.provider_limit - and key.disabled_at is null - ) - ); - -alter table public.v2_provider_keys - drop constraint v2_provider_keys_provider_check; - -alter table public.v2_provider_keys - add constraint v2_provider_keys_provider_check - check ( - provider in ( - 'anthropic', - 'openai', - 'google', - 'openrouter', - 'deepseek', - 'exa', - 'firecrawl' - ) - ); - -create or replace function public.set_provider_key(p_provider text, p_key text) returns void -language plpgsql -security definer -set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); - secret_id uuid; - key_fingerprint text; -begin - if p_provider is null or p_provider not in ( - 'anthropic', - 'openai', - 'google', - 'openrouter', - 'deepseek', - 'exa', - 'firecrawl' - ) then - raise exception 'unsupported provider'; - end if; - if p_key is null or btrim(p_key) = '' or octet_length(p_key) > 65536 then - raise exception 'provider key must contain between 1 and 65536 bytes'; - end if; - - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended( - 'cheatcode:provider-keys:' || actor_id::text, - 0 - ) - ); - - key_fingerprint := substring( - encode(extensions.digest(convert_to(p_key, 'UTF8'), 'sha256'), 'hex') - for 12 - ); - - delete from public.v2_provider_keys - where user_id = actor_id and provider = p_provider; - - secret_id := vault.create_secret( - p_key, - actor_id::text || ':' || p_provider || ':' || public.uuidv7()::text, - 'Cheatcode V2 BYOK provider key' - ); - - insert into public.v2_provider_keys ( - user_id, - provider, - vault_secret_id, - fingerprint - ) values ( - actor_id, - p_provider, - secret_id, - key_fingerprint - ); -end -$function$; diff --git a/infra/supabase/migrations/post/0057_enforce_permanent_v2_integrity.sql b/infra/supabase/migrations/post/0057_enforce_permanent_v2_integrity.sql deleted file mode 100644 index 2fab6b71..00000000 --- a/infra/supabase/migrations/post/0057_enforce_permanent_v2_integrity.sql +++ /dev/null @@ -1,466 +0,0 @@ --- Close the remaining permanent V2 integrity gaps after the exact-SHA Workers --- are live and writers are maintenance-fenced. Historical values are repaired --- only where the current authoritative state makes the result unambiguous; --- external-identity corruption fails closed for operator review. - -lock table - public.v2_agent_runs, - public.v2_entitlements, - public.v2_generated_outputs, - public.v2_messages, - public.v2_projects, - public.v2_provider_keys, - public.v2_threads, - public.v2_user_profiles, - public.v2_user_skills -in share row exclusive mode; - --- `status` is authoritative. Restore the timestamp projection without inventing --- elapsed work: missing or inverted terminal times collapse to `started_at`, --- while nonterminal rows cannot retain a stale finish marker. -update public.v2_agent_runs - set finished_at = started_at - where status in ('completed', 'failed', 'canceled') - and (finished_at is null or finished_at < started_at); - -update public.v2_agent_runs - set finished_at = null - where status in ('pending', 'running', 'paused') - and finished_at is not null; - --- A project-bound thread has consumed its one-shot launch intent. Quota state --- also projects one exact read-only/archive state, so repair only the missing --- half of that pair using the live 30-day retention policy. -update public.v2_threads - set launch_intent = null, - updated_at = now() - where project_id is not null - and launch_intent is not null; - -update public.v2_projects - set archive_after = null, - updated_at = now() - where not over_quota - and archive_after is not null; - -update public.v2_projects - set archive_after = now() + interval '30 days', - updated_at = now() - where over_quota - and archive_after is null; - --- JSON null is not a logical model selection. Current writers omit the key, --- so normalize that harmless historical spelling before enforcing the exact --- canonical-model contract introduced by migration 0041. -update public.v2_projects - set settings = settings - 'defaultModel', - updated_at = now() - where jsonb_typeof(settings) = 'object' - and settings -> 'defaultModel' = 'null'::jsonb; - -update public.v2_threads - set launch_intent = launch_intent - 'defaultModel', - updated_at = now() - where jsonb_typeof(launch_intent) = 'object' - and launch_intent -> 'defaultModel' = 'null'::jsonb; - --- Fingerprints are a non-secret projection of the owned Vault payload. Repair --- only malformed projections with the same lowercase SHA-256 prefix used by --- set_provider_key; migrations 0042-0043 already prove Vault ownership. -update public.v2_provider_keys key - set fingerprint = substring( - encode( - extensions.digest(convert_to(secret.decrypted_secret, 'UTF8'), 'sha256'), - 'hex' - ) - for 12 - ) - from vault.decrypted_secrets secret - where secret.id = key.vault_secret_id - and key.fingerprint !~ '^[0-9a-f]{12}$'; - -do $preflight$ -begin - if exists ( - select 1 - from public.v2_agent_runs - where status not in ('pending', 'running', 'paused', 'completed', 'failed', 'canceled') - ) then - raise exception 'agent-run integrity refused: unsupported status values remain'; - end if; - - if exists ( - select 1 - from public.v2_threads - where active_run_id is not null - and project_id is null - ) then - raise exception 'thread integrity refused: a project-less thread retains an active run'; - end if; - - if exists ( - select 1 - from public.v2_entitlements - where current_period_start is not null - and current_period_end is not null - and current_period_start > current_period_end - ) then - raise exception 'entitlement integrity refused: an inverted subscription period remains'; - end if; - - if exists ( - select 1 - from public.v2_entitlements - where polar_subscription_id is not null - group by polar_subscription_id - having count(*) > 1 - ) then - raise exception 'entitlement integrity refused: duplicate Polar subscription identities remain'; - end if; - - if exists ( - select 1 - from public.v2_projects - where jsonb_typeof(settings) <> 'object' - or ( - settings ? 'defaultModel' - and ( - jsonb_typeof(settings -> 'defaultModel') <> 'string' - or char_length(settings ->> 'defaultModel') > 200 - or settings ->> 'defaultModel' - !~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$' - ) - ) - ) then - raise exception 'project integrity refused: invalid settings JSON remains'; - end if; - - if exists ( - select 1 - from public.v2_threads - where ( - launch_intent is not null - and jsonb_typeof(launch_intent) <> 'object' - ) - or ( - launch_intent ? 'defaultModel' - and ( - jsonb_typeof(launch_intent -> 'defaultModel') <> 'string' - or char_length(launch_intent ->> 'defaultModel') > 200 - or launch_intent ->> 'defaultModel' - !~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$' - ) - ) - ) then - raise exception 'thread integrity refused: invalid launch-intent JSON remains'; - end if; - - if exists ( - select 1 from public.v2_messages where jsonb_typeof(parts) <> 'array' - ) then - raise exception 'message integrity refused: parts must be JSON arrays'; - end if; - - if exists ( - select 1 - from public.v2_user_profiles - where jsonb_typeof(disabled_models) <> 'array' - or jsonb_typeof(onboarding_state) <> 'object' - ) then - raise exception 'profile integrity refused: invalid JSON containers remain'; - end if; - - if exists ( - select 1 from public.v2_user_skills where jsonb_typeof(tags) <> 'array' - ) then - raise exception 'skill integrity refused: tags must be JSON arrays'; - end if; - - if exists ( - select 1 - from public.v2_provider_keys - where fingerprint !~ '^[0-9a-f]{12}$' - or ((disabled_at is null) <> (disabled_reason is null)) - ) then - raise exception 'provider-key integrity refused: malformed metadata remains'; - end if; - - if exists ( - select 1 - from public.v2_generated_outputs - where r2_key <> user_id::text || '/' || split_part(r2_key, '/', 2) || '/' || - agent_run_id::text || '/' || id::text || '-' || filename - or split_part(r2_key, '/', 2) - !~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$' - or strpos(filename, '/') <> 0 - ) then - raise exception 'generated-output integrity refused: a noncanonical R2 identity remains'; - end if; -end -$preflight$; - --- Replace the keyset index with the physical ordering used by --- listThreadMessages: created_at, transcript segment, then UUID. -drop index public.v2_messages_thread_page_idx; - -create index v2_messages_thread_page_idx - on public.v2_messages (user_id, thread_id, created_at, agent_run_segment, id); - -create index v2_agent_runs_user_finished_idx - on public.v2_agent_runs (user_id, finished_at) - where finished_at is not null; - -create unique index v2_entitlements_polar_subscription_uidx - on public.v2_entitlements (polar_subscription_id) - where polar_subscription_id is not null; - -create index v2_threads_active_run_idx - on public.v2_threads (active_run_id) - where active_run_id is not null; - --- A canonical slug ends in its globally unique project primary key, making the --- historical (user_id, workspace_slug) uniqueness index redundant. -drop index public.v2_projects_user_workspace_slug_uidx; - --- Preserve transcript grouping identity. A run cannot disappear while any --- message still references it; project/thread cascade deletion removes both --- sides through their owning thread. -alter table public.v2_messages - add constraint v2_messages_agent_run_scope_restrict_fk - foreign key (agent_run_id, user_id, thread_id) - references public.v2_agent_runs (id, user_id, thread_id) - on delete restrict - not valid; - -alter table public.v2_messages - validate constraint v2_messages_agent_run_scope_restrict_fk; - -alter table public.v2_messages - drop constraint v2_messages_agent_run_scope_fk; - -alter table public.v2_messages - rename constraint v2_messages_agent_run_scope_restrict_fk - to v2_messages_agent_run_scope_fk; - -alter table public.v2_agent_runs - add constraint v2_agent_runs_status_check - check (status in ('pending', 'running', 'paused', 'completed', 'failed', 'canceled')) - not valid, - add constraint v2_agent_runs_finished_order_check - check (finished_at is null or finished_at >= started_at) - not valid, - add constraint v2_agent_runs_terminal_timestamp_check - check ((status in ('completed', 'failed', 'canceled')) = (finished_at is not null)) - not valid; - -alter table public.v2_entitlements - add constraint v2_entitlements_period_order_check - check ( - current_period_start is null - or current_period_end is null - or current_period_start <= current_period_end - ) - not valid; - -alter table public.v2_generated_outputs - add constraint v2_generated_outputs_r2_identity_check - check ( - r2_key = user_id::text || '/' || split_part(r2_key, '/', 2) || '/' || - agent_run_id::text || '/' || id::text || '-' || filename - and split_part(r2_key, '/', 2) - ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$' - and strpos(filename, '/') = 0 - ) - not valid; - -alter table public.v2_messages - add constraint v2_messages_parts_array_check - check (jsonb_typeof(parts) = 'array') - not valid; - -alter table public.v2_projects - add constraint v2_projects_quota_archive_pair_check - check (over_quota = (archive_after is not null)) - not valid, - add constraint v2_projects_settings_object_check - check (jsonb_typeof(settings) = 'object') - not valid, - add constraint v2_projects_settings_default_model_check - check ( - not (settings ? 'defaultModel') - or ( - jsonb_typeof(settings -> 'defaultModel') = 'string' - and char_length(settings ->> 'defaultModel') <= 200 - and settings ->> 'defaultModel' - ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$' - ) - ) - not valid; - -alter table public.v2_provider_keys - add constraint v2_provider_keys_fingerprint_check - check (fingerprint ~ '^[0-9a-f]{12}$') - not valid; - -alter table public.v2_threads - add constraint v2_threads_project_launch_intent_check - check (project_id is null or launch_intent is null) - not valid, - add constraint v2_threads_active_run_project_check - check (active_run_id is null or project_id is not null) - not valid, - add constraint v2_threads_launch_intent_object_check - check (launch_intent is null or jsonb_typeof(launch_intent) = 'object') - not valid, - add constraint v2_threads_launch_default_model_check - check ( - launch_intent is null - or not (launch_intent ? 'defaultModel') - or ( - jsonb_typeof(launch_intent -> 'defaultModel') = 'string' - and char_length(launch_intent ->> 'defaultModel') <= 200 - and launch_intent ->> 'defaultModel' - ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$' - ) - ) - not valid; - -alter table public.v2_user_profiles - add constraint v2_user_profiles_disabled_models_array_check - check (jsonb_typeof(disabled_models) = 'array') - not valid, - add constraint v2_user_profiles_onboarding_state_object_check - check (jsonb_typeof(onboarding_state) = 'object') - not valid; - -alter table public.v2_user_skills - add constraint v2_user_skills_tags_array_check - check (jsonb_typeof(tags) = 'array') - not valid; - -alter table public.v2_agent_runs - validate constraint v2_agent_runs_status_check, - validate constraint v2_agent_runs_finished_order_check, - validate constraint v2_agent_runs_terminal_timestamp_check; - -alter table public.v2_entitlements - validate constraint v2_entitlements_period_order_check; - -alter table public.v2_generated_outputs - validate constraint v2_generated_outputs_r2_identity_check; - -alter table public.v2_messages - validate constraint v2_messages_parts_array_check; - -alter table public.v2_projects - validate constraint v2_projects_quota_archive_pair_check, - validate constraint v2_projects_settings_object_check, - validate constraint v2_projects_settings_default_model_check; - -alter table public.v2_provider_keys - validate constraint v2_provider_keys_fingerprint_check; - -alter table public.v2_threads - validate constraint v2_threads_project_launch_intent_check, - validate constraint v2_threads_active_run_project_check, - validate constraint v2_threads_launch_intent_object_check, - validate constraint v2_threads_launch_default_model_check; - -alter table public.v2_user_profiles - validate constraint v2_user_profiles_disabled_models_array_check, - validate constraint v2_user_profiles_onboarding_state_object_check; - -alter table public.v2_user_skills - validate constraint v2_user_skills_tags_array_check; - --- Partition creation is database maintenance, not an application capability. --- A postgres-owned daily job maintains a short rolling runway while the admin --- archive command remains responsible for export, verification, and detach. -create or replace function public.ensure_v2_audit_partitions() -returns integer -language plpgsql -set search_path = '' -as $function$ -declare - child_oid oid; - created_count integer := 0; - expected_bound text; - month_offset integer; - partition_bound text; - partition_end date; - partition_name text; - partition_start date; -begin - if pg_catalog.to_regclass('public.v2_audit_log') is null then - raise exception 'audit partition maintenance requires public.v2_audit_log'; - end if; - - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:v2:audit-partitions', 0) - ); - - for month_offset in 0..3 loop - partition_start := ( - pg_catalog.date_trunc( - 'month', - pg_catalog.timezone('UTC', pg_catalog.statement_timestamp()) - ) + pg_catalog.make_interval(months => month_offset) - )::date; - partition_end := ( - partition_start + pg_catalog.make_interval(months => 1) - )::date; - partition_name := 'v2_audit_log_' || pg_catalog.to_char(partition_start, 'YYYY_MM'); - expected_bound := pg_catalog.format( - 'FOR VALUES FROM (%L) TO (%L)', - partition_start::text || ' 00:00:00+00', - partition_end::text || ' 00:00:00+00' - ); - child_oid := pg_catalog.to_regclass( - pg_catalog.format('public.%I', partition_name) - ); - - if child_oid is null then - execute pg_catalog.format( - 'create table public.%I partition of public.v2_audit_log for values from (%L) to (%L)', - partition_name, - partition_start::text || ' 00:00:00+00', - partition_end::text || ' 00:00:00+00' - ); - created_count := created_count + 1; - elsif not exists ( - select 1 - from pg_catalog.pg_inherits inheritance - where inheritance.inhrelid = child_oid - and inheritance.inhparent = 'public.v2_audit_log'::regclass - ) then - raise exception 'audit partition name % is occupied by an unattached relation', - partition_name; - else - select pg_catalog.pg_get_expr(relation.relpartbound, relation.oid) - into partition_bound - from pg_catalog.pg_class relation - where relation.oid = child_oid; - if partition_bound is distinct from expected_bound then - raise exception 'audit partition % has unexpected bounds: %', - partition_name, - partition_bound; - end if; - end if; - end loop; - - return created_count; -end -$function$; - -alter function public.ensure_v2_audit_partitions() owner to postgres; -revoke all on function public.ensure_v2_audit_partitions() - from public, anon, authenticated, service_role, - app_worker, app_gateway, app_agent, app_webhooks; - -select public.ensure_v2_audit_partitions(); - -select cron.schedule( - 'cheatcode-v2-audit-partitions', - '17 2 * * *', - 'select public.ensure_v2_audit_partitions();' -); diff --git a/infra/supabase/migrations/post/0058_expand_worker_database_roles.sql b/infra/supabase/migrations/post/0058_expand_worker_database_roles.sql deleted file mode 100644 index 645febc9..00000000 --- a/infra/supabase/migrations/post/0058_expand_worker_database_roles.sql +++ /dev/null @@ -1,332 +0,0 @@ -do $dependency$ -begin - if not exists ( - select 1 - from public._raw_migrations - where filename = 'infra/supabase/migrations/post/0051_resource_deletion_jobs.sql' - ) then - raise exception 'worker role expansion requires pre-deploy migration post/0051'; - end if; - if not exists ( - select 1 - from public._raw_migrations - where filename = 'infra/supabase/migrations/pre/0007_worker_database_roles.sql' - ) then - raise exception 'worker role expansion requires foundation pre/0007'; - end if; - if pg_catalog.to_regprocedure( - 'public._configure_v2_worker_role_access(boolean,boolean)' - ) is null then - raise exception 'worker role expansion requires the pre/0007 role helper'; - end if; -end -$dependency$; - --- Keep app_worker fully operational while adding the three dedicated service --- identities. The closed release and reconciliation can switch Hyperdrives --- before post-deploy removes the compatibility identity. -select public._configure_v2_worker_role_access(false, true); - -alter role app_gateway set search_path = public, pg_catalog; -alter role app_agent set search_path = public, pg_catalog; -alter role app_webhooks set search_path = public, pg_catalog; - --- A runtime role must not inherit or assume any second identity. Supabase's --- migration administrator may retain ADMIN OPTION on these managed roles; that --- inverse edge grants the administrator access to the runtime role and does not --- expand a Worker's privileges. -do $memberships$ -declare - membership record; -begin - for membership in - select granted.rolname as granted_role, member.rolname as member_role - from pg_auth_members relation - join pg_roles granted on granted.oid = relation.roleid - join pg_roles member on member.oid = relation.member - where member.rolname in ('app_gateway', 'app_agent', 'app_webhooks') - loop - execute format('revoke %I from %I', membership.granted_role, membership.member_role); - end loop; -end -$memberships$; - --- The final target verifier runs after post-deploy contractions. Assert the --- minimum-positive staged contract here so a typo cannot switch the closed --- release to an unusable Hyperdrive identity. -do $postconditions$ -declare - access_spec text; - column_group text; - column_name text; - function_spec text; - object_name text; - privilege_name text; - role_name text; - select_column_group text; -begin - if ( - select count(*) = 3 - and bool_and(rolcanlogin) - and bool_and(not rolinherit) - and bool_and(not rolsuper) - and bool_and(not rolcreatedb) - and bool_and(not rolcreaterole) - and bool_and(not rolreplication) - and bool_and(not rolbypassrls) - from pg_roles - where rolname in ('app_gateway', 'app_agent', 'app_webhooks') - ) is not true then - raise exception 'worker role expansion produced invalid role attributes'; - end if; - - if exists ( - select 1 - from pg_auth_members membership - join pg_roles granted on granted.oid = membership.roleid - join pg_roles member on member.oid = membership.member - where member.rolname in ('app_gateway', 'app_agent', 'app_webhooks') - ) then - raise exception 'worker role expansion left a runtime role membership'; - end if; - - foreach role_name in array array['app_gateway', 'app_agent', 'app_webhooks'] - loop - if not exists ( - select 1 - from pg_database database_record - cross join lateral pg_catalog.aclexplode( - coalesce( - database_record.datacl, - pg_catalog.acldefault('d', database_record.datdba) - ) - ) entry - where database_record.datname = pg_catalog.current_database() - and (entry).grantee = (select oid from pg_roles where rolname = role_name) - and (entry).privilege_type = 'CONNECT' - and not (entry).is_grantable - ) then - raise exception 'worker role expansion omitted direct CONNECT for %', role_name; - end if; - if not exists ( - select 1 - from pg_namespace namespace - cross join lateral pg_catalog.aclexplode( - coalesce(namespace.nspacl, pg_catalog.acldefault('n', namespace.nspowner)) - ) entry - where namespace.nspname = 'public' - and (entry).grantee = (select oid from pg_roles where rolname = role_name) - and (entry).privilege_type = 'USAGE' - and not (entry).is_grantable - ) then - raise exception 'worker role expansion omitted direct public USAGE for %', role_name; - end if; - end loop; - - foreach access_spec in array array[ - 'app_gateway|v2_deleted_clerk_identities|SELECT', - 'app_gateway|v2_entitlements|SELECT', - 'app_gateway|v2_messages|SELECT', - 'app_gateway|v2_projects|SELECT', - 'app_gateway|v2_threads|SELECT', - 'app_gateway|v2_user_integrations|SELECT', - 'app_gateway|v2_user_profiles|SELECT', - 'app_gateway|v2_user_skills|SELECT', - 'app_gateway|v2_entitlements|INSERT', - 'app_gateway|v2_projects|INSERT', - 'app_gateway|v2_threads|INSERT', - 'app_gateway|v2_user_integrations|INSERT', - 'app_gateway|v2_user_profiles|INSERT', - 'app_gateway|v2_user_skills|INSERT', - 'app_gateway|v2_users|INSERT', - 'app_gateway|v2_user_integrations|DELETE', - 'app_gateway|v2_user_skills|DELETE', - 'app_agent|v2_messages|SELECT', - 'app_agent|v2_projects|SELECT', - 'app_agent|v2_threads|SELECT', - 'app_agent|v2_user_skills|SELECT', - 'app_agent|v2_agent_runs|INSERT', - 'app_agent|v2_generated_outputs|INSERT', - 'app_agent|v2_messages|INSERT', - 'app_agent|v2_projects|INSERT', - 'app_agent|v2_user_skills|INSERT', - 'app_webhooks|v2_deleted_clerk_identities|SELECT', - 'app_webhooks|v2_entitlements|SELECT', - 'app_webhooks|v2_resource_deletion_jobs|SELECT', - 'app_webhooks|v2_deleted_clerk_identities|INSERT', - 'app_webhooks|v2_entitlements|INSERT', - 'app_webhooks|v2_resource_deletion_jobs|INSERT', - 'app_webhooks|v2_users|INSERT', - 'app_webhooks|v2_generated_outputs|DELETE', - 'app_webhooks|v2_projects|DELETE', - 'app_webhooks|v2_resource_deletion_jobs|DELETE', - 'app_webhooks|v2_threads|DELETE', - 'app_webhooks|v2_users|DELETE' - ] - loop - role_name := pg_catalog.split_part(access_spec, '|', 1); - object_name := pg_catalog.split_part(access_spec, '|', 2); - privilege_name := pg_catalog.split_part(access_spec, '|', 3); - if not pg_catalog.has_table_privilege( - role_name, - pg_catalog.format('public.%I', object_name), - privilege_name - ) then - raise exception 'worker role expansion omitted % %.%', privilege_name, role_name, object_name; - end if; - end loop; - - foreach select_column_group in array array[ - 'app_gateway|v2_users|avatar_url,clerk_id,deleted_at,deletion_fence,display_name,email,id,polar_customer_id', - 'app_gateway|v2_agent_runs|finished_at,id,started_at,status,user_id', - 'app_gateway|v2_provider_keys|created_at,disabled_at,disabled_reason,provider,user_id', - 'app_agent|v2_users|deleted_at,deletion_fence,first_artifact_at,id', - 'app_agent|v2_entitlements|current_period_end,current_period_start,subscription_status,tier,updated_at,user_id', - 'app_agent|v2_agent_runs|id,idempotency_key_hash,model_id,request_body_hash,status,thread_id,user_id', - 'app_agent|v2_generated_outputs|expires_at,filename,id,mime_type,r2_key,user_id', - 'app_agent|v2_user_profiles|agent_display_name,disabled_models,global_memory,user_id', - 'app_agent|v2_user_integrations|composio_connection_id,integration,is_default,status,updated_at,user_id', - 'app_webhooks|v2_users|avatar_url,clerk_id,created_at,deleted_at,deletion_fence,display_name,email,id,polar_customer_id', - 'app_webhooks|v2_agent_runs|id,started_at,thread_id,user_id', - 'app_webhooks|v2_generated_outputs|agent_run_id,expires_at,id,r2_key,user_id', - 'app_webhooks|v2_projects|archive_after,created_at,deleted_at,id,name,over_quota,updated_at,user_id,workspace_slug', - 'app_webhooks|v2_threads|active_run_id,deleted_at,id,project_id,user_id', - 'app_webhooks|v2_provider_keys|created_at,disabled_at,disabled_reason,fingerprint,provider,revalidation_claimed_at,revalidation_lease_token,user_id', - 'app_webhooks|v2_user_integrations|composio_connection_id,integration,is_default,status,updated_at,user_id' - ] - loop - role_name := pg_catalog.split_part(select_column_group, '|', 1); - object_name := pg_catalog.split_part(select_column_group, '|', 2); - foreach column_name in array pg_catalog.string_to_array( - pg_catalog.split_part(select_column_group, '|', 3), - ',' - ) - loop - if not pg_catalog.has_column_privilege( - role_name, - pg_catalog.format('public.%I', object_name), - column_name, - 'SELECT' - ) then - raise exception 'worker role expansion omitted SELECT %.%.%', - role_name, - object_name, - column_name; - end if; - end loop; - end loop; - - foreach column_group in array array[ - 'app_gateway|v2_users|avatar_url,deleted_at,deletion_fence,display_name,email,polar_customer_id', - 'app_gateway|v2_entitlements|cancel_at_period_end,current_period_end,current_period_start,polar_subscription_id,subscription_status,updated_at', - 'app_gateway|v2_projects|deleted_at,master_instructions,name,settings,updated_at', - 'app_gateway|v2_threads|deleted_at,title,updated_at', - 'app_gateway|v2_provider_keys|disabled_at,disabled_reason', - 'app_gateway|v2_user_integrations|is_default,status', - 'app_gateway|v2_user_profiles|agent_display_name,disabled_models,global_memory,onboarding_completed_at,onboarding_state', - 'app_gateway|v2_user_skills|body,category,description,tags,updated_at', - 'app_agent|v2_users|first_artifact_at', - 'app_agent|v2_threads|active_run_id,launch_intent,project_id,updated_at', - 'app_agent|v2_agent_runs|finished_at,model_id,status', - 'app_agent|v2_user_skills|body,category,description,tags,updated_at', - 'app_webhooks|v2_users|avatar_url,deleted_at,deletion_fence,display_name,email,polar_customer_id', - 'app_webhooks|v2_entitlements|cancel_at_period_end,current_period_end,current_period_start,polar_subscription_id,subscription_status,tier,updated_at', - 'app_webhooks|v2_projects|archive_after,deleted_at,over_quota,updated_at,workspace_slug', - 'app_webhooks|v2_threads|active_run_id,deleted_at,updated_at', - 'app_webhooks|v2_provider_keys|disabled_at,disabled_reason,last_revalidated_at,revalidation_claimed_at,revalidation_lease_token', - 'app_webhooks|v2_user_integrations|is_default,status', - 'app_webhooks|v2_resource_deletion_jobs|continuation,cursor,failure_count,last_error_code,lease_expires_at,lease_token,next_attempt_at,phase,status' - ] - loop - role_name := pg_catalog.split_part(column_group, '|', 1); - object_name := pg_catalog.split_part(column_group, '|', 2); - foreach column_name in array pg_catalog.string_to_array( - pg_catalog.split_part(column_group, '|', 3), - ',' - ) - loop - if not pg_catalog.has_column_privilege( - role_name, - pg_catalog.format('public.%I', object_name), - column_name, - 'UPDATE' - ) then - raise exception 'worker role expansion omitted UPDATE %.%.%', role_name, object_name, column_name; - end if; - end loop; - end loop; - - foreach function_spec in array array[ - 'app_gateway|public.delete_provider_key(text)', - 'app_gateway|public.set_provider_key(text,text)', - 'app_gateway|public.uuidv7()', - 'app_agent|public.get_provider_key(text)', - 'app_agent|public.uuidv7()', - 'app_webhooks|public.claim_provider_key_revalidation_targets(integer)', - 'app_webhooks|public.current_app_user()', - 'app_webhooks|public.delete_all_provider_keys()', - 'app_webhooks|public.get_provider_key(text)', - 'app_webhooks|public.scrub_current_user_audit()', - 'app_webhooks|public.uuidv7()' - ] - loop - role_name := pg_catalog.split_part(function_spec, '|', 1); - object_name := pg_catalog.split_part(function_spec, '|', 2); - if not pg_catalog.has_function_privilege(role_name, object_name, 'EXECUTE') then - raise exception 'worker role expansion omitted EXECUTE % %', role_name, object_name; - end if; - end loop; - - if not exists ( - select 1 - from pg_policies - where schemaname = 'public' - and tablename = 'v2_provider_keys' - and policyname = 'v2_provider_keys_select_own' - and cmd = 'SELECT' - and roles::text[] @> array['app_worker', 'app_gateway', 'app_webhooks'] - and pg_catalog.cardinality(roles) = 3 - ) or not exists ( - select 1 - from pg_policies - where schemaname = 'public' - and tablename = 'v2_provider_keys' - and policyname = 'v2_provider_keys_update_own' - and cmd = 'UPDATE' - and roles::text[] @> array['app_worker', 'app_gateway', 'app_webhooks'] - and pg_catalog.cardinality(roles) = 3 - ) or not exists ( - select 1 - from pg_policies - where schemaname = 'public' - and tablename = 'v2_deleted_clerk_identities' - and policyname = 'v2_deleted_clerk_identities_select' - and cmd = 'SELECT' - and roles::text[] @> array['app_worker', 'app_gateway', 'app_webhooks'] - and pg_catalog.cardinality(roles) = 3 - ) or not exists ( - select 1 - from pg_policies - where schemaname = 'public' - and tablename = 'v2_deleted_clerk_identities' - and policyname = 'v2_deleted_clerk_identities_insert' - and cmd = 'INSERT' - and roles::text[] @> array['app_worker', 'app_webhooks'] - and pg_catalog.cardinality(roles) = 2 - ) then - raise exception 'worker role expansion produced an invalid staged RLS role set'; - end if; - - if not pg_catalog.has_table_privilege( - 'app_worker', - 'public.v2_projects', - 'SELECT' - ) or not pg_catalog.has_function_privilege( - 'app_worker', - 'public.uuidv7()', - 'EXECUTE' - ) then - raise exception 'worker role expansion removed representative legacy access'; - end if; -end -$postconditions$; diff --git a/infra/supabase/migrations/post/0059_finalize_worker_database_roles.sql b/infra/supabase/migrations/post/0059_finalize_worker_database_roles.sql deleted file mode 100644 index 88906270..00000000 --- a/infra/supabase/migrations/post/0059_finalize_worker_database_roles.sql +++ /dev/null @@ -1,151 +0,0 @@ -do $dependency$ -begin - if not exists ( - select 1 - from public._raw_migrations - where filename = 'infra/supabase/migrations/post/0057_enforce_permanent_v2_integrity.sql' - ) then - raise exception 'worker role finalization requires post/0057'; - end if; - if not exists ( - select 1 - from public._raw_migrations - where filename = 'infra/supabase/migrations/post/0058_expand_worker_database_roles.sql' - ) then - raise exception 'worker role finalization requires pre-deploy post/0058'; - end if; - if pg_catalog.to_regprocedure( - 'public._configure_v2_worker_role_access(boolean,boolean)' - ) is null then - raise exception 'worker role finalization requires the pre/0007 role helper'; - end if; -end -$dependency$; - --- Managed Supabase migration administrators cannot ALTER superuser-only role --- attributes, including their negative forms. Fail closed if manual role --- provisioning violated the restricted defaults. -do $restricted_attributes$ -begin - if exists ( - select 1 - from pg_roles - where rolname in ('app_worker', 'app_gateway', 'app_agent', 'app_webhooks') - and (rolsuper or rolreplication or rolbypassrls) - ) then - raise exception 'worker runtime roles must not be superuser, replication, or bypassrls roles'; - end if; -end -$restricted_attributes$; - --- The drain and closed reconciliation are complete, pre/0058 prepared the --- dedicated identities, and the release remains closed while this finalizer --- runs. Reset the reviewed matrix and drop the transition identity before the --- OPEN Workers connect through their dedicated Hyperdrives. -select public._configure_v2_worker_role_access(true, false); - -drop function public._configure_v2_worker_role_access(boolean, boolean); -drop function if exists public._configure_v2_worker_role_access(boolean); - --- PUBLIC schema usage would otherwise leak into Supabase Data API roles despite --- their direct ACLs being empty. -revoke all on schema public from public; -grant usage on schema public to app_gateway, app_agent, app_webhooks; - -alter role app_gateway - with login noinherit nocreatedb nocreaterole; -alter role app_agent - with login noinherit nocreatedb nocreaterole; -alter role app_webhooks - with login noinherit nocreatedb nocreaterole; -alter role app_worker - with nologin password null noinherit nocreatedb nocreaterole; - -alter role app_gateway set search_path = public, pg_catalog; -alter role app_agent set search_path = public, pg_catalog; -alter role app_webhooks set search_path = public, pg_catalog; -alter role app_worker reset search_path; - --- Recheck outbound active-role membership at the irreversible boundary in case --- an operator granted a second identity during the staged release window. --- Supabase's inverse administrator memberships are required to manage these --- roles and do not expand Worker privileges. Keep the migration administrator's --- ADMIN OPTION on app_worker until DROP ROLE; PostgreSQL removes memberships --- involving the dropped role atomically. -do $memberships$ -declare - membership record; -begin - for membership in - select granted.rolname as granted_role, member.rolname as member_role - from pg_auth_members relation - join pg_roles granted on granted.oid = relation.roleid - join pg_roles member on member.oid = relation.member - where member.rolname in ('app_gateway', 'app_agent', 'app_webhooks') - loop - execute format('revoke %I from %I', membership.granted_role, membership.member_role); - end loop; -end -$memberships$; - --- Future migration-owned objects remain closed until a reviewed migration --- grants one service the exact operation it needs. -alter default privileges for role postgres - revoke all privileges on tables from app_worker, app_gateway, app_agent, app_webhooks; -alter default privileges for role postgres - revoke all privileges on sequences from app_worker, app_gateway, app_agent, app_webhooks; -alter default privileges for role postgres - revoke all privileges on functions from app_worker, app_gateway, app_agent, app_webhooks; -alter default privileges for role postgres in schema public - revoke all privileges on tables from app_worker, app_gateway, app_agent, app_webhooks; -alter default privileges for role postgres in schema public - revoke all privileges on sequences from app_worker, app_gateway, app_agent, app_webhooks; -alter default privileges for role postgres in schema public - revoke all privileges on functions from app_worker, app_gateway, app_agent, app_webhooks; - --- Never use DROP OWNED here: an unexpected legacy dependency is a release --- defect, not permission to cascade production objects. pg_shdepend is the --- cluster-wide source of ownership, ACL, initial-ACL, and policy references to --- roles. Assert it is empty after the explicit revokes, then let DROP ROLE --- repeat PostgreSQL's own dependency check while removing role memberships. -do $legacy_role_dependencies$ -declare - dependency_count bigint; - dependency_summary text; - legacy_role_oid oid; -begin - select oid into strict legacy_role_oid - from pg_roles - where rolname = 'app_worker'; - - select - count(*), - pg_catalog.string_agg( - pg_catalog.format( - 'database=%s catalog=%s object=%s subobject=%s type=%s', - coalesce(database_record.datname::text, ''), - dependency.classid::regclass::text, - dependency.objid, - dependency.objsubid, - dependency.deptype - ), - '; ' order by dependency.dbid, dependency.classid, - dependency.objid, dependency.objsubid, dependency.deptype - ) - into dependency_count, dependency_summary - from pg_catalog.pg_shdepend dependency - left join pg_catalog.pg_database database_record - on database_record.oid = dependency.dbid - where dependency.refclassid = 'pg_catalog.pg_authid'::regclass - and dependency.refobjid = legacy_role_oid; - - if dependency_count <> 0 then - raise exception - 'app_worker still has % unexpected cluster dependencies: %', - dependency_count, - dependency_summary; - end if; -end -$legacy_role_dependencies$; - -drop role app_worker; diff --git a/infra/supabase/migrations/post/0060_expand_signed_tenant_boundary.sql b/infra/supabase/migrations/post/0060_expand_signed_tenant_boundary.sql deleted file mode 100644 index c3a7efd7..00000000 --- a/infra/supabase/migrations/post/0060_expand_signed_tenant_boundary.sql +++ /dev/null @@ -1,594 +0,0 @@ -do $preflight$ -declare - distinct_count integer; - expected_description text; - expected_name text; - expected_role text; - named_count integer; - valid_count integer; -begin - foreach expected_role in array array['app_agent', 'app_gateway', 'app_webhooks'] - loop - expected_name := 'cheatcode-database-context-' || - pg_catalog.replace(expected_role, '_', '-') || '-v1'; - expected_description := 'Cheatcode signed tenant context HMAC for ' || expected_role; - select count(*) into named_count - from vault.secrets secret - where secret.name = expected_name; - select count(*) into valid_count - from vault.decrypted_secrets secret - where secret.name = expected_name - and secret.description = expected_description - and pg_catalog.octet_length(secret.decrypted_secret) >= 32; - if named_count <> 1 or valid_count <> 1 then - raise exception - 'signed tenant boundary requires exactly one valid % Vault secret for %', - expected_name, - expected_role; - end if; - end loop; - select count(distinct secret.decrypted_secret) into distinct_count - from vault.decrypted_secrets secret - where secret.name = any(array[ - 'cheatcode-database-context-app-agent-v1', - 'cheatcode-database-context-app-gateway-v1', - 'cheatcode-database-context-app-webhooks-v1' - ]); - if distinct_count <> 3 then - raise exception 'signed tenant boundary requires three distinct Vault secrets'; - end if; -end -$preflight$; - -create or replace function public.gateway_resolve_clerk_user(p_clerk_id text) -returns uuid -language sql stable security definer set search_path = '' -as $function$ - select app_user.id - from public.v2_users app_user - where app_user.clerk_id = p_clerk_id and app_user.deleted_at is null - limit 1 -$function$; - -create or replace function public.webhooks_list_daily_activation_events( - p_day date, - p_cursor_event text, - p_cursor_user_id uuid, - p_limit integer -) -returns table ( - event_order integer, - event_name text, - user_id uuid, - cohort_week text, - cohort_month text -) -language sql stable security definer set search_path = '' -as $function$ - with bounded as ( - select greatest(1, least(coalesce(p_limit, 1), 200)) as page_size, - case - when p_cursor_event is null then null - when p_cursor_event = 'retention_d7' then 1 - when p_cursor_event = 'retention_d28' then 2 - when p_cursor_event = 'first_week_mau' then 3 - else -1 - end as cursor_order - ), activation_events as ( - select 1 as event_order, 'retention_d7'::text as event_name, - candidate.id as user_id, - to_char(date_trunc('week', candidate.created_at), 'YYYY-MM-DD') as cohort_week, - to_char(date_trunc('month', candidate.created_at), 'YYYY-MM-DD') as cohort_month - from public.v2_users candidate - where candidate.deleted_at is null - and candidate.created_at >= p_day - interval '7 days' - and candidate.created_at < p_day - interval '6 days' - and exists ( - select 1 from public.v2_agent_runs run - where run.user_id = candidate.id - and run.started_at >= p_day - and run.started_at < p_day + interval '1 day' - ) - union all - select 2, 'retention_d28'::text, candidate.id, - to_char(date_trunc('week', candidate.created_at), 'YYYY-MM-DD'), - to_char(date_trunc('month', candidate.created_at), 'YYYY-MM-DD') - from public.v2_users candidate - where candidate.deleted_at is null - and candidate.created_at >= p_day - interval '28 days' - and candidate.created_at < p_day - interval '27 days' - and exists ( - select 1 from public.v2_agent_runs run - where run.user_id = candidate.id - and run.started_at >= p_day - and run.started_at < p_day + interval '1 day' - ) - union all - select 3, 'first_week_mau'::text, candidate.id, - to_char(date_trunc('week', candidate.created_at), 'YYYY-MM-DD'), null::text - from public.v2_users candidate - where candidate.deleted_at is null - and candidate.created_at >= p_day - interval '7 days' - and candidate.created_at < p_day - interval '6 days' - and ( - select count(*) from public.v2_agent_runs run - where run.user_id = candidate.id - and run.started_at >= candidate.created_at - and run.started_at < candidate.created_at + interval '7 days' - ) >= 3 - ) - select event.event_order, event.event_name, event.user_id, - event.cohort_week, event.cohort_month - from activation_events event, bounded - where (bounded.cursor_order is null and p_cursor_user_id is null) - or ( - bounded.cursor_order > 0 - and p_cursor_user_id is not null - and (event.event_order, event.user_id) > (bounded.cursor_order, p_cursor_user_id) - ) - order by event.event_order, event.user_id - limit (select page_size + 1 from bounded) -$function$; - -create or replace function public.webhooks_list_expired_outputs( - p_before timestamp with time zone, - p_cursor_expires_at timestamp with time zone, - p_cursor_id uuid, - p_limit integer -) -returns table (expires_at timestamp with time zone, id uuid, r2_key text) -language sql stable security definer set search_path = '' -as $function$ - select output.expires_at, output.id, output.r2_key - from public.v2_generated_outputs output - where output.expires_at <= p_before - and ( - (p_cursor_expires_at is null and p_cursor_id is null) - or ( - p_cursor_expires_at is not null - and p_cursor_id is not null - and (output.expires_at, output.id) > (p_cursor_expires_at, p_cursor_id) - ) - ) - order by output.expires_at, output.id - limit greatest(1, least(coalesce(p_limit, 1), 500)) -$function$; - -create or replace function public.webhooks_delete_expired_outputs( - p_before timestamp with time zone, - p_outputs jsonb -) -returns integer -language plpgsql security definer set search_path = '' -as $function$ -declare - deleted_count integer; -begin - if pg_catalog.jsonb_typeof(p_outputs) <> 'array' - or pg_catalog.jsonb_array_length(p_outputs) > 500 - or pg_catalog.octet_length(p_outputs::text) > 1048576 then - raise exception 'invalid expired-output deletion batch'; - end if; - with requested as ( - select record.id, record.expires_at, record.r2_key - from pg_catalog.jsonb_to_recordset(p_outputs) - as record(id uuid, expires_at timestamp with time zone, r2_key text) - ), deleted as ( - delete from public.v2_generated_outputs output - using requested - where output.id = requested.id - and output.expires_at = requested.expires_at - and output.r2_key = requested.r2_key - and output.expires_at <= p_before - returning output.id - ) - select count(*)::integer into deleted_count from deleted; - return deleted_count; -end -$function$; - -create or replace function public.sync_clerk_user( - p_clerk_id text, - p_email text, - p_display_name text, - p_avatar_url text -) -returns table ( - sync_state text, - user_id uuid, - email text, - display_name text, - avatar_url text, - polar_customer_id text, - email_changed boolean, - profile_changed boolean -) -language plpgsql security definer set search_path = '' -as $function$ -declare - identity_hash text; - existing record; - persisted record; -begin - if p_clerk_id is null or btrim(p_clerk_id) = '' or octet_length(p_clerk_id) > 512 then - raise exception 'invalid Clerk identity'; - end if; - if p_email is null or btrim(p_email) = '' or octet_length(p_email) > 512 then - raise exception 'invalid Clerk email'; - end if; - if octet_length(coalesce(p_display_name, '')) > 1024 - or octet_length(coalesce(p_avatar_url, '')) > 4096 then - raise exception 'invalid Clerk profile payload'; - end if; - - identity_hash := pg_catalog.encode( - extensions.digest(pg_catalog.convert_to(p_clerk_id, 'UTF8'), 'sha256'), - 'hex' - ); - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:clerk-identity:' || identity_hash, 0) - ); - if exists ( - select 1 from public.v2_deleted_clerk_identities retired - where retired.clerk_identity_hash = identity_hash - ) then - return query select 'completed', null::uuid, null::text, null::text, - null::text, null::text, false, false; - return; - end if; - - select app_user.avatar_url, app_user.display_name, app_user.email, - app_user.polar_customer_id - into existing - from public.v2_users app_user - where app_user.clerk_id = p_clerk_id; - - insert into public.v2_users ( - clerk_id, email, display_name, avatar_url, deleted_at, deletion_fence - ) values ( - p_clerk_id, - p_email, - nullif(btrim(p_display_name), ''), - nullif(btrim(p_avatar_url), ''), - null, - null - ) - on conflict (clerk_id) do update - set email = excluded.email, - display_name = excluded.display_name, - avatar_url = excluded.avatar_url, - deleted_at = null, - deletion_fence = null - where public.v2_users.deletion_fence is null - returning id, public.v2_users.email, public.v2_users.display_name, - public.v2_users.avatar_url, public.v2_users.polar_customer_id - into persisted; - if not found then - return query select 'in_progress', null::uuid, null::text, null::text, - null::text, null::text, false, false; - return; - end if; - - insert into public.v2_entitlements (user_id, tier) - values (persisted.id, 'free') - on conflict on constraint v2_entitlements_pkey do nothing; - return query select - 'active', - persisted.id, - persisted.email, - persisted.display_name, - persisted.avatar_url, - persisted.polar_customer_id, - existing.email is not null and existing.email is distinct from persisted.email, - existing.email is not null and ( - existing.email is distinct from persisted.email - or existing.display_name is distinct from persisted.display_name - or existing.avatar_url is distinct from persisted.avatar_url - ); -end -$function$; - -create or replace function public.webhooks_mark_clerk_user_deleted( - p_clerk_id text, - p_deleted_at timestamp with time zone -) -returns uuid -language plpgsql security definer set search_path = '' -as $function$ -declare - identity_hash text; - deleted_user_id uuid; -begin - if p_clerk_id is null or btrim(p_clerk_id) = '' or p_deleted_at is null then - raise exception 'invalid Clerk deletion payload'; - end if; - identity_hash := pg_catalog.encode( - extensions.digest(pg_catalog.convert_to(p_clerk_id, 'UTF8'), 'sha256'), - 'hex' - ); - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:clerk-identity:' || identity_hash, 0) - ); - update public.v2_users app_user - set deleted_at = p_deleted_at, deletion_fence = null - where app_user.clerk_id = p_clerk_id and app_user.deletion_fence is null - returning app_user.id into deleted_user_id; - return deleted_user_id; -end -$function$; - -create or replace function public.webhooks_resolve_polar_customer(p_polar_customer_id text) -returns table (user_id uuid, email text, polar_customer_id text) -language sql stable security definer set search_path = '' -as $function$ - select app_user.id, app_user.email, app_user.polar_customer_id - from public.v2_users app_user - where app_user.polar_customer_id = p_polar_customer_id - and app_user.deleted_at is null - limit 1 -$function$; - -create or replace function public.webhooks_expire_composio_connection(p_connection_id text) -returns boolean -language plpgsql security definer set search_path = '' -as $function$ -declare - target record; -begin - select connection.user_id, connection.integration - into target - from public.v2_user_integrations connection - where connection.composio_connection_id = p_connection_id - for update; - if not found then - return false; - end if; - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended(target.user_id::text || ':' || target.integration, 0) - ); - update public.v2_user_integrations connection - set status = 'expired', is_default = false - where connection.composio_connection_id = p_connection_id - and (connection.status is distinct from 'expired' or connection.is_default); - update public.v2_user_integrations connection - set is_default = false - where connection.user_id = target.user_id - and connection.integration = target.integration - and connection.is_default - and lower(connection.status) not in ('active', 'authorized', 'connected', 'enabled'); - update public.v2_user_integrations connection - set is_default = true - where connection.composio_connection_id = ( - select candidate.composio_connection_id - from public.v2_user_integrations candidate - where candidate.user_id = target.user_id - and candidate.integration = target.integration - and lower(candidate.status) in ('active', 'authorized', 'connected', 'enabled') - order by candidate.updated_at desc, candidate.composio_connection_id - limit 1 - ) and not exists ( - select 1 from public.v2_user_integrations existing - where existing.user_id = target.user_id - and existing.integration = target.integration - and existing.is_default - ); - return true; -end -$function$; - -create or replace function public.webhooks_list_due_user_deletions( - p_before timestamp with time zone, - p_limit_per_state integer -) -returns table (user_id uuid, requested_at timestamp with time zone, is_claimed boolean) -language sql stable security definer set search_path = '' -as $function$ - with bounded as ( - select greatest(1, least(coalesce(p_limit_per_state, 1), 50)) as page_size - ), claimed as ( - select app_user.id as user_id, app_user.deleted_at as requested_at, true as is_claimed - from public.v2_users app_user - where app_user.deleted_at <= p_before - and app_user.deletion_fence = - ((extract(epoch from app_user.deleted_at) * 1000)::bigint)::text - order by app_user.deleted_at, app_user.id - limit (select page_size from bounded) - ), pending as ( - select app_user.id as user_id, app_user.deleted_at as requested_at, false as is_claimed - from public.v2_users app_user - where app_user.deleted_at <= p_before and app_user.deletion_fence is null - order by app_user.deleted_at, app_user.id - limit (select page_size from bounded) - ) - select * from claimed - union all - select * from pending -$function$; - -create or replace function public.webhooks_discover_resource_deletion_jobs(p_limit integer) -returns table (projects integer, threads integer) -language plpgsql security definer set search_path = '' -as $function$ -declare - project_count integer; - page_size integer := greatest(1, least(coalesce(p_limit, 1), 25)); - thread_count integer; -begin - with candidates as ( - select project.user_id, project.id, project.deleted_at - from public.v2_projects project - join public.v2_users app_user on app_user.id = project.user_id - where project.deleted_at is not null and app_user.deleted_at is null - order by project.deleted_at, project.id - limit page_size - ), inserted as ( - insert into public.v2_resource_deletion_jobs (user_id, kind, resource_id, generation) - select candidate.user_id, 'project-deletion', candidate.id, candidate.deleted_at - from candidates candidate - on conflict (kind, resource_id, generation) do nothing - returning id - ) select count(*)::integer into project_count from inserted; - - with candidates as ( - select thread.user_id, thread.id, thread.deleted_at - from public.v2_threads thread - join public.v2_users app_user on app_user.id = thread.user_id - left join public.v2_projects project - on project.id = thread.project_id and project.user_id = thread.user_id - where thread.deleted_at is not null - and app_user.deleted_at is null - and (thread.project_id is null or project.deleted_at is null) - order by thread.deleted_at, thread.id - limit page_size - ), inserted as ( - insert into public.v2_resource_deletion_jobs (user_id, kind, resource_id, generation) - select candidate.user_id, 'thread-deletion', candidate.id, candidate.deleted_at - from candidates candidate - on conflict (kind, resource_id, generation) do nothing - returning id - ) select count(*)::integer into thread_count from inserted; - return query select project_count, thread_count; -end -$function$; - -create or replace function public.webhooks_claim_ready_resource_deletion_jobs( - p_lease_token uuid, - p_limit integer, - p_max_failures integer, - p_now timestamp with time zone -) -returns table (disposition text, job_id uuid, user_id uuid, continuation integer) -language plpgsql security definer set search_path = '' -as $function$ -declare - candidate_ids uuid[]; - quarantine_ids uuid[]; -begin - if p_lease_token is null or p_now is null or p_max_failures < 1 then - raise exception 'invalid resource-deletion claim input'; - end if; - if not pg_catalog.pg_try_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:database-maintenance:v1', 0) - ) then - return; - end if; - select coalesce(array_agg(candidate.id), array[]::uuid[]) - into candidate_ids - from ( - select job.id - from public.v2_resource_deletion_jobs job - where (job.status = 'queued' and job.next_attempt_at <= p_now) - or (job.status = 'leased' and job.lease_expires_at <= p_now) - order by job.next_attempt_at, job.id - limit greatest(1, least(coalesce(p_limit, 1), 25)) - for update skip locked - ) candidate; - select coalesce(array_agg(job.id), array[]::uuid[]) - into quarantine_ids - from public.v2_resource_deletion_jobs job - where job.id = any(candidate_ids) - and job.status = 'leased' - and job.failure_count + 1 >= p_max_failures; - - return query - update public.v2_resource_deletion_jobs job - set continuation = job.continuation + 1, - failure_count = job.failure_count + 1, - last_error_code = 'resource_deletion_lease_expired', - lease_expires_at = null, - lease_token = null, - status = 'quarantined' - where job.id = any(quarantine_ids) - returning 'quarantined'::text, job.id, job.user_id, job.continuation; - return query - update public.v2_resource_deletion_jobs job - set continuation = case when job.status = 'leased' - then job.continuation + 1 else job.continuation end, - failure_count = case when job.status = 'leased' - then job.failure_count + 1 else job.failure_count end, - last_error_code = case when job.status = 'leased' - then 'resource_deletion_lease_expired' else job.last_error_code end, - lease_expires_at = p_now + interval '2 hours', - lease_token = p_lease_token, - next_attempt_at = case when job.status = 'leased' - then p_now else job.next_attempt_at end, - status = 'leased' - where job.id = any(candidate_ids) - and not (job.id = any(quarantine_ids)) - returning 'leased'::text, job.id, job.user_id, job.continuation; -end -$function$; - -create or replace function public.webhooks_finalize_current_user_deletion( - p_deletion_fence text, - p_clerk_identity_hash text -) -returns boolean -language plpgsql security definer set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); - deleted_id uuid; -begin - if p_deletion_fence is null or p_deletion_fence = '' - or p_clerk_identity_hash !~ '^[0-9a-f]{64}$' then - raise exception 'invalid user-deletion finalization identity'; - end if; - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:clerk-identity:' || p_clerk_identity_hash, 0) - ); - if exists ( - select 1 from public.v2_deleted_clerk_identities retired - where retired.clerk_identity_hash = p_clerk_identity_hash - ) then - return false; - end if; - if not exists ( - select 1 from public.v2_users app_user - where app_user.id = actor_id and app_user.deletion_fence = p_deletion_fence - ) then - raise exception 'user deletion fence is no longer valid'; - end if; - insert into public.v2_deleted_clerk_identities (clerk_identity_hash) - values (p_clerk_identity_hash); - delete from public.v2_users app_user - where app_user.id = actor_id and app_user.deletion_fence = p_deletion_fence - returning app_user.id into deleted_id; - if deleted_id is null then - raise exception 'claimed user deletion did not remove exactly one user'; - end if; - return true; -end -$function$; - -revoke all on function - public.gateway_resolve_clerk_user(text), - public.sync_clerk_user(text, text, text, text), - public.webhooks_mark_clerk_user_deleted(text, timestamp with time zone), - public.webhooks_resolve_polar_customer(text), - public.webhooks_expire_composio_connection(text), - public.webhooks_list_due_user_deletions(timestamp with time zone, integer), - public.webhooks_list_daily_activation_events(date, text, uuid, integer), - public.webhooks_list_expired_outputs(timestamp with time zone, timestamp with time zone, uuid, integer), - public.webhooks_delete_expired_outputs(timestamp with time zone, jsonb), - public.webhooks_discover_resource_deletion_jobs(integer), - public.webhooks_claim_ready_resource_deletion_jobs(uuid, integer, integer, timestamp with time zone), - public.webhooks_finalize_current_user_deletion(text, text) -from public, app_gateway, app_agent, app_webhooks; - -grant execute on function public.gateway_resolve_clerk_user(text) -to app_gateway; -grant execute on function public.sync_clerk_user(text, text, text, text) -to app_gateway, app_webhooks; -grant execute on function - public.webhooks_mark_clerk_user_deleted(text, timestamp with time zone), - public.webhooks_resolve_polar_customer(text), - public.webhooks_expire_composio_connection(text), - public.webhooks_list_due_user_deletions(timestamp with time zone, integer), - public.webhooks_list_daily_activation_events(date, text, uuid, integer), - public.webhooks_list_expired_outputs(timestamp with time zone, timestamp with time zone, uuid, integer), - public.webhooks_delete_expired_outputs(timestamp with time zone, jsonb), - public.webhooks_discover_resource_deletion_jobs(integer), - public.webhooks_claim_ready_resource_deletion_jobs(uuid, integer, integer, timestamp with time zone), - public.webhooks_finalize_current_user_deletion(text, text) -to app_webhooks; diff --git a/infra/supabase/migrations/post/0061_enforce_signed_tenant_boundary.sql b/infra/supabase/migrations/post/0061_enforce_signed_tenant_boundary.sql deleted file mode 100644 index 0a7fedd6..00000000 --- a/infra/supabase/migrations/post/0061_enforce_signed_tenant_boundary.sql +++ /dev/null @@ -1,577 +0,0 @@ -do $dependency$ -begin - if not exists ( - select 1 from public._raw_migrations - where filename = 'infra/supabase/migrations/post/0059_finalize_worker_database_roles.sql' - ) then - raise exception 'signed tenant enforcement requires post/0059'; - end if; - if not exists ( - select 1 from public._raw_migrations - where filename = 'infra/supabase/migrations/post/0060_expand_signed_tenant_boundary.sql' - ) then - raise exception 'signed tenant enforcement requires pre-deploy post/0060'; - end if; -end -$dependency$; - --- The caller supplies a short-lived, role-bound HMAC. GUCs are transaction-local, --- so Hyperdrive cannot carry an accepted tenant identity into a later request. -create or replace function public.current_app_user() -returns uuid -language plpgsql stable security definer set search_path = '' -as $function$ -declare - actor_id uuid; - actor_text text := pg_catalog.current_setting('app.user_id', true); - audience text := session_user; - context_secret text; - expected_description text; - expected_hmac bytea; - expected_name text; - issued_at bigint; - issued_text text := pg_catalog.current_setting('app.context_issued_at', true); - nonce_text text := pg_catalog.current_setting('app.context_nonce', true); - now_ms bigint; - payload text; - signature_difference integer; - signature_text text := pg_catalog.current_setting('app.context_signature', true); - supplied_hmac bytea; -begin - if audience not in ('app_agent', 'app_gateway', 'app_webhooks') then - raise exception using - errcode = '42501', - message = 'signed tenant context is unavailable to this database role'; - end if; - if actor_text is null - or actor_text !~ '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' - or issued_text is null - or issued_text !~ '^[0-9]{13}$' - or nonce_text is null - or nonce_text !~ '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' - or signature_text is null - or signature_text !~ '^[0-9a-f]{64}$' then - raise exception using - errcode = '42501', - message = 'signed tenant context is malformed'; - end if; - - actor_id := actor_text::uuid; - issued_at := issued_text::bigint; - now_ms := ( - extract(epoch from pg_catalog.transaction_timestamp()) * 1000 - )::bigint; - if issued_at < now_ms - 15000 or issued_at > now_ms + 2000 then - raise exception using - errcode = '42501', - message = 'signed tenant context is outside its freshness window'; - end if; - - expected_name := 'cheatcode-database-context-' || - pg_catalog.replace(audience, '_', '-') || '-v1'; - expected_description := 'Cheatcode signed tenant context HMAC for ' || audience; - select secret.decrypted_secret into strict context_secret - from vault.decrypted_secrets secret - where secret.name = expected_name - and secret.description = expected_description; - if pg_catalog.octet_length(context_secret) < 32 then - raise exception 'signed tenant context secret is invalid'; - end if; - - payload := 'cheatcode-database-context-v1' || pg_catalog.chr(10) || - audience || pg_catalog.chr(10) || actor_text || pg_catalog.chr(10) || - issued_text || pg_catalog.chr(10) || nonce_text; - expected_hmac := extensions.hmac( - pg_catalog.convert_to(payload, 'UTF8'), - pg_catalog.convert_to(context_secret, 'UTF8'), - 'sha256' - ); - supplied_hmac := pg_catalog.decode(signature_text, 'hex'); - select pg_catalog.bit_or( - pg_catalog.get_byte(expected_hmac, offset_value) # - pg_catalog.get_byte(supplied_hmac, offset_value) - ) into signature_difference - from pg_catalog.generate_series(0, 31) as offsets(offset_value); - if signature_difference is distinct from 0 then - raise exception using - errcode = '42501', - message = 'signed tenant context signature is invalid'; - end if; - return actor_id; -exception - when no_data_found or too_many_rows then - raise exception using - errcode = '42501', - message = 'signed tenant context secret contract is invalid'; -end -$function$; - -alter function public.current_app_user() owner to postgres; - --- Audit maintenance must apply the same closed posture to every future child; --- partition ACL/RLS state is not inherited as an independent direct-access contract. -create or replace function public.ensure_v2_audit_partitions() -returns integer -language plpgsql -set search_path = '' -as $function$ -declare - child_oid oid; - created_count integer := 0; - expected_bound text; - month_offset integer; - partition_bound text; - partition_end date; - partition_name text; - partition_start date; -begin - if pg_catalog.to_regclass('public.v2_audit_log') is null then - raise exception 'audit partition maintenance requires public.v2_audit_log'; - end if; - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:v2:audit-partitions', 0) - ); - - for month_offset in 0..3 loop - partition_start := ( - pg_catalog.date_trunc( - 'month', - pg_catalog.timezone('UTC', pg_catalog.statement_timestamp()) - ) + pg_catalog.make_interval(months => month_offset) - )::date; - partition_end := (partition_start + pg_catalog.make_interval(months => 1))::date; - partition_name := 'v2_audit_log_' || pg_catalog.to_char(partition_start, 'YYYY_MM'); - expected_bound := pg_catalog.format( - 'FOR VALUES FROM (%L) TO (%L)', - partition_start::text || ' 00:00:00+00', - partition_end::text || ' 00:00:00+00' - ); - child_oid := pg_catalog.to_regclass(pg_catalog.format('public.%I', partition_name)); - - if child_oid is null then - execute pg_catalog.format( - 'create table public.%I partition of public.v2_audit_log for values from (%L) to (%L)', - partition_name, - partition_start::text || ' 00:00:00+00', - partition_end::text || ' 00:00:00+00' - ); - child_oid := pg_catalog.to_regclass(pg_catalog.format('public.%I', partition_name)); - created_count := created_count + 1; - elsif not exists ( - select 1 from pg_catalog.pg_inherits inheritance - where inheritance.inhrelid = child_oid - and inheritance.inhparent = 'public.v2_audit_log'::regclass - ) then - raise exception 'audit partition name % is occupied by an unattached relation', - partition_name; - else - select pg_catalog.pg_get_expr(relation.relpartbound, relation.oid) - into partition_bound - from pg_catalog.pg_class relation - where relation.oid = child_oid; - if partition_bound is distinct from expected_bound then - raise exception 'audit partition % has unexpected bounds: %', - partition_name, - partition_bound; - end if; - end if; - - execute pg_catalog.format( - 'alter table public.%I enable row level security', partition_name - ); - execute pg_catalog.format( - 'alter table public.%I force row level security', partition_name - ); - execute pg_catalog.format( - 'revoke all privileges on table public.%I from app_gateway, app_agent, app_webhooks', - partition_name - ); - execute pg_catalog.format( - 'drop policy if exists v2_audit_partition_postgres_all on public.%I', partition_name - ); - execute pg_catalog.format( - 'create policy v2_audit_partition_postgres_all on public.%I for all to postgres using (true) with check (true)', - partition_name - ); - end loop; - return created_count; -end -$function$; - -alter function public.ensure_v2_audit_partitions() owner to postgres; - --- Replace every historical policy at once. No permissive policy from the staged --- role migration is allowed to survive this final boundary. -do $policies$ -declare - policy_record record; - table_name text; -begin - foreach table_name in array array[ - 'v2_agent_runs', - 'v2_audit_log', - 'v2_deleted_clerk_identities', - 'v2_entitlements', - 'v2_generated_outputs', - 'v2_messages', - 'v2_projects', - 'v2_provider_keys', - 'v2_resource_deletion_jobs', - 'v2_threads', - 'v2_user_integrations', - 'v2_user_profiles', - 'v2_user_skills', - 'v2_users' - ] loop - execute pg_catalog.format( - 'alter table public.%I enable row level security', table_name - ); - execute pg_catalog.format( - 'alter table public.%I force row level security', table_name - ); - for policy_record in - select policy.policyname - from pg_catalog.pg_policies policy - where policy.schemaname = 'public' and policy.tablename = table_name - loop - execute pg_catalog.format( - 'drop policy %I on public.%I', policy_record.policyname, table_name - ); - end loop; - execute pg_catalog.format( - 'create policy %I on public.%I for all to postgres using (true) with check (true)', - table_name || '_postgres_all', - table_name - ); - end loop; -end -$policies$; - -create policy v2_users_select_own on public.v2_users - for select to app_gateway, app_agent, app_webhooks - using (id = (select public.current_app_user())); -create policy v2_users_update_own on public.v2_users - for update to app_gateway, app_agent, app_webhooks - using (id = (select public.current_app_user())) - with check (id = (select public.current_app_user())); - -create policy v2_entitlements_select_own on public.v2_entitlements - for select to app_gateway, app_agent, app_webhooks - using (user_id = (select public.current_app_user())); -create policy v2_entitlements_insert_own on public.v2_entitlements - for insert to app_gateway, app_webhooks - with check (user_id = (select public.current_app_user())); -create policy v2_entitlements_update_own on public.v2_entitlements - for update to app_gateway, app_webhooks - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); - -create policy v2_user_profiles_select_own on public.v2_user_profiles - for select to app_gateway, app_agent - using (user_id = (select public.current_app_user())); -create policy v2_user_profiles_insert_own on public.v2_user_profiles - for insert to app_gateway - with check (user_id = (select public.current_app_user())); -create policy v2_user_profiles_update_own on public.v2_user_profiles - for update to app_gateway - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); - -create policy v2_projects_select_own on public.v2_projects - for select to app_gateway, app_agent, app_webhooks - using (user_id = (select public.current_app_user())); -create policy v2_projects_insert_own on public.v2_projects - for insert to app_gateway, app_agent - with check (user_id = (select public.current_app_user())); -create policy v2_projects_update_own on public.v2_projects - for update to app_gateway, app_webhooks - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); -create policy v2_projects_delete_own on public.v2_projects - for delete to app_webhooks - using (user_id = (select public.current_app_user())); - -create policy v2_threads_select_own on public.v2_threads - for select to app_gateway, app_agent, app_webhooks - using (user_id = (select public.current_app_user())); -create policy v2_threads_insert_own on public.v2_threads - for insert to app_gateway - with check (user_id = (select public.current_app_user())); -create policy v2_threads_update_own on public.v2_threads - for update to app_gateway, app_agent, app_webhooks - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); -create policy v2_threads_delete_own on public.v2_threads - for delete to app_webhooks - using (user_id = (select public.current_app_user())); - -create policy v2_messages_select_own on public.v2_messages - for select to app_gateway, app_agent - using (user_id = (select public.current_app_user())); -create policy v2_messages_insert_own on public.v2_messages - for insert to app_agent - with check (user_id = (select public.current_app_user())); - -create policy v2_agent_runs_select_own on public.v2_agent_runs - for select to app_gateway, app_agent, app_webhooks - using (user_id = (select public.current_app_user())); -create policy v2_agent_runs_insert_own on public.v2_agent_runs - for insert to app_agent - with check (user_id = (select public.current_app_user())); -create policy v2_agent_runs_update_own on public.v2_agent_runs - for update to app_agent - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); - -create policy v2_generated_outputs_select_own on public.v2_generated_outputs - for select to app_agent, app_webhooks - using (user_id = (select public.current_app_user())); -create policy v2_generated_outputs_insert_own on public.v2_generated_outputs - for insert to app_agent - with check (user_id = (select public.current_app_user())); -create policy v2_generated_outputs_delete_own on public.v2_generated_outputs - for delete to app_webhooks - using (user_id = (select public.current_app_user())); - -create policy v2_user_skills_select_own on public.v2_user_skills - for select to app_gateway, app_agent - using (user_id = (select public.current_app_user())); -create policy v2_user_skills_insert_own on public.v2_user_skills - for insert to app_gateway, app_agent - with check (user_id = (select public.current_app_user())); -create policy v2_user_skills_update_own on public.v2_user_skills - for update to app_gateway, app_agent - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); -create policy v2_user_skills_delete_own on public.v2_user_skills - for delete to app_gateway - using (user_id = (select public.current_app_user())); - -create policy v2_user_integrations_select_own on public.v2_user_integrations - for select to app_gateway, app_agent, app_webhooks - using (user_id = (select public.current_app_user())); -create policy v2_user_integrations_insert_own on public.v2_user_integrations - for insert to app_gateway - with check (user_id = (select public.current_app_user())); -create policy v2_user_integrations_update_own on public.v2_user_integrations - for update to app_gateway - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); -create policy v2_user_integrations_delete_own on public.v2_user_integrations - for delete to app_gateway - using (user_id = (select public.current_app_user())); - -create policy v2_resource_deletion_jobs_select_own on public.v2_resource_deletion_jobs - for select to app_webhooks - using (user_id = (select public.current_app_user())); -create policy v2_resource_deletion_jobs_insert_own on public.v2_resource_deletion_jobs - for insert to app_webhooks - with check (user_id = (select public.current_app_user())); -create policy v2_resource_deletion_jobs_update_own on public.v2_resource_deletion_jobs - for update to app_webhooks - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); -create policy v2_resource_deletion_jobs_delete_own on public.v2_resource_deletion_jobs - for delete to app_webhooks - using (user_id = (select public.current_app_user())); - -create policy v2_provider_keys_select_own on public.v2_provider_keys - for select to app_gateway, app_webhooks - using (user_id = (select public.current_app_user())); -create policy v2_provider_keys_update_own on public.v2_provider_keys - for update to app_gateway, app_webhooks - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); - --- Reset every service ACL before rebuilding the reviewed steady-state matrix. -do $acl_reset$ -begin - execute pg_catalog.format( - 'revoke all privileges on database %I from app_gateway, app_agent, app_webhooks', - pg_catalog.current_database() - ); - revoke all on schema public, extensions, vault - from app_gateway, app_agent, app_webhooks; - revoke all privileges on all tables in schema public - from app_gateway, app_agent, app_webhooks; - revoke all privileges on all sequences in schema public - from app_gateway, app_agent, app_webhooks; - revoke all privileges on all functions in schema public - from app_gateway, app_agent, app_webhooks; -end -$acl_reset$; - -revoke execute on all functions in schema public - from public, anon, authenticated, service_role; -do $database_grant$ -begin - execute pg_catalog.format( - 'grant connect on database %I to app_gateway, app_agent, app_webhooks', - pg_catalog.current_database() - ); -end -$database_grant$; -grant usage on schema public to app_gateway, app_agent, app_webhooks; - -grant select on table - public.v2_entitlements, - public.v2_messages, - public.v2_projects, - public.v2_threads, - public.v2_user_integrations, - public.v2_user_profiles, - public.v2_user_skills -to app_gateway; -grant select (avatar_url, clerk_id, deleted_at, deletion_fence, display_name, email, id, polar_customer_id) - on table public.v2_users to app_gateway; -grant select (finished_at, id, started_at, status, user_id) - on table public.v2_agent_runs to app_gateway; -grant select (created_at, disabled_at, disabled_reason, provider, user_id) - on table public.v2_provider_keys to app_gateway; -grant insert on table - public.v2_entitlements, - public.v2_projects, - public.v2_threads, - public.v2_user_integrations, - public.v2_user_profiles, - public.v2_user_skills -to app_gateway; -grant update (display_name) on table public.v2_users to app_gateway; -grant update ( - cancel_at_period_end, current_period_end, current_period_start, - polar_subscription_id, subscription_status, updated_at -) on table public.v2_entitlements to app_gateway; -grant update (deleted_at, master_instructions, name, settings, updated_at) - on table public.v2_projects to app_gateway; -grant update (deleted_at, title, updated_at) on table public.v2_threads to app_gateway; -grant update (disabled_at, disabled_reason) on table public.v2_provider_keys to app_gateway; -grant update (is_default, status) on table public.v2_user_integrations to app_gateway; -grant update ( - agent_display_name, disabled_models, global_memory, - onboarding_completed_at, onboarding_state -) on table public.v2_user_profiles to app_gateway; -grant update (body, category, description, tags, updated_at) - on table public.v2_user_skills to app_gateway; -grant delete on table public.v2_user_integrations, public.v2_user_skills to app_gateway; - -grant select on table - public.v2_messages, - public.v2_projects, - public.v2_threads, - public.v2_user_skills -to app_agent; -grant select (deleted_at, deletion_fence, first_artifact_at, id) - on table public.v2_users to app_agent; -grant select (current_period_end, current_period_start, subscription_status, tier, updated_at, user_id) - on table public.v2_entitlements to app_agent; -grant select (id, idempotency_key_hash, model_id, request_body_hash, status, thread_id, user_id) - on table public.v2_agent_runs to app_agent; -grant select (expires_at, filename, id, mime_type, r2_key, user_id) - on table public.v2_generated_outputs to app_agent; -grant select (agent_display_name, disabled_models, global_memory, user_id) - on table public.v2_user_profiles to app_agent; -grant select (composio_connection_id, integration, is_default, status, updated_at, user_id) - on table public.v2_user_integrations to app_agent; -grant insert on table - public.v2_agent_runs, - public.v2_generated_outputs, - public.v2_messages, - public.v2_projects, - public.v2_user_skills -to app_agent; -grant update (first_artifact_at) on table public.v2_users to app_agent; -grant update (active_run_id, launch_intent, project_id, updated_at) - on table public.v2_threads to app_agent; -grant update (finished_at, model_id, status) on table public.v2_agent_runs to app_agent; -grant update (body, category, description, tags, updated_at) - on table public.v2_user_skills to app_agent; - -grant select on table public.v2_entitlements, public.v2_resource_deletion_jobs - to app_webhooks; -grant select (avatar_url, clerk_id, created_at, deleted_at, deletion_fence, display_name, email, id, polar_customer_id) - on table public.v2_users to app_webhooks; -grant select (id, started_at, thread_id, user_id) - on table public.v2_agent_runs to app_webhooks; -grant select (agent_run_id, expires_at, id, r2_key, user_id) - on table public.v2_generated_outputs to app_webhooks; -grant select (archive_after, created_at, deleted_at, id, name, over_quota, updated_at, user_id, workspace_slug) - on table public.v2_projects to app_webhooks; -grant select (active_run_id, deleted_at, id, project_id, user_id) - on table public.v2_threads to app_webhooks; -grant select (created_at, disabled_at, disabled_reason, fingerprint, provider, revalidation_claimed_at, revalidation_lease_token, user_id) - on table public.v2_provider_keys to app_webhooks; -grant select (composio_connection_id, integration, is_default, status, updated_at, user_id) - on table public.v2_user_integrations to app_webhooks; -grant insert on table public.v2_entitlements, public.v2_resource_deletion_jobs to app_webhooks; -grant update (deleted_at, deletion_fence, polar_customer_id) - on table public.v2_users to app_webhooks; -grant update ( - cancel_at_period_end, current_period_end, current_period_start, - polar_subscription_id, subscription_status, tier, updated_at -) on table public.v2_entitlements to app_webhooks; -grant update (archive_after, deleted_at, over_quota, updated_at, workspace_slug) - on table public.v2_projects to app_webhooks; -grant update (active_run_id, deleted_at, updated_at) - on table public.v2_threads to app_webhooks; -grant update ( - disabled_at, disabled_reason, last_revalidated_at, - revalidation_claimed_at, revalidation_lease_token -) on table public.v2_provider_keys to app_webhooks; -grant update ( - continuation, cursor, failure_count, last_error_code, lease_expires_at, - lease_token, next_attempt_at, phase, status -) on table public.v2_resource_deletion_jobs to app_webhooks; -grant delete on table - public.v2_generated_outputs, - public.v2_projects, - public.v2_resource_deletion_jobs, - public.v2_threads -to app_webhooks; - -grant execute on function - public.current_app_user(), - public.delete_provider_key(text), - public.gateway_resolve_clerk_user(text), - public.set_provider_key(text, text), - public.sync_clerk_user(text, text, text, text), - public.uuidv7() -to app_gateway; -grant execute on function - public.current_app_user(), - public.get_provider_key(text), - public.uuidv7() -to app_agent; -grant execute on function - public.claim_provider_key_revalidation_targets(integer), - public.current_app_user(), - public.delete_all_provider_keys(), - public.get_provider_key(text), - public.scrub_current_user_audit(), - public.sync_clerk_user(text, text, text, text), - public.uuidv7(), - public.webhooks_claim_ready_resource_deletion_jobs(uuid, integer, integer, timestamp with time zone), - public.webhooks_delete_expired_outputs(timestamp with time zone, jsonb), - public.webhooks_discover_resource_deletion_jobs(integer), - public.webhooks_expire_composio_connection(text), - public.webhooks_finalize_current_user_deletion(text, text), - public.webhooks_list_daily_activation_events(date, text, uuid, integer), - public.webhooks_list_due_user_deletions(timestamp with time zone, integer), - public.webhooks_list_expired_outputs(timestamp with time zone, timestamp with time zone, uuid, integer), - public.webhooks_mark_clerk_user_deleted(text, timestamp with time zone), - public.webhooks_resolve_polar_customer(text) -to app_webhooks; - -alter function public.gateway_resolve_clerk_user(text) owner to postgres; -alter function public.sync_clerk_user(text, text, text, text) owner to postgres; -alter function public.webhooks_mark_clerk_user_deleted(text, timestamp with time zone) owner to postgres; -alter function public.webhooks_resolve_polar_customer(text) owner to postgres; -alter function public.webhooks_expire_composio_connection(text) owner to postgres; -alter function public.webhooks_list_due_user_deletions(timestamp with time zone, integer) owner to postgres; -alter function public.webhooks_list_daily_activation_events(date, text, uuid, integer) owner to postgres; -alter function public.webhooks_list_expired_outputs(timestamp with time zone, timestamp with time zone, uuid, integer) owner to postgres; -alter function public.webhooks_delete_expired_outputs(timestamp with time zone, jsonb) owner to postgres; -alter function public.webhooks_discover_resource_deletion_jobs(integer) owner to postgres; -alter function public.webhooks_claim_ready_resource_deletion_jobs(uuid, integer, integer, timestamp with time zone) owner to postgres; -alter function public.webhooks_finalize_current_user_deletion(text, text) owner to postgres; - -select public.ensure_v2_audit_partitions(); diff --git a/infra/supabase/migrations/post/0062_user_deletion_jobs.sql b/infra/supabase/migrations/post/0062_user_deletion_jobs.sql deleted file mode 100644 index 9cdc1756..00000000 --- a/infra/supabase/migrations/post/0062_user_deletion_jobs.sql +++ /dev/null @@ -1,178 +0,0 @@ -revoke all on table public.v2_user_deletion_jobs -from public, anon, authenticated, service_role, app_gateway, app_agent, app_webhooks; - -alter table public.v2_user_deletion_jobs enable row level security; -alter table public.v2_user_deletion_jobs force row level security; - -create policy v2_user_deletion_jobs_postgres_all on public.v2_user_deletion_jobs - as permissive for all to postgres using (true) with check (true); -create policy v2_user_deletion_jobs_select_own on public.v2_user_deletion_jobs - as permissive for select to app_webhooks using (user_id = (select public.current_app_user())); -create policy v2_user_deletion_jobs_insert_own on public.v2_user_deletion_jobs - as permissive for insert to app_webhooks with check (user_id = (select public.current_app_user())); -create policy v2_user_deletion_jobs_update_own on public.v2_user_deletion_jobs - as permissive for update to app_webhooks - using (user_id = (select public.current_app_user())) - with check (user_id = (select public.current_app_user())); -create policy v2_user_deletion_jobs_delete_own on public.v2_user_deletion_jobs - as permissive for delete to app_webhooks using (user_id = (select public.current_app_user())); - -grant select, insert, delete on table public.v2_user_deletion_jobs to app_webhooks; -grant update ( - continuation, - cursor, - failure_count, - last_error_code, - lease_expires_at, - lease_token, - next_attempt_at, - phase, - status -) on table public.v2_user_deletion_jobs to app_webhooks; - -create or replace function public.webhooks_discover_user_deletion_jobs( - p_before timestamp with time zone, - p_limit integer -) -returns integer -language plpgsql security definer set search_path = '' -as $function$ -declare - discovered integer; - page_size integer := greatest(1, least(coalesce(p_limit, 1), 25)); -begin - if p_before is null then - raise exception 'invalid user-deletion discovery cutoff'; - end if; - if not pg_catalog.pg_try_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:database-maintenance:v1', 0) - ) then - return 0; - end if; - with candidates as ( - select app_user.id, app_user.deleted_at - from public.v2_users app_user - where app_user.deleted_at <= p_before - and ( - app_user.deletion_fence is null - or app_user.deletion_fence = - ((extract(epoch from app_user.deleted_at) * 1000)::bigint)::text - ) - and not exists ( - select 1 - from public.v2_user_deletion_jobs existing - where existing.user_id = app_user.id - and existing.generation = app_user.deleted_at - ) - order by app_user.deleted_at, app_user.id - limit page_size - ), inserted as ( - insert into public.v2_user_deletion_jobs (user_id, generation) - select candidate.id, candidate.deleted_at - from candidates candidate - on conflict (user_id, generation) do nothing - returning id - ) - select count(*)::integer into discovered from inserted; - return discovered; -end -$function$; - -create or replace function public.webhooks_claim_ready_user_deletion_jobs( - p_lease_token uuid, - p_limit integer, - p_max_failures integer, - p_now timestamp with time zone -) -returns table (disposition text, job_id uuid, user_id uuid, continuation integer) -language plpgsql security definer set search_path = '' -as $function$ -declare - candidate record; - expected_fence text; - page_size integer := greatest(1, least(coalesce(p_limit, 1), 25)); -begin - if p_lease_token is null or p_now is null or p_max_failures is null - or p_max_failures < 1 then - raise exception 'invalid user-deletion claim input'; - end if; - if not pg_catalog.pg_try_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:database-maintenance:v1', 0) - ) then - return; - end if; - for candidate in - select job.id, job.user_id, job.generation, job.continuation, - job.failure_count, job.status - from public.v2_user_deletion_jobs job - where (job.status = 'queued' and job.next_attempt_at <= p_now) - or (job.status = 'leased' and job.lease_expires_at <= p_now) - order by job.next_attempt_at, job.id - limit page_size - for update skip locked - loop - expected_fence := - ((extract(epoch from candidate.generation) * 1000)::bigint)::text; - update public.v2_users app_user - set deletion_fence = expected_fence - where app_user.id = candidate.user_id - and app_user.deleted_at = candidate.generation - and ( - app_user.deletion_fence is null - or app_user.deletion_fence = expected_fence - ); - if not found then - delete from public.v2_user_deletion_jobs job where job.id = candidate.id; - return query select 'stale'::text, candidate.id, candidate.user_id, - candidate.continuation; - elsif candidate.status = 'leased' - and candidate.failure_count + 1 >= p_max_failures then - return query - update public.v2_user_deletion_jobs job - set continuation = job.continuation + 1, - failure_count = job.failure_count + 1, - last_error_code = 'user_deletion_lease_expired', - lease_expires_at = null, - lease_token = null, - status = 'quarantined' - where job.id = candidate.id - returning 'quarantined'::text, job.id, job.user_id, job.continuation; - else - return query - update public.v2_user_deletion_jobs job - set continuation = case when candidate.status = 'leased' - then job.continuation + 1 else job.continuation end, - failure_count = case when candidate.status = 'leased' - then job.failure_count + 1 else job.failure_count end, - last_error_code = case when candidate.status = 'leased' - then 'user_deletion_lease_expired' else job.last_error_code end, - lease_expires_at = p_now + interval '2 hours', - lease_token = p_lease_token, - next_attempt_at = case when candidate.status = 'leased' - then p_now else job.next_attempt_at end, - status = 'leased' - where job.id = candidate.id - returning 'leased'::text, job.id, job.user_id, job.continuation; - end if; - end loop; -end -$function$; - -alter function public.webhooks_discover_user_deletion_jobs(timestamp with time zone, integer) -owner to postgres; -alter function public.webhooks_claim_ready_user_deletion_jobs( - uuid, - integer, - integer, - timestamp with time zone -) owner to postgres; - -revoke all on function - public.webhooks_discover_user_deletion_jobs(timestamp with time zone, integer), - public.webhooks_claim_ready_user_deletion_jobs(uuid, integer, integer, timestamp with time zone) -from public, app_gateway, app_agent, app_webhooks; - -grant execute on function - public.webhooks_discover_user_deletion_jobs(timestamp with time zone, integer), - public.webhooks_claim_ready_user_deletion_jobs(uuid, integer, integer, timestamp with time zone) -to app_webhooks; diff --git a/infra/supabase/migrations/post/0063_remove_legacy_user_deletion_admission.sql b/infra/supabase/migrations/post/0063_remove_legacy_user_deletion_admission.sql deleted file mode 100644 index f452ec2c..00000000 --- a/infra/supabase/migrations/post/0063_remove_legacy_user_deletion_admission.sql +++ /dev/null @@ -1,21 +0,0 @@ -drop function public.webhooks_list_due_user_deletions(timestamp with time zone, integer); - --- The steady-state ACL reset in 0061 intentionally runs after every expansion. --- Restore only the reviewed account-deletion job surface introduced by 0062. -grant select, insert, delete on table public.v2_user_deletion_jobs to app_webhooks; -grant update ( - continuation, - cursor, - failure_count, - last_error_code, - lease_expires_at, - lease_token, - next_attempt_at, - phase, - status -) on table public.v2_user_deletion_jobs to app_webhooks; - -grant execute on function - public.webhooks_discover_user_deletion_jobs(timestamp with time zone, integer), - public.webhooks_claim_ready_user_deletion_jobs(uuid, integer, integer, timestamp with time zone) -to app_webhooks; diff --git a/infra/supabase/migrations/post/0064_retention_jobs.sql b/infra/supabase/migrations/post/0064_retention_jobs.sql deleted file mode 100644 index 49fd39a4..00000000 --- a/infra/supabase/migrations/post/0064_retention_jobs.sql +++ /dev/null @@ -1,37 +0,0 @@ -alter table public.v2_retention_jobs owner to postgres; - -revoke all on table public.v2_retention_jobs -from public, anon, authenticated, service_role, app_gateway, app_agent, app_webhooks; - -alter table public.v2_retention_jobs enable row level security; -alter table public.v2_retention_jobs force row level security; - -create policy v2_retention_jobs_postgres_all on public.v2_retention_jobs - as permissive for all to postgres using (true) with check (true); -create policy v2_retention_jobs_select_maintenance on public.v2_retention_jobs - as permissive for select to app_webhooks using (true); -create policy v2_retention_jobs_insert_maintenance on public.v2_retention_jobs - as permissive for insert to app_webhooks with check (true); -create policy v2_retention_jobs_update_maintenance on public.v2_retention_jobs - as permissive for update to app_webhooks using (true) with check (true); -create policy v2_retention_jobs_delete_maintenance on public.v2_retention_jobs - as permissive for delete to app_webhooks using (true); - -grant select, delete on table public.v2_retention_jobs to app_webhooks; -grant insert (day, scheduled_at) on table public.v2_retention_jobs to app_webhooks; -grant update ( - activation_cursor_event, - activation_cursor_user_id, - completed_at, - continuation, - failure_count, - last_error_code, - lease_expires_at, - lease_token, - next_attempt_at, - output_cursor_expires_at, - output_cursor_id, - phase, - release_version_id, - status -) on table public.v2_retention_jobs to app_webhooks; diff --git a/infra/supabase/migrations/post/0065_enforce_terminal_clerk_deletion.sql b/infra/supabase/migrations/post/0065_enforce_terminal_clerk_deletion.sql deleted file mode 100644 index 20ac91d0..00000000 --- a/infra/supabase/migrations/post/0065_enforce_terminal_clerk_deletion.sql +++ /dev/null @@ -1,134 +0,0 @@ -create or replace function public.sync_clerk_user( - p_clerk_id text, - p_email text, - p_display_name text, - p_avatar_url text -) -returns table ( - sync_state text, - user_id uuid, - email text, - display_name text, - avatar_url text, - polar_customer_id text, - email_changed boolean, - profile_changed boolean -) -language plpgsql security definer set search_path = '' -as $function$ -declare - identity_hash text; - existing record; - persisted record; -begin - if p_clerk_id is null or btrim(p_clerk_id) = '' or octet_length(p_clerk_id) > 512 then - raise exception 'invalid Clerk identity'; - end if; - if p_email is null or btrim(p_email) = '' or octet_length(p_email) > 512 then - raise exception 'invalid Clerk email'; - end if; - if octet_length(coalesce(p_display_name, '')) > 1024 - or octet_length(coalesce(p_avatar_url, '')) > 4096 then - raise exception 'invalid Clerk profile payload'; - end if; - - identity_hash := pg_catalog.encode( - extensions.digest(pg_catalog.convert_to(p_clerk_id, 'UTF8'), 'sha256'), - 'hex' - ); - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:clerk-identity:' || identity_hash, 0) - ); - if exists ( - select 1 from public.v2_deleted_clerk_identities retired - where retired.clerk_identity_hash = identity_hash - ) then - return query select 'completed', null::uuid, null::text, null::text, - null::text, null::text, false, false; - return; - end if; - - select app_user.avatar_url, app_user.deleted_at, app_user.display_name, - app_user.email, app_user.polar_customer_id - into existing - from public.v2_users app_user - where app_user.clerk_id = p_clerk_id; - if found and existing.deleted_at is not null then - return query select 'in_progress', null::uuid, null::text, null::text, - null::text, null::text, false, false; - return; - end if; - - insert into public.v2_users ( - clerk_id, email, display_name, avatar_url, deleted_at, deletion_fence - ) values ( - p_clerk_id, - p_email, - nullif(btrim(p_display_name), ''), - nullif(btrim(p_avatar_url), ''), - null, - null - ) - on conflict (clerk_id) do update - set email = excluded.email, - display_name = excluded.display_name, - avatar_url = excluded.avatar_url - where public.v2_users.deleted_at is null - and public.v2_users.deletion_fence is null - returning id, public.v2_users.email, public.v2_users.display_name, - public.v2_users.avatar_url, public.v2_users.polar_customer_id - into persisted; - if not found then - return query select 'in_progress', null::uuid, null::text, null::text, - null::text, null::text, false, false; - return; - end if; - - insert into public.v2_entitlements (user_id, tier) - values (persisted.id, 'free') - on conflict on constraint v2_entitlements_pkey do nothing; - return query select - 'active', - persisted.id, - persisted.email, - persisted.display_name, - persisted.avatar_url, - persisted.polar_customer_id, - existing.email is not null and existing.email is distinct from persisted.email, - existing.email is not null and ( - existing.email is distinct from persisted.email - or existing.display_name is distinct from persisted.display_name - or existing.avatar_url is distinct from persisted.avatar_url - ); -end -$function$; - -create or replace function public.webhooks_mark_clerk_user_deleted( - p_clerk_id text, - p_deleted_at timestamp with time zone -) -returns uuid -language plpgsql security definer set search_path = '' -as $function$ -declare - identity_hash text; - deleted_user_id uuid; -begin - if p_clerk_id is null or btrim(p_clerk_id) = '' or p_deleted_at is null then - raise exception 'invalid Clerk deletion payload'; - end if; - identity_hash := pg_catalog.encode( - extensions.digest(pg_catalog.convert_to(p_clerk_id, 'UTF8'), 'sha256'), - 'hex' - ); - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:clerk-identity:' || identity_hash, 0) - ); - update public.v2_users app_user - set deleted_at = coalesce(app_user.deleted_at, p_deleted_at), - deletion_fence = null - where app_user.clerk_id = p_clerk_id and app_user.deletion_fence is null - returning app_user.id into deleted_user_id; - return deleted_user_id; -end -$function$; diff --git a/infra/supabase/migrations/post/0066_enforce_monotonic_clerk_identity_sync.sql b/infra/supabase/migrations/post/0066_enforce_monotonic_clerk_identity_sync.sql deleted file mode 100644 index 3b5096f4..00000000 --- a/infra/supabase/migrations/post/0066_enforce_monotonic_clerk_identity_sync.sql +++ /dev/null @@ -1,300 +0,0 @@ -alter table public.v2_users alter column clerk_updated_at_ms drop default; - -do $preflight$ -begin - if exists ( - select 1 - from public.v2_users app_user - where app_user.deleted_at is not null - and app_user.deletion_fence is not null - and app_user.deletion_fence !~ '^[0-9]+$' - ) then - raise exception 'invalid Clerk deletion fence blocks precision normalization'; - end if; -end -$preflight$; - -update public.v2_users app_user - set deletion_fence = ( - pg_catalog.trunc(extract(epoch from app_user.deleted_at) * 1000)::bigint - )::text - where app_user.deleted_at is not null - and app_user.deletion_fence is not null; - -create or replace function public.webhooks_discover_user_deletion_jobs( - p_before timestamp with time zone, - p_limit integer -) -returns integer -language plpgsql security definer set search_path = '' -as $function$ -declare - discovered integer; - page_size integer := greatest(1, least(coalesce(p_limit, 1), 25)); -begin - if p_before is null then - raise exception 'invalid user-deletion discovery cutoff'; - end if; - if not pg_catalog.pg_try_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:database-maintenance:v1', 0) - ) then - return 0; - end if; - with candidates as ( - select app_user.id, app_user.deleted_at - from public.v2_users app_user - where app_user.deleted_at <= p_before - and ( - app_user.deletion_fence is null - or app_user.deletion_fence = ( - pg_catalog.trunc(extract(epoch from app_user.deleted_at) * 1000)::bigint - )::text - ) - and not exists ( - select 1 - from public.v2_user_deletion_jobs existing - where existing.user_id = app_user.id - and existing.generation = app_user.deleted_at - ) - order by app_user.deleted_at, app_user.id - limit page_size - ), inserted as ( - insert into public.v2_user_deletion_jobs (user_id, generation) - select candidate.id, candidate.deleted_at - from candidates candidate - on conflict (user_id, generation) do nothing - returning id - ) - select count(*)::integer into discovered from inserted; - return discovered; -end -$function$; - -create or replace function public.webhooks_claim_ready_user_deletion_jobs( - p_lease_token uuid, - p_limit integer, - p_max_failures integer, - p_now timestamp with time zone -) -returns table (disposition text, job_id uuid, user_id uuid, continuation integer) -language plpgsql security definer set search_path = '' -as $function$ -declare - candidate record; - expected_fence text; - page_size integer := greatest(1, least(coalesce(p_limit, 1), 25)); -begin - if p_lease_token is null or p_now is null or p_max_failures is null - or p_max_failures < 1 then - raise exception 'invalid user-deletion claim input'; - end if; - if not pg_catalog.pg_try_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:database-maintenance:v1', 0) - ) then - return; - end if; - for candidate in - select job.id, job.user_id, job.generation, job.continuation, - job.failure_count, job.status - from public.v2_user_deletion_jobs job - where (job.status = 'queued' and job.next_attempt_at <= p_now) - or (job.status = 'leased' and job.lease_expires_at <= p_now) - order by job.next_attempt_at, job.id - limit page_size - for update skip locked - loop - expected_fence := ( - pg_catalog.trunc(extract(epoch from candidate.generation) * 1000)::bigint - )::text; - update public.v2_users app_user - set deletion_fence = expected_fence - where app_user.id = candidate.user_id - and app_user.deleted_at = candidate.generation - and ( - app_user.deletion_fence is null - or app_user.deletion_fence = expected_fence - ); - if not found then - delete from public.v2_user_deletion_jobs job where job.id = candidate.id; - return query select 'stale'::text, candidate.id, candidate.user_id, - candidate.continuation; - elsif candidate.status = 'leased' - and candidate.failure_count + 1 >= p_max_failures then - return query - update public.v2_user_deletion_jobs job - set continuation = job.continuation + 1, - failure_count = job.failure_count + 1, - last_error_code = 'user_deletion_lease_expired', - lease_expires_at = null, - lease_token = null, - status = 'quarantined' - where job.id = candidate.id - returning 'quarantined'::text, job.id, job.user_id, job.continuation; - else - return query - update public.v2_user_deletion_jobs job - set continuation = case when candidate.status = 'leased' - then job.continuation + 1 else job.continuation end, - failure_count = case when candidate.status = 'leased' - then job.failure_count + 1 else job.failure_count end, - last_error_code = case when candidate.status = 'leased' - then 'user_deletion_lease_expired' else job.last_error_code end, - lease_expires_at = p_now + interval '2 hours', - lease_token = p_lease_token, - next_attempt_at = case when candidate.status = 'leased' - then p_now else job.next_attempt_at end, - status = 'leased' - where job.id = candidate.id - returning 'leased'::text, job.id, job.user_id, job.continuation; - end if; - end loop; -end -$function$; - -drop function public.sync_clerk_user(text, text, text, text); - -create function public.sync_clerk_user( - p_clerk_id text, - p_email text, - p_display_name text, - p_avatar_url text, - p_clerk_updated_at_ms bigint -) -returns table ( - sync_state text, - user_id uuid, - email text, - display_name text, - avatar_url text, - polar_customer_id text, - clerk_updated_at_ms bigint, - email_changed boolean, - profile_changed boolean -) -language plpgsql security definer set search_path = '' -as $function$ -declare - has_existing boolean; - identity_hash text; - existing record; - persisted record; -begin - if p_clerk_id is null or btrim(p_clerk_id) = '' or octet_length(p_clerk_id) > 512 then - raise exception 'invalid Clerk identity'; - end if; - if p_email is null or btrim(p_email) = '' or octet_length(p_email) > 512 then - raise exception 'invalid Clerk email'; - end if; - if p_clerk_updated_at_ms is null - or p_clerk_updated_at_ms < 0 - or p_clerk_updated_at_ms > 9007199254740991 then - raise exception 'invalid Clerk source version'; - end if; - if octet_length(coalesce(p_display_name, '')) > 1024 - or octet_length(coalesce(p_avatar_url, '')) > 4096 then - raise exception 'invalid Clerk profile payload'; - end if; - - identity_hash := pg_catalog.encode( - extensions.digest(pg_catalog.convert_to(p_clerk_id, 'UTF8'), 'sha256'), - 'hex' - ); - perform pg_catalog.pg_advisory_xact_lock( - pg_catalog.hashtextextended('cheatcode:clerk-identity:' || identity_hash, 0) - ); - if exists ( - select 1 from public.v2_deleted_clerk_identities retired - where retired.clerk_identity_hash = identity_hash - ) then - return query select 'completed', null::uuid, null::text, null::text, - null::text, null::text, null::bigint, false, false; - return; - end if; - - select app_user.id, app_user.avatar_url, app_user.clerk_updated_at_ms, - app_user.deleted_at, app_user.display_name, app_user.email, - app_user.polar_customer_id - into existing - from public.v2_users app_user - where app_user.clerk_id = p_clerk_id; - has_existing := found; - if has_existing and existing.deleted_at is not null then - return query select 'in_progress', null::uuid, null::text, null::text, - null::text, null::text, null::bigint, false, false; - return; - end if; - if has_existing and existing.clerk_updated_at_ms > p_clerk_updated_at_ms then - return query select 'stale', existing.id, existing.email, existing.display_name, - existing.avatar_url, existing.polar_customer_id, existing.clerk_updated_at_ms, - false, false; - return; - end if; - if has_existing and existing.clerk_updated_at_ms = p_clerk_updated_at_ms then - return query select 'unchanged', existing.id, existing.email, existing.display_name, - existing.avatar_url, existing.polar_customer_id, existing.clerk_updated_at_ms, - false, false; - return; - end if; - - if has_existing then - update public.v2_users app_user - set email = btrim(p_email), - display_name = nullif(btrim(p_display_name), ''), - avatar_url = nullif(btrim(p_avatar_url), ''), - clerk_updated_at_ms = p_clerk_updated_at_ms - where app_user.id = existing.id - and app_user.deleted_at is null - and app_user.deletion_fence is null - and app_user.clerk_updated_at_ms < p_clerk_updated_at_ms - returning app_user.id, app_user.email, app_user.display_name, - app_user.avatar_url, app_user.polar_customer_id, - app_user.clerk_updated_at_ms - into persisted; - else - insert into public.v2_users ( - clerk_id, clerk_updated_at_ms, email, display_name, avatar_url - ) values ( - p_clerk_id, - p_clerk_updated_at_ms, - btrim(p_email), - nullif(btrim(p_display_name), ''), - nullif(btrim(p_avatar_url), '') - ) - returning id, public.v2_users.email, public.v2_users.display_name, - public.v2_users.avatar_url, public.v2_users.polar_customer_id, - public.v2_users.clerk_updated_at_ms - into persisted; - end if; - if not found then - return query select 'in_progress', null::uuid, null::text, null::text, - null::text, null::text, null::bigint, false, false; - return; - end if; - - insert into public.v2_entitlements (user_id, tier) - values (persisted.id, 'free') - on conflict on constraint v2_entitlements_pkey do nothing; - return query select - case when has_existing then 'updated' else 'created' end, - persisted.id, - persisted.email, - persisted.display_name, - persisted.avatar_url, - persisted.polar_customer_id, - persisted.clerk_updated_at_ms, - has_existing and existing.email is distinct from persisted.email, - has_existing and ( - existing.email is distinct from persisted.email - or existing.display_name is distinct from persisted.display_name - or existing.avatar_url is distinct from persisted.avatar_url - ); -end -$function$; - -alter function public.sync_clerk_user(text, text, text, text, bigint) owner to postgres; - -revoke all on function public.sync_clerk_user(text, text, text, text, bigint) -from public, app_gateway, app_agent, app_webhooks; - -grant execute on function public.sync_clerk_user(text, text, text, text, bigint) -to app_gateway, app_webhooks; diff --git a/infra/supabase/migrations/post/0067_artifact_upload_intents.sql b/infra/supabase/migrations/post/0067_artifact_upload_intents.sql deleted file mode 100644 index e7751a5b..00000000 --- a/infra/supabase/migrations/post/0067_artifact_upload_intents.sql +++ /dev/null @@ -1,181 +0,0 @@ -alter table public.v2_artifact_upload_intents owner to postgres; - -alter table public.v2_artifact_upload_intents - add constraint v2_artifact_upload_intents_project_user_fk - foreign key (project_id, user_id) - references public.v2_projects (id, user_id), - add constraint v2_artifact_upload_intents_agent_run_user_fk - foreign key (agent_run_id, user_id) - references public.v2_agent_runs (id, user_id); - -revoke all on table public.v2_artifact_upload_intents -from public, anon, authenticated, service_role, app_gateway, app_agent, app_webhooks; - -alter table public.v2_artifact_upload_intents enable row level security; -alter table public.v2_artifact_upload_intents force row level security; - -create policy v2_artifact_upload_intents_postgres_all -on public.v2_artifact_upload_intents -as permissive for all to postgres using (true) with check (true); - -create policy v2_artifact_upload_intents_select_own -on public.v2_artifact_upload_intents -as permissive for select to app_agent -using (user_id = (select public.current_app_user())); - -create policy v2_artifact_upload_intents_insert_own -on public.v2_artifact_upload_intents -as permissive for insert to app_agent -with check (user_id = (select public.current_app_user())); - -create policy v2_artifact_upload_intents_update_own -on public.v2_artifact_upload_intents -as permissive for update to app_agent -using (user_id = (select public.current_app_user())) -with check (user_id = (select public.current_app_user())); - -create policy v2_artifact_upload_intents_delete_own -on public.v2_artifact_upload_intents -as permissive for delete to app_agent -using (user_id = (select public.current_app_user())); - -create policy v2_artifact_upload_intents_select_maintenance -on public.v2_artifact_upload_intents -as permissive for select to app_webhooks using (true); - -create policy v2_artifact_upload_intents_delete_maintenance -on public.v2_artifact_upload_intents -as permissive for delete to app_webhooks using (true); - -grant delete on table public.v2_artifact_upload_intents to app_agent, app_webhooks; -grant select ( - agent_run_id, - cleanup_not_before, - id, - project_id, - quiesced_at, - r2_key, - user_id -) on table public.v2_artifact_upload_intents to app_agent, app_webhooks; -grant insert ( - agent_run_id, - cleanup_not_before, - id, - project_id, - r2_key, - user_id -) on table public.v2_artifact_upload_intents to app_agent; -grant update ( - cleanup_not_before, - quiesced_at -) on table public.v2_artifact_upload_intents to app_agent; - --- Artifact finalization compares an existing output to its originating run, --- while maintenance proves the joined run is terminal before deleting an --- abandoned object. These are the only pre-existing columns the new paths add. -grant select (agent_run_id) on table public.v2_generated_outputs to app_agent; -grant select (finished_at, status) on table public.v2_agent_runs to app_webhooks; -grant update (expires_at) on table public.v2_generated_outputs to app_agent; - -create policy v2_generated_outputs_update_own -on public.v2_generated_outputs -as permissive for update to app_agent -using (user_id = (select public.current_app_user())) -with check (user_id = (select public.current_app_user())); - -create or replace function public.webhooks_list_expired_outputs( - p_before timestamp with time zone, - p_cursor_expires_at timestamp with time zone, - p_cursor_id uuid, - p_limit integer -) -returns table (expires_at timestamp with time zone, id uuid, r2_key text) -language sql stable security definer set search_path = '' -as $function$ - select output.expires_at, output.id, output.r2_key - from public.v2_generated_outputs output - join public.v2_agent_runs terminal_run - on terminal_run.id = output.agent_run_id - and terminal_run.user_id = output.user_id - where output.expires_at <= p_before - and terminal_run.status in ('completed', 'failed', 'canceled') - and terminal_run.finished_at is not null - and ( - (p_cursor_expires_at is null and p_cursor_id is null) - or ( - p_cursor_expires_at is not null - and p_cursor_id is not null - and (output.expires_at, output.id) > (p_cursor_expires_at, p_cursor_id) - ) - ) - order by output.expires_at, output.id - limit greatest(1, least(coalesce(p_limit, 1), 500)) -$function$; - -create or replace function public.webhooks_delete_expired_outputs( - p_before timestamp with time zone, - p_outputs jsonb -) -returns integer -language plpgsql security definer set search_path = '' -as $function$ -declare - deleted_count integer; -begin - if pg_catalog.jsonb_typeof(p_outputs) <> 'array' - or pg_catalog.jsonb_array_length(p_outputs) > 500 - or pg_catalog.octet_length(p_outputs::text) > 1048576 then - raise exception 'invalid expired-output deletion batch'; - end if; - with requested as ( - select record.id, record.expires_at, record.r2_key - from pg_catalog.jsonb_to_recordset(p_outputs) - as record(id uuid, expires_at timestamp with time zone, r2_key text) - ), deleted as ( - delete from public.v2_generated_outputs output - using requested, public.v2_agent_runs terminal_run - where output.id = requested.id - and output.expires_at = requested.expires_at - and output.r2_key = requested.r2_key - and output.expires_at <= p_before - and terminal_run.id = output.agent_run_id - and terminal_run.user_id = output.user_id - and terminal_run.status in ('completed', 'failed', 'canceled') - and terminal_run.finished_at is not null - returning output.id - ) - select count(*)::integer into deleted_count from deleted; - return deleted_count; -end -$function$; - -alter function public.webhooks_list_expired_outputs( - timestamp with time zone, - timestamp with time zone, - uuid, - integer -) owner to postgres; -alter function public.webhooks_delete_expired_outputs( - timestamp with time zone, - jsonb -) owner to postgres; - -revoke all on function - public.webhooks_list_expired_outputs( - timestamp with time zone, - timestamp with time zone, - uuid, - integer - ), - public.webhooks_delete_expired_outputs(timestamp with time zone, jsonb) -from public, anon, authenticated, service_role, app_gateway, app_agent, app_webhooks; - -grant execute on function - public.webhooks_list_expired_outputs( - timestamp with time zone, - timestamp with time zone, - uuid, - integer - ), - public.webhooks_delete_expired_outputs(timestamp with time zone, jsonb) -to app_webhooks; diff --git a/infra/supabase/migrations/post/0068_user_deletion_refund_intents.sql b/infra/supabase/migrations/post/0068_user_deletion_refund_intents.sql deleted file mode 100644 index 4bdc8b3a..00000000 --- a/infra/supabase/migrations/post/0068_user_deletion_refund_intents.sql +++ /dev/null @@ -1,319 +0,0 @@ -alter table public.v2_user_deletion_refund_intents owner to postgres; - -revoke all on table public.v2_user_deletion_refund_intents -from public, anon, authenticated, service_role, app_gateway, app_agent, app_webhooks; - -alter table public.v2_user_deletion_refund_intents enable row level security; -alter table public.v2_user_deletion_refund_intents force row level security; - -create policy v2_user_deletion_refund_intents_postgres_all -on public.v2_user_deletion_refund_intents -as permissive for all to postgres using (true) with check (true); - -create policy v2_user_deletion_refund_intents_select_own -on public.v2_user_deletion_refund_intents -as permissive for select to app_webhooks -using (user_id = (select public.current_app_user())); - -grant select on table public.v2_user_deletion_refund_intents to app_webhooks; - -create or replace function public.webhooks_reserve_user_deletion_refund_intent( - p_job_id uuid, - p_generation timestamp with time zone, - p_continuation integer, - p_lease_token uuid, - p_cursor text, - p_order_id text, - p_amount integer, - p_currency text -) -returns table ( - job_id uuid, - user_id uuid, - generation timestamp with time zone, - order_id text, - amount integer, - currency text, - idempotency_key text, - provider_refund_id text, - provider_status text, - created_at timestamp with time zone, - reconciled_at timestamp with time zone -) -language plpgsql security definer set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); -begin - if actor_id is null or p_job_id is null or p_generation is null - or p_continuation is null or p_continuation < 0 - or p_lease_token is null or p_order_id is null or btrim(p_order_id) = '' - or p_amount is null or p_amount < 1 - or p_currency is null or p_currency !~ '^[a-z]{3}$' then - raise exception 'invalid user-deletion refund reservation'; - end if; - - perform 1 - from public.v2_user_deletion_jobs deletion_job - where deletion_job.id = p_job_id - and deletion_job.user_id = actor_id - and deletion_job.generation = p_generation - and deletion_job.continuation = p_continuation - and deletion_job.status = 'leased' - and deletion_job.lease_token = p_lease_token - and deletion_job.phase = 'billing' - and deletion_job.cursor is not distinct from p_cursor - for update; - if not found then - return; - end if; - - insert into public.v2_user_deletion_refund_intents ( - job_id, - user_id, - generation, - order_id, - amount, - currency, - idempotency_key - ) values ( - p_job_id, - actor_id, - p_generation, - p_order_id, - p_amount, - p_currency, - 'cheatcode:user-deletion-refund:' || p_job_id::text - ) - on conflict on constraint v2_user_deletion_refund_intents_pkey do nothing; - - return query - select intent.job_id, - intent.user_id, - intent.generation, - intent.order_id, - intent.amount, - intent.currency, - intent.idempotency_key, - intent.provider_refund_id, - intent.provider_status, - intent.created_at, - intent.reconciled_at - from public.v2_user_deletion_refund_intents intent - where intent.job_id = p_job_id - and intent.user_id = actor_id - and intent.generation = p_generation; -end -$function$; - -create or replace function public.webhooks_record_user_deletion_refund_evidence( - p_job_id uuid, - p_generation timestamp with time zone, - p_continuation integer, - p_lease_token uuid, - p_cursor text, - p_order_id text, - p_amount integer, - p_currency text, - p_idempotency_key text, - p_provider_refund_id text, - p_provider_status text -) -returns table ( - job_id uuid, - user_id uuid, - generation timestamp with time zone, - order_id text, - amount integer, - currency text, - idempotency_key text, - provider_refund_id text, - provider_status text, - created_at timestamp with time zone, - reconciled_at timestamp with time zone -) -language plpgsql security definer set search_path = '' -as $function$ -declare - actor_id uuid := public.current_app_user(); - current_intent public.v2_user_deletion_refund_intents%rowtype; -begin - if actor_id is null or p_job_id is null or p_generation is null - or p_continuation is null or p_continuation < 0 - or p_lease_token is null or p_order_id is null or btrim(p_order_id) = '' - or p_amount is null or p_amount < 1 - or p_currency is null or p_currency !~ '^[a-z]{3}$' - or p_idempotency_key is null or p_idempotency_key = '' - or p_provider_refund_id is null or btrim(p_provider_refund_id) = '' - or p_provider_status is null - or p_provider_status not in ('pending', 'succeeded', 'failed', 'canceled') then - raise exception 'invalid user-deletion refund evidence'; - end if; - - perform 1 - from public.v2_user_deletion_jobs deletion_job - where deletion_job.id = p_job_id - and deletion_job.user_id = actor_id - and deletion_job.generation = p_generation - and deletion_job.continuation = p_continuation - and deletion_job.status = 'leased' - and deletion_job.lease_token = p_lease_token - and deletion_job.phase = 'billing' - and deletion_job.cursor is not distinct from p_cursor - for update; - if not found then - return; - end if; - - select intent.* into current_intent - from public.v2_user_deletion_refund_intents intent - where intent.job_id = p_job_id - and intent.user_id = actor_id - and intent.generation = p_generation - for update; - if not found then - raise exception 'user-deletion refund intent is missing'; - end if; - - if current_intent.order_id <> p_order_id - or current_intent.amount <> p_amount - or current_intent.currency <> p_currency - or current_intent.idempotency_key <> p_idempotency_key then - raise exception 'user-deletion refund immutable identity changed'; - end if; - if current_intent.provider_refund_id is not null - and current_intent.provider_refund_id <> p_provider_refund_id then - raise exception 'user-deletion provider refund identity changed'; - end if; - if current_intent.provider_status is not null - and current_intent.provider_status <> 'pending' - and current_intent.provider_status <> p_provider_status then - raise exception 'user-deletion provider refund status regressed'; - end if; - - update public.v2_user_deletion_refund_intents intent - set provider_refund_id = p_provider_refund_id, - provider_status = p_provider_status, - reconciled_at = now() - where intent.job_id = p_job_id; - - return query - select intent.job_id, - intent.user_id, - intent.generation, - intent.order_id, - intent.amount, - intent.currency, - intent.idempotency_key, - intent.provider_refund_id, - intent.provider_status, - intent.created_at, - intent.reconciled_at - from public.v2_user_deletion_refund_intents intent - where intent.job_id = p_job_id; -end -$function$; - -alter function public.webhooks_reserve_user_deletion_refund_intent( - uuid, - timestamp with time zone, - integer, - uuid, - text, - text, - integer, - text -) owner to postgres; -alter function public.webhooks_record_user_deletion_refund_evidence( - uuid, - timestamp with time zone, - integer, - uuid, - text, - text, - integer, - text, - text, - text, - text -) owner to postgres; - -revoke all on function - public.webhooks_reserve_user_deletion_refund_intent( - uuid, - timestamp with time zone, - integer, - uuid, - text, - text, - integer, - text - ), - public.webhooks_record_user_deletion_refund_evidence( - uuid, - timestamp with time zone, - integer, - uuid, - text, - text, - integer, - text, - text, - text, - text - ) -from public, anon, authenticated, service_role, app_gateway, app_agent, app_webhooks; - -grant execute on function - public.webhooks_reserve_user_deletion_refund_intent( - uuid, - timestamp with time zone, - integer, - uuid, - text, - text, - integer, - text - ), - public.webhooks_record_user_deletion_refund_evidence( - uuid, - timestamp with time zone, - integer, - uuid, - text, - text, - integer, - text, - text, - text, - text - ) -to app_webhooks; - -create or replace function public.v2_guard_user_deletion_refund_resolution() -returns trigger -language plpgsql set search_path = '' -as $function$ -begin - if ( - tg_op = 'DELETE' - or (old.phase = 'billing' and new.phase <> 'billing') - ) and exists ( - select 1 - from public.v2_user_deletion_refund_intents refund_intent - where refund_intent.job_id = old.id - and refund_intent.provider_status is distinct from 'succeeded' - ) then - raise exception 'user-deletion job has an unresolved refund intent'; - end if; - return case when tg_op = 'DELETE' then old else new end; -end -$function$; - -alter function public.v2_guard_user_deletion_refund_resolution() owner to postgres; -revoke all on function public.v2_guard_user_deletion_refund_resolution() -from public, anon, authenticated, service_role, app_gateway, app_agent, app_webhooks; - -create trigger trg_v2_user_deletion_refund_resolution -before update of phase or delete on public.v2_user_deletion_jobs -for each row execute function public.v2_guard_user_deletion_refund_resolution(); diff --git a/infra/supabase/migrations/post/0069_finalize_new_runtime_grants.sql b/infra/supabase/migrations/post/0069_finalize_new_runtime_grants.sql deleted file mode 100644 index 326624e1..00000000 --- a/infra/supabase/migrations/post/0069_finalize_new_runtime_grants.sql +++ /dev/null @@ -1,90 +0,0 @@ --- 0059 intentionally rebuilds the worker privilege surface. These grants are the --- exact delta introduced by later expand migrations and must run after that --- contraction during a fresh bootstrap. - -grant delete on table public.v2_artifact_upload_intents to app_agent, app_webhooks; -grant select ( - agent_run_id, - cleanup_not_before, - id, - project_id, - quiesced_at, - r2_key, - user_id -) on table public.v2_artifact_upload_intents to app_agent, app_webhooks; -grant insert ( - agent_run_id, - cleanup_not_before, - id, - project_id, - r2_key, - user_id -) on table public.v2_artifact_upload_intents to app_agent; -grant update ( - cleanup_not_before, - quiesced_at -) on table public.v2_artifact_upload_intents to app_agent; - -grant select (agent_run_id) on table public.v2_generated_outputs to app_agent; -grant select (finished_at, status) on table public.v2_agent_runs to app_webhooks; -grant update (expires_at) on table public.v2_generated_outputs to app_agent; - -drop policy if exists v2_generated_outputs_update_own on public.v2_generated_outputs; -create policy v2_generated_outputs_update_own -on public.v2_generated_outputs -as permissive for update to app_agent -using (user_id = (select public.current_app_user())) -with check (user_id = (select public.current_app_user())); - -create or replace function public.v2_guard_terminal_agent_run_state() -returns trigger -language plpgsql -set search_path = '' -as $function$ -begin - if old.status in ('completed', 'failed', 'canceled') - and ( - new.status is distinct from old.status - or new.finished_at is distinct from old.finished_at - ) then - raise exception 'terminal agent-run state is immutable' - using errcode = '23514'; - end if; - return new; -end -$function$; - -alter function public.v2_guard_terminal_agent_run_state() owner to postgres; -revoke all on function public.v2_guard_terminal_agent_run_state() -from public, anon, authenticated, service_role, app_gateway, app_agent, app_webhooks; - -create trigger trg_v2_agent_runs_terminal_state -before update of finished_at, status on public.v2_agent_runs -for each row execute function public.v2_guard_terminal_agent_run_state(); - -grant select on table public.v2_user_deletion_refund_intents to app_webhooks; -grant execute on function - public.webhooks_reserve_user_deletion_refund_intent( - uuid, - timestamp with time zone, - integer, - uuid, - text, - text, - integer, - text - ), - public.webhooks_record_user_deletion_refund_evidence( - uuid, - timestamp with time zone, - integer, - uuid, - text, - text, - integer, - text, - text, - text, - text - ) -to app_webhooks; diff --git a/infra/supabase/migrations/post/0070_remove_persisted_artifact_download_urls.sql b/infra/supabase/migrations/post/0070_remove_persisted_artifact_download_urls.sql deleted file mode 100644 index 0d227eaf..00000000 --- a/infra/supabase/migrations/post/0070_remove_persisted_artifact_download_urls.sql +++ /dev/null @@ -1,79 +0,0 @@ --- Artifact download capabilities are minted on demand. Persisted message parts retain only --- durable output identity and presentation metadata. - -do $$ -declare - invalid_count bigint; -begin - select count(*) - into invalid_count - from public.v2_messages - where jsonb_typeof(parts) is distinct from 'array'; - - if invalid_count <> 0 then - raise exception - 'artifact download URL contraction refused: % message parts payloads are not arrays', - invalid_count; - end if; - - select count(*) - into invalid_count - from public.v2_messages as message - cross join lateral jsonb_array_elements(message.parts) as part(value) - where jsonb_typeof(part.value) is distinct from 'object'; - - if invalid_count <> 0 then - raise exception - 'artifact download URL contraction refused: % message parts are not objects', - invalid_count; - end if; - - select count(*) - into invalid_count - from public.v2_messages as message - cross join lateral jsonb_array_elements(message.parts) as part(value) - where part.value ->> 'type' = 'data-artifact' - and jsonb_typeof(part.value -> 'data') is distinct from 'object'; - - if invalid_count <> 0 then - raise exception - 'artifact download URL contraction refused: % artifact data payloads are not objects', - invalid_count; - end if; -end -$$; - -with contracted_messages as ( - select - message.id, - jsonb_agg( - case - when part.value ->> 'type' = 'data-artifact' - then part.value #- '{data,downloadUrl}' - else part.value - end - order by part.ordinality - ) as parts - from public.v2_messages as message - cross join lateral jsonb_array_elements(message.parts) with ordinality as part(value, ordinality) - group by message.id -) -update public.v2_messages as message - set parts = contracted.parts - from contracted_messages as contracted - where message.id = contracted.id - and message.parts is distinct from contracted.parts; - -do $$ -begin - if exists ( - select 1 - from public.v2_messages as message - cross join lateral jsonb_array_elements(message.parts) as part(value) - where part.value ->> 'type' = 'data-artifact' - and (part.value -> 'data') ? 'downloadUrl' - ) then - raise exception 'artifact download URL contraction failed: persisted URLs remain'; - end if; -end -$$; diff --git a/infra/supabase/migrations/post/0071_allow_projectless_active_runs.sql b/infra/supabase/migrations/post/0071_allow_projectless_active_runs.sql deleted file mode 100644 index 3646509a..00000000 --- a/infra/supabase/migrations/post/0071_allow_projectless_active_runs.sql +++ /dev/null @@ -1,2 +0,0 @@ -alter table public.v2_threads - drop constraint if exists v2_threads_active_run_project_check; diff --git a/infra/supabase/migrations/post/0072_remove_obsolete_run_gates.sql b/infra/supabase/migrations/post/0072_remove_obsolete_run_gates.sql deleted file mode 100644 index 73622f0a..00000000 --- a/infra/supabase/migrations/post/0072_remove_obsolete_run_gates.sql +++ /dev/null @@ -1,32 +0,0 @@ -with obsolete_runs as materialized ( - select distinct (part.value -> 'data' ->> 'runId')::uuid as run_id - from public.v2_messages message - cross join lateral jsonb_array_elements(message.parts) as part(value) - where part.value ->> 'type' in ('data-approval-request', 'data-approval-decision') - and part.value -> 'data' ->> 'runId' ~* '^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$' -), closed_runs as ( - update public.v2_agent_runs run - set status = 'canceled', - finished_at = greatest(run.started_at, now()) - from obsolete_runs obsolete - where run.id = obsolete.run_id - and run.status in ('pending', 'running', 'paused') - returning run.id -) -update public.v2_threads thread -set active_run_id = null, - updated_at = now() -from obsolete_runs obsolete -where thread.active_run_id = obsolete.run_id; - -update public.v2_messages message -set parts = ( - select coalesce(jsonb_agg(part.value order by part.ordinality), '[]'::jsonb) - from jsonb_array_elements(message.parts) with ordinality as part(value, ordinality) - where part.value ->> 'type' not in ('data-approval-request', 'data-approval-decision') -) -where exists ( - select 1 - from jsonb_array_elements(message.parts) as part(value) - where part.value ->> 'type' in ('data-approval-request', 'data-approval-decision') -); diff --git a/infra/supabase/migrations/post/0073_finalize_direct_run_statuses.sql b/infra/supabase/migrations/post/0073_finalize_direct_run_statuses.sql deleted file mode 100644 index 27145e6f..00000000 --- a/infra/supabase/migrations/post/0073_finalize_direct_run_statuses.sql +++ /dev/null @@ -1,18 +0,0 @@ -update public.v2_agent_runs -set status = 'canceled', - finished_at = greatest(started_at, coalesce(finished_at, now())) -where status not in ('pending', 'running', 'completed', 'failed', 'canceled'); - -update public.v2_threads thread -set active_run_id = null, - updated_at = now() -from public.v2_agent_runs run -where thread.active_run_id = run.id - and run.status = 'canceled'; - -alter table public.v2_agent_runs - drop constraint v2_agent_runs_status_check; - -alter table public.v2_agent_runs - add constraint v2_agent_runs_status_check - check (status in ('pending', 'running', 'completed', 'failed', 'canceled')); diff --git a/infra/supabase/migrations/post/0074_remove_product_policy_residue.sql b/infra/supabase/migrations/post/0074_remove_product_policy_residue.sql deleted file mode 100644 index d088fa3f..00000000 --- a/infra/supabase/migrations/post/0074_remove_product_policy_residue.sql +++ /dev/null @@ -1,48 +0,0 @@ --- Remove user-visible product-policy limits only after the matching Workers are live. - -update public.v2_provider_keys -set disabled_at = null, - disabled_reason = null -where disabled_reason = 'tier_slot_limit'; - -revoke update (expires_at) on table public.v2_generated_outputs from app_agent; -drop policy if exists v2_generated_outputs_update_own on public.v2_generated_outputs; - -drop function if exists public.webhooks_list_expired_outputs( - timestamp with time zone, - timestamp with time zone, - uuid, - integer -); -drop function if exists public.webhooks_delete_expired_outputs( - timestamp with time zone, - jsonb -); - -drop index if exists public.v2_generated_outputs_expiry_idx; -alter table public.v2_generated_outputs - drop constraint if exists v2_generated_outputs_expiry_check, - drop column if exists expires_at; - -alter table public.v2_projects - drop column if exists master_instructions; - -revoke update ( - output_cursor_expires_at, - output_cursor_id -) on table public.v2_retention_jobs from app_webhooks; - -alter table public.v2_retention_jobs - drop constraint if exists v2_retention_jobs_output_cursor_check, - drop constraint if exists v2_retention_jobs_phase_cursor_check, - drop column if exists output_cursor_expires_at, - drop column if exists output_cursor_id, - add constraint v2_retention_jobs_phase_cursor_check - check ( - phase = 'activation' - or ( - phase = 'cleanup' - and activation_cursor_event is null - and activation_cursor_user_id is null - ) - ); diff --git a/infra/supabase/migrations/post/0075_attribute_thread_models.sql b/infra/supabase/migrations/post/0075_attribute_thread_models.sql deleted file mode 100644 index bd8a2f2c..00000000 --- a/infra/supabase/migrations/post/0075_attribute_thread_models.sql +++ /dev/null @@ -1,17 +0,0 @@ --- Expose resolved model attribution without widening gateway access to run rows. -grant update (latest_model_id) on table public.v2_threads to app_gateway, app_agent; - -with latest_runs as ( - select distinct on (run.thread_id, run.user_id) - run.thread_id, - run.user_id, - run.model_id - from public.v2_agent_runs as run - order by run.thread_id, run.user_id, run.started_at desc, run.id desc -) -update public.v2_threads as thread -set latest_model_id = latest_run.model_id -from latest_runs as latest_run -where thread.id = latest_run.thread_id - and thread.user_id = latest_run.user_id - and thread.latest_model_id is distinct from latest_run.model_id; diff --git a/infra/supabase/migrations/post/0076_remove_skill_proposals.sql b/infra/supabase/migrations/post/0076_remove_skill_proposals.sql deleted file mode 100644 index 1ebd4337..00000000 --- a/infra/supabase/migrations/post/0076_remove_skill_proposals.sql +++ /dev/null @@ -1,11 +0,0 @@ -update public.v2_messages as message -set parts = ( - select coalesce(jsonb_agg(part.value order by part.ordinality), '[]'::jsonb) - from jsonb_array_elements(message.parts) with ordinality as part(value, ordinality) - where part.value ->> 'type' <> 'data-skill-proposed' -) -where exists ( - select 1 - from jsonb_array_elements(message.parts) as part(value) - where part.value ->> 'type' = 'data-skill-proposed' -); diff --git a/infra/supabase/migrations/post/0077_restore_thread_model_runtime_grants.sql b/infra/supabase/migrations/post/0077_restore_thread_model_runtime_grants.sql deleted file mode 100644 index b674e4f9..00000000 --- a/infra/supabase/migrations/post/0077_restore_thread_model_runtime_grants.sql +++ /dev/null @@ -1,4 +0,0 @@ --- 0069 rebuilds the runtime privilege surface after earlier expansions. Model --- attribution arrived later, so restore only the two V2 update grants its --- writers require after that rebuild. -grant update (latest_model_id) on table public.v2_threads to app_gateway, app_agent; diff --git a/infra/supabase/migrations/post/0078_remove_v1_vector_search_functions.sql b/infra/supabase/migrations/post/0078_remove_v1_vector_search_functions.sql deleted file mode 100644 index df214531..00000000 --- a/infra/supabase/migrations/post/0078_remove_v1_vector_search_functions.sql +++ /dev/null @@ -1,14 +0,0 @@ --- The protected V1 cleanup resolved visible vector arguments as `vector`, not --- `public.vector`, and therefore left these two exact legacy functions behind. --- Drop only the audited V1 signatures; RESTRICT preserves the cleanup boundary. -drop function if exists public.match_components( - public.vector, - double precision, - integer -) restrict; - -drop function if exists public.match_mobile_components( - public.vector, - double precision, - integer -) restrict; diff --git a/infra/supabase/migrations/post/0079_remove_extensions_vector_v1_functions.sql b/infra/supabase/migrations/post/0079_remove_extensions_vector_v1_functions.sql deleted file mode 100644 index bc8dbd0b..00000000 --- a/infra/supabase/migrations/post/0079_remove_extensions_vector_v1_functions.sql +++ /dev/null @@ -1,13 +0,0 @@ --- Production installs pgvector in `extensions`, so remove the two remaining --- V1 search functions against their actual argument type identities. -drop function if exists public.match_components( - extensions.vector, - double precision, - integer -) restrict; - -drop function if exists public.match_mobile_components( - extensions.vector, - double precision, - integer -) restrict; diff --git a/infra/supabase/migrations/post/0080_rename_daily_maintenance_jobs.sql b/infra/supabase/migrations/post/0080_rename_daily_maintenance_jobs.sql deleted file mode 100644 index 80c21a0f..00000000 --- a/infra/supabase/migrations/post/0080_rename_daily_maintenance_jobs.sql +++ /dev/null @@ -1,82 +0,0 @@ --- Rename the durable daily job aggregate without replacing the table or losing queued work. - -do $$ -begin - if exists ( - select 1 - from public.v2_retention_jobs - where status = 'leased' - ) then - raise exception 'daily maintenance migration requires every active lease to drain first'; - end if; -end; -$$; - -alter table public.v2_retention_jobs - rename to v2_daily_maintenance_jobs; - -alter table public.v2_daily_maintenance_jobs - drop constraint v2_retention_jobs_phase_check, - drop constraint v2_retention_jobs_phase_cursor_check, - drop constraint v2_retention_jobs_terminal_phase_check; - -update public.v2_daily_maintenance_jobs -set phase = 'orphan-upload-cleanup' -where phase = 'cleanup'; - -alter table public.v2_daily_maintenance_jobs - rename constraint v2_retention_jobs_pkey to v2_daily_maintenance_jobs_pkey; -alter table public.v2_daily_maintenance_jobs - rename constraint v2_retention_jobs_day_check to v2_daily_maintenance_jobs_day_check; -alter table public.v2_daily_maintenance_jobs - rename constraint v2_retention_jobs_status_check to v2_daily_maintenance_jobs_status_check; -alter table public.v2_daily_maintenance_jobs - rename constraint v2_retention_jobs_counter_check to v2_daily_maintenance_jobs_counter_check; -alter table public.v2_daily_maintenance_jobs - rename constraint v2_retention_jobs_error_code_check to v2_daily_maintenance_jobs_error_code_check; -alter table public.v2_daily_maintenance_jobs - rename constraint v2_retention_jobs_activation_cursor_check - to v2_daily_maintenance_jobs_activation_cursor_check; -alter table public.v2_daily_maintenance_jobs - rename constraint v2_retention_jobs_lease_check to v2_daily_maintenance_jobs_lease_check; - -alter index public.v2_retention_jobs_ready_idx - rename to v2_daily_maintenance_jobs_ready_idx; -alter index public.v2_retention_jobs_lease_idx - rename to v2_daily_maintenance_jobs_lease_idx; -alter index public.v2_retention_jobs_completed_idx - rename to v2_daily_maintenance_jobs_completed_idx; - -alter table public.v2_daily_maintenance_jobs - add constraint v2_daily_maintenance_jobs_phase_check - check (phase in ('activation', 'orphan-upload-cleanup')), - add constraint v2_daily_maintenance_jobs_phase_cursor_check - check ( - phase = 'activation' - or ( - phase = 'orphan-upload-cleanup' - and activation_cursor_event is null - and activation_cursor_user_id is null - ) - ), - add constraint v2_daily_maintenance_jobs_terminal_phase_check - check (status <> 'complete' or phase = 'orphan-upload-cleanup'); - -alter policy v2_retention_jobs_postgres_all - on public.v2_daily_maintenance_jobs - rename to v2_daily_maintenance_jobs_postgres_all; -alter policy v2_retention_jobs_select_maintenance - on public.v2_daily_maintenance_jobs - rename to v2_daily_maintenance_jobs_select_maintenance; -alter policy v2_retention_jobs_insert_maintenance - on public.v2_daily_maintenance_jobs - rename to v2_daily_maintenance_jobs_insert_maintenance; -alter policy v2_retention_jobs_update_maintenance - on public.v2_daily_maintenance_jobs - rename to v2_daily_maintenance_jobs_update_maintenance; -alter policy v2_retention_jobs_delete_maintenance - on public.v2_daily_maintenance_jobs - rename to v2_daily_maintenance_jobs_delete_maintenance; - -comment on table public.v2_daily_maintenance_jobs is - 'Durable daily activation-metric and orphan-upload-cleanup workflow state.'; diff --git a/infra/supabase/migrations/pre/0001_extensions.sql b/infra/supabase/migrations/pre/0001_extensions.sql deleted file mode 100644 index e6a8611d..00000000 --- a/infra/supabase/migrations/pre/0001_extensions.sql +++ /dev/null @@ -1,17 +0,0 @@ -create schema if not exists extensions; - -create extension if not exists pgcrypto with schema extensions; -create extension if not exists pg_trgm with schema extensions; -create extension if not exists supabase_vault with schema extensions; -create extension if not exists moddatetime with schema extensions; - -do $$ -begin - if not exists (select 1 from pg_roles where rolname = 'app_worker') then - create role app_worker login password 'app_worker' nobypassrls; - end if; -end $$; - -grant usage on schema public, extensions to app_worker; - -alter default privileges in schema public revoke execute on functions from public; diff --git a/infra/supabase/migrations/pre/0002_uuidv7_compat.sql b/infra/supabase/migrations/pre/0002_uuidv7_compat.sql deleted file mode 100644 index f3414b54..00000000 --- a/infra/supabase/migrations/pre/0002_uuidv7_compat.sql +++ /dev/null @@ -1,47 +0,0 @@ -do $$ -begin - if to_regprocedure('pg_catalog.uuidv7()') is null - and to_regprocedure('public.uuidv7()') is null - then - execute $create$ - create function public.uuidv7() - returns uuid - language sql - volatile - security definer - set search_path = '' - as $function$ - with - timestamp_bytes as ( - select substring( - int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) - from 3 - for 6 - ) as value - ), - random_bytes as ( - select extensions.gen_random_bytes(10) as value - ), - uuid_bytes as ( - select - timestamp_bytes.value - || set_byte( - substring(random_bytes.value from 1 for 2), - 0, - (get_byte(random_bytes.value, 0) & 15) | 112 - ) - || set_byte( - substring(random_bytes.value from 3 for 8), - 0, - (get_byte(random_bytes.value, 2) & 63) | 128 - ) as value - from timestamp_bytes, random_bytes - ) - select encode(uuid_bytes.value, 'hex')::uuid - from uuid_bytes; - $function$; - $create$; - grant execute on function public.uuidv7() to app_worker; - end if; -end -$$; diff --git a/infra/supabase/migrations/pre/0003_audit_log_partitioned.sql b/infra/supabase/migrations/pre/0003_audit_log_partitioned.sql deleted file mode 100644 index 1c43d362..00000000 --- a/infra/supabase/migrations/pre/0003_audit_log_partitioned.sql +++ /dev/null @@ -1,33 +0,0 @@ -create table if not exists v2_audit_log ( - id uuid not null default public.uuidv7(), - user_id uuid, - action text not null, - resource_type text, - resource_id text, - metadata jsonb not null default '{}'::jsonb, - ip_address inet, - user_agent text, - created_at timestamptz not null default now(), - primary key (id, created_at) -) partition by range (created_at); - -do $$ -declare - partition_start date; - partition_end date; - partition_name text; -begin - for month_offset in -1..24 loop - partition_start := (date_trunc('month', now())::date + (month_offset || ' months')::interval)::date; - partition_end := (partition_start + interval '1 month')::date; - partition_name := 'v2_audit_log_' || to_char(partition_start, 'YYYY_MM'); - - execute format( - 'create table if not exists public.%I partition of public.v2_audit_log for values from (%L) to (%L)', - partition_name, - partition_start::timestamptz, - partition_end::timestamptz - ); - end loop; -end -$$; diff --git a/infra/supabase/migrations/pre/0004_uuidv7_extensions_schema.sql b/infra/supabase/migrations/pre/0004_uuidv7_extensions_schema.sql deleted file mode 100644 index 5737eaa7..00000000 --- a/infra/supabase/migrations/pre/0004_uuidv7_extensions_schema.sql +++ /dev/null @@ -1,38 +0,0 @@ -create or replace function public.uuidv7() -returns uuid -language sql -volatile -security definer -set search_path = '' -as $function$ - with - timestamp_bytes as ( - select substring( - int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) - from 3 - for 6 - ) as value - ), - random_bytes as ( - select extensions.gen_random_bytes(10) as value - ), - uuid_bytes as ( - select - timestamp_bytes.value - || set_byte( - substring(random_bytes.value from 1 for 2), - 0, - (get_byte(random_bytes.value, 0) & 15) | 112 - ) - || set_byte( - substring(random_bytes.value from 3 for 8), - 0, - (get_byte(random_bytes.value, 2) & 63) | 128 - ) as value - from timestamp_bytes, random_bytes - ) - select encode(uuid_bytes.value, 'hex')::uuid - from uuid_bytes; -$function$; - -grant execute on function public.uuidv7() to app_worker; diff --git a/infra/supabase/migrations/pre/0005_extensions_schema_grants.sql b/infra/supabase/migrations/pre/0005_extensions_schema_grants.sql deleted file mode 100644 index 4cc3770d..00000000 --- a/infra/supabase/migrations/pre/0005_extensions_schema_grants.sql +++ /dev/null @@ -1 +0,0 @@ -grant usage on schema extensions to app_worker; diff --git a/infra/supabase/migrations/pre/0007_worker_database_roles.sql b/infra/supabase/migrations/pre/0007_worker_database_roles.sql deleted file mode 100644 index 565308c9..00000000 --- a/infra/supabase/migrations/pre/0007_worker_database_roles.sql +++ /dev/null @@ -1,348 +0,0 @@ -do $roles$ -begin - if not exists (select 1 from pg_roles where rolname = 'app_gateway') then - create role app_gateway - login noinherit nocreatedb nocreaterole; - end if; - if not exists (select 1 from pg_roles where rolname = 'app_agent') then - create role app_agent - login noinherit nocreatedb nocreaterole; - end if; - if not exists (select 1 from pg_roles where rolname = 'app_webhooks') then - create role app_webhooks - login noinherit nocreatedb nocreaterole; - end if; -end -$roles$; - -alter role app_gateway - with login noinherit nocreatedb nocreaterole; -alter role app_agent - with login noinherit nocreatedb nocreaterole; -alter role app_webhooks - with login noinherit nocreatedb nocreaterole; - --- Supabase's migration administrator is deliberately not a superuser. PostgreSQL --- rejects ALTER ROLE for these attributes even when setting their negative --- forms, so validate the CREATE ROLE defaults/manual provisioning instead. -do $restricted_attributes$ -begin - if exists ( - select 1 - from pg_roles - where rolname in ('app_gateway', 'app_agent', 'app_webhooks') - and (rolsuper or rolreplication or rolbypassrls) - ) then - raise exception 'worker runtime roles must not be superuser, replication, or bypassrls roles'; - end if; -end -$restricted_attributes$; - --- A runtime role must never gain a second identity through role membership. -do $memberships$ -declare - membership record; -begin - for membership in - select granted.rolname as granted_role, member.rolname as member_role - from pg_auth_members relation - join pg_roles granted on granted.oid = relation.roleid - join pg_roles member on member.oid = relation.member - where granted.rolname in ('app_gateway', 'app_agent', 'app_webhooks') - or member.rolname in ('app_gateway', 'app_agent', 'app_webhooks') - loop - execute format('revoke %I from %I', membership.granted_role, membership.member_role); - end loop; -end -$memberships$; - --- The foundation runs before Drizzle on a clean database, so the pre-deploy --- expansion invokes this helper only after the complete V2 schema exists. The --- post-deploy finalizer uses reset mode and then removes the helper. -create or replace function public._configure_v2_worker_role_access( - p_reset_access boolean, - p_include_legacy boolean -) -returns void -language plpgsql -set search_path = '' -as $function$ -declare - expected_relation text; - provider_policy_roles text; - tombstone_select_roles text; -begin - if pg_catalog.to_regclass('public.v2_users') is null then - return; - end if; - - foreach expected_relation in array array[ - 'v2_agent_runs', - 'v2_audit_log', - 'v2_deleted_clerk_identities', - 'v2_entitlements', - 'v2_generated_outputs', - 'v2_messages', - 'v2_projects', - 'v2_provider_keys', - 'v2_resource_deletion_jobs', - 'v2_threads', - 'v2_user_integrations', - 'v2_user_profiles', - 'v2_user_skills', - 'v2_users' - ] - loop - if pg_catalog.to_regclass(pg_catalog.format('public.%I', expected_relation)) is null then - raise exception 'worker role cutover requires public.%', expected_relation; - end if; - end loop; - - if p_reset_access then - execute pg_catalog.format( - 'revoke all privileges on database %I from app_gateway, app_agent, app_webhooks', - pg_catalog.current_database() - ); - revoke all on schema public, extensions, vault - from app_gateway, app_agent, app_webhooks; - revoke all privileges on all tables in schema public - from app_gateway, app_agent, app_webhooks; - revoke all privileges on all sequences in schema public - from app_gateway, app_agent, app_webhooks; - revoke all privileges on all functions in schema public - from app_gateway, app_agent, app_webhooks; - end if; - - execute pg_catalog.format( - 'grant connect on database %I to app_gateway, app_agent, app_webhooks', - pg_catalog.current_database() - ); - grant usage on schema public to app_gateway, app_agent, app_webhooks; - - if not p_include_legacy then - execute pg_catalog.format( - 'revoke all privileges on database %I from app_worker', - pg_catalog.current_database() - ); - revoke all on schema public, extensions, vault from app_worker; - revoke all privileges on all tables in schema public from app_worker; - revoke all privileges on all sequences in schema public from app_worker; - revoke all privileges on all functions in schema public from app_worker; - end if; - - -- Gateway: public API reads and user-initiated mutations. Project deletion is - -- soft-only here; the external-resource workflow owns the hard delete. - grant select on table - public.v2_deleted_clerk_identities, - public.v2_entitlements, - public.v2_messages, - public.v2_projects, - public.v2_threads, - public.v2_user_integrations, - public.v2_user_profiles, - public.v2_user_skills - to app_gateway; - grant select (avatar_url, clerk_id, deleted_at, deletion_fence, display_name, email, id, polar_customer_id) - on table public.v2_users to app_gateway; - grant select (finished_at, id, started_at, status, user_id) - on table public.v2_agent_runs to app_gateway; - grant select (created_at, disabled_at, disabled_reason, provider, user_id) - on table public.v2_provider_keys to app_gateway; - grant insert on table - public.v2_entitlements, - public.v2_projects, - public.v2_threads, - public.v2_user_integrations, - public.v2_user_profiles, - public.v2_user_skills, - public.v2_users - to app_gateway; - grant update (avatar_url, deleted_at, deletion_fence, display_name, email, polar_customer_id) - on table public.v2_users to app_gateway; - grant update ( - cancel_at_period_end, - current_period_end, - current_period_start, - polar_subscription_id, - subscription_status, - updated_at - ) on table public.v2_entitlements to app_gateway; - grant update (deleted_at, master_instructions, name, settings, updated_at) - on table public.v2_projects to app_gateway; - grant update (deleted_at, title, updated_at) - on table public.v2_threads to app_gateway; - grant update (disabled_at, disabled_reason) - on table public.v2_provider_keys to app_gateway; - grant update (is_default, status) - on table public.v2_user_integrations to app_gateway; - grant update ( - agent_display_name, - disabled_models, - global_memory, - onboarding_completed_at, - onboarding_state - ) on table public.v2_user_profiles to app_gateway; - grant update (body, category, description, tags, updated_at) - on table public.v2_user_skills to app_gateway; - -- Integration rows are the one gateway-owned external finalization: the - -- route deletes them only after Composio confirms the disconnect. Skills - -- have no external payload. - grant delete on table public.v2_user_integrations, public.v2_user_skills - to app_gateway; - - -- Agent: run execution and artifact persistence. It cannot delete any - -- externally owned resource or mutate billing/integration ownership. - grant select on table - public.v2_messages, - public.v2_projects, - public.v2_threads, - public.v2_user_skills - to app_agent; - grant select (deleted_at, deletion_fence, first_artifact_at, id) - on table public.v2_users to app_agent; - grant select (current_period_end, current_period_start, subscription_status, tier, updated_at, user_id) - on table public.v2_entitlements to app_agent; - grant select (id, idempotency_key_hash, model_id, request_body_hash, status, thread_id, user_id) - on table public.v2_agent_runs to app_agent; - grant select (expires_at, filename, id, mime_type, r2_key, user_id) - on table public.v2_generated_outputs to app_agent; - grant select (agent_display_name, disabled_models, global_memory, user_id) - on table public.v2_user_profiles to app_agent; - grant select (composio_connection_id, integration, is_default, status, updated_at, user_id) - on table public.v2_user_integrations to app_agent; - grant insert on table - public.v2_agent_runs, - public.v2_generated_outputs, - public.v2_messages, - public.v2_projects, - public.v2_user_skills - to app_agent; - grant update (first_artifact_at) on table public.v2_users to app_agent; - grant update (active_run_id, launch_intent, project_id, updated_at) - on table public.v2_threads to app_agent; - grant update (finished_at, model_id, status) - on table public.v2_agent_runs to app_agent; - grant update (body, category, description, tags, updated_at) - on table public.v2_user_skills to app_agent; - - -- Webhooks: provider callbacks and the bounded external-resource finalizers. - -- Direct project/thread/output deletes exist only here, after their workflow - -- has removed the corresponding Daytona/R2/DO resources. - grant select on table - public.v2_deleted_clerk_identities, - public.v2_entitlements, - public.v2_resource_deletion_jobs - to app_webhooks; - grant select (avatar_url, clerk_id, created_at, deleted_at, deletion_fence, display_name, email, id, polar_customer_id) - on table public.v2_users to app_webhooks; - grant select (id, started_at, thread_id, user_id) - on table public.v2_agent_runs to app_webhooks; - grant select (agent_run_id, expires_at, id, r2_key, user_id) - on table public.v2_generated_outputs to app_webhooks; - grant select (archive_after, created_at, deleted_at, id, name, over_quota, updated_at, user_id, workspace_slug) - on table public.v2_projects to app_webhooks; - grant select (active_run_id, deleted_at, id, project_id, user_id) - on table public.v2_threads to app_webhooks; - grant select (created_at, disabled_at, disabled_reason, fingerprint, provider, revalidation_claimed_at, revalidation_lease_token, user_id) - on table public.v2_provider_keys to app_webhooks; - grant select (composio_connection_id, integration, is_default, status, updated_at, user_id) - on table public.v2_user_integrations to app_webhooks; - grant insert on table - public.v2_deleted_clerk_identities, - public.v2_entitlements, - public.v2_resource_deletion_jobs, - public.v2_users - to app_webhooks; - grant update (avatar_url, deleted_at, deletion_fence, display_name, email, polar_customer_id) - on table public.v2_users to app_webhooks; - grant update ( - cancel_at_period_end, - current_period_end, - current_period_start, - polar_subscription_id, - subscription_status, - tier, - updated_at - ) on table public.v2_entitlements to app_webhooks; - grant update (archive_after, deleted_at, over_quota, updated_at, workspace_slug) - on table public.v2_projects to app_webhooks; - grant update (active_run_id, deleted_at, updated_at) - on table public.v2_threads to app_webhooks; - grant update ( - disabled_at, - disabled_reason, - last_revalidated_at, - revalidation_claimed_at, - revalidation_lease_token - ) on table public.v2_provider_keys to app_webhooks; - grant update (is_default, status) - on table public.v2_user_integrations to app_webhooks; - grant update ( - continuation, - cursor, - failure_count, - last_error_code, - lease_expires_at, - lease_token, - next_attempt_at, - phase, - status - ) on table public.v2_resource_deletion_jobs to app_webhooks; - grant delete on table - public.v2_generated_outputs, - public.v2_projects, - public.v2_resource_deletion_jobs, - public.v2_threads, - public.v2_users - to app_webhooks; - - grant execute on function - public.delete_provider_key(text), - public.set_provider_key(text, text), - public.uuidv7() - to app_gateway; - grant execute on function public.get_provider_key(text), public.uuidv7() - to app_agent; - grant execute on function - public.claim_provider_key_revalidation_targets(integer), - public.current_app_user(), - public.delete_all_provider_keys(), - public.get_provider_key(text), - public.scrub_current_user_audit(), - public.uuidv7() - to app_webhooks; - - provider_policy_roles := case - when p_include_legacy then 'app_worker, app_gateway, app_webhooks' - else 'app_gateway, app_webhooks' - end; - tombstone_select_roles := provider_policy_roles; - - drop policy if exists v2_provider_keys_select_own on public.v2_provider_keys; - drop policy if exists v2_provider_keys_update_own on public.v2_provider_keys; - execute pg_catalog.format( - 'create policy v2_provider_keys_select_own on public.v2_provider_keys for select to %s using (user_id::text = (select current_setting(''app.user_id'', true)))', - provider_policy_roles - ); - execute pg_catalog.format( - 'create policy v2_provider_keys_update_own on public.v2_provider_keys for update to %s using (user_id::text = (select current_setting(''app.user_id'', true))) with check (user_id::text = (select current_setting(''app.user_id'', true)))', - provider_policy_roles - ); - - drop policy if exists v2_deleted_clerk_identities_select - on public.v2_deleted_clerk_identities; - drop policy if exists v2_deleted_clerk_identities_insert - on public.v2_deleted_clerk_identities; - execute pg_catalog.format( - 'create policy v2_deleted_clerk_identities_select on public.v2_deleted_clerk_identities for select to %s using (true)', - tombstone_select_roles - ); - execute pg_catalog.format( - 'create policy v2_deleted_clerk_identities_insert on public.v2_deleted_clerk_identities for insert to %s with check (clerk_identity_hash ~ ''^[0-9a-f]{64}$'')', - case when p_include_legacy then 'app_worker, app_webhooks' else 'app_webhooks' end - ); -end -$function$; - -revoke all on function public._configure_v2_worker_role_access(boolean, boolean) - from public, app_worker, app_gateway, app_agent, app_webhooks; diff --git a/infra/supabase/migrations/raw-phases.json b/infra/supabase/migrations/raw-phases.json deleted file mode 100644 index 535b0cb3..00000000 --- a/infra/supabase/migrations/raw-phases.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "infra/supabase/migrations/post/0010_indexes.sql": "pre-deploy", - "infra/supabase/migrations/post/0011_triggers.sql": "pre-deploy", - "infra/supabase/migrations/post/0012_rls.sql": "pre-deploy", - "infra/supabase/migrations/post/0013_byok.sql": "pre-deploy", - "infra/supabase/migrations/post/0014_v2_grants.sql": "pre-deploy", - "infra/supabase/migrations/post/0015_v2_advisor_fixes.sql": "pre-deploy", - "infra/supabase/migrations/post/0016_v2_vault_grants.sql": "pre-deploy", - "infra/supabase/migrations/post/0017_v2_billing_triggers.sql": "pre-deploy", - "infra/supabase/migrations/post/0018_v2_byok_vault_cleanup.sql": "pre-deploy", - "infra/supabase/migrations/post/0019_v2_entitlement_cancel_state.sql": "pre-deploy", - "infra/supabase/migrations/post/0020_v2_downgrade_resource_state.sql": "pre-deploy", - "infra/supabase/migrations/post/0021_v2_user_profile_sync.sql": "pre-deploy", - "infra/supabase/migrations/post/0022_v2_byok_revalidation_inventory.sql": "pre-deploy", - "infra/supabase/migrations/post/0023_v2_user_profiles.sql": "pre-deploy", - "infra/supabase/migrations/post/0024_v2_billing_tier_and_usage.sql": "pre-deploy", - "infra/supabase/migrations/post/0027_v2_user_skills_grants.sql": "pre-deploy", - "infra/supabase/migrations/post/0028_v2_security_integrity.sql": "pre-deploy", - "infra/supabase/migrations/post/0029_remove_token_cost_accounting.sql": "post-deploy", - "infra/supabase/migrations/post/0030_remove_obsolete_entitlement_scaffolding.sql": "post-deploy", - "infra/supabase/migrations/post/0031_enforce_composio_connection_identity.sql": "pre-deploy", - "infra/supabase/migrations/post/0032_finalize_composio_connection_identity.sql": "post-deploy", - "infra/supabase/migrations/post/0033_clerk_deletion_tombstone_access.sql": "pre-deploy", - "infra/supabase/migrations/post/0034_remove_superseded_thread_index.sql": "post-deploy", - "infra/supabase/migrations/post/0035_finalize_security_integrity.sql": "post-deploy", - "infra/supabase/migrations/post/0036_remove_project_backup_scaffolding.sql": "post-deploy", - "infra/supabase/migrations/post/0037_backfill_first_artifact_milestone.sql": "pre-deploy", - "infra/supabase/migrations/post/0038_remove_first_artifact_bridge.sql": "post-deploy", - "infra/supabase/migrations/post/0039_remove_retired_automations.sql": "post-deploy", - "infra/supabase/migrations/post/0040_remove_dead_persisted_fields.sql": "post-deploy", - "infra/supabase/migrations/post/0041_finalize_agent_run_model_attribution.sql": "post-deploy", - "infra/supabase/migrations/post/0042_harden_byok_and_data_api_boundary.sql": "pre-deploy", - "infra/supabase/migrations/post/0043_finalize_provider_keys_and_audit.sql": "post-deploy", - "infra/supabase/migrations/post/0044_finalize_generated_output_ownership.sql": "post-deploy", - "infra/supabase/migrations/post/0045_remove_unused_v2_state.sql": "post-deploy", - "infra/supabase/migrations/post/0046_remove_v1_database_surface.sql": "release-finalization", - "infra/supabase/migrations/post/0047_remove_mastra_persistence.sql": "post-deploy", - "infra/supabase/migrations/post/0048_remove_unused_extensions.sql": "post-deploy", - "infra/supabase/migrations/post/0050_finalize_canonical_project_workspaces.sql": "post-deploy", - "infra/supabase/migrations/post/0051_resource_deletion_jobs.sql": "pre-deploy", - "infra/supabase/migrations/post/0052_remove_relational_residue.sql": "post-deploy", - "infra/supabase/migrations/post/0053_finalize_assistant_transcript_segments.sql": "post-deploy", - "infra/supabase/migrations/post/0054_finalize_provider_key_revalidation_lease.sql": "post-deploy", - "infra/supabase/migrations/post/0055_finalize_message_roles.sql": "post-deploy", - "infra/supabase/migrations/post/0056_remove_unused_llamaparse_provider.sql": "post-deploy", - "infra/supabase/migrations/post/0057_enforce_permanent_v2_integrity.sql": "post-deploy", - "infra/supabase/migrations/post/0058_expand_worker_database_roles.sql": "pre-deploy", - "infra/supabase/migrations/post/0059_finalize_worker_database_roles.sql": "post-deploy", - "infra/supabase/migrations/post/0060_expand_signed_tenant_boundary.sql": "pre-deploy", - "infra/supabase/migrations/post/0061_enforce_signed_tenant_boundary.sql": "post-deploy", - "infra/supabase/migrations/post/0062_user_deletion_jobs.sql": "pre-deploy", - "infra/supabase/migrations/post/0063_remove_legacy_user_deletion_admission.sql": "post-deploy", - "infra/supabase/migrations/post/0064_retention_jobs.sql": "post-deploy", - "infra/supabase/migrations/post/0065_enforce_terminal_clerk_deletion.sql": "post-deploy", - "infra/supabase/migrations/post/0066_enforce_monotonic_clerk_identity_sync.sql": "post-deploy", - "infra/supabase/migrations/post/0067_artifact_upload_intents.sql": "pre-deploy", - "infra/supabase/migrations/post/0068_user_deletion_refund_intents.sql": "pre-deploy", - "infra/supabase/migrations/post/0069_finalize_new_runtime_grants.sql": "post-deploy", - "infra/supabase/migrations/post/0070_remove_persisted_artifact_download_urls.sql": "pre-deploy", - "infra/supabase/migrations/post/0071_allow_projectless_active_runs.sql": "post-deploy", - "infra/supabase/migrations/post/0072_remove_obsolete_run_gates.sql": "pre-deploy", - "infra/supabase/migrations/post/0073_finalize_direct_run_statuses.sql": "post-deploy", - "infra/supabase/migrations/post/0074_remove_product_policy_residue.sql": "post-deploy", - "infra/supabase/migrations/post/0075_attribute_thread_models.sql": "pre-deploy", - "infra/supabase/migrations/post/0076_remove_skill_proposals.sql": "pre-deploy", - "infra/supabase/migrations/post/0077_restore_thread_model_runtime_grants.sql": "pre-deploy", - "infra/supabase/migrations/post/0078_remove_v1_vector_search_functions.sql": "post-deploy", - "infra/supabase/migrations/post/0079_remove_extensions_vector_v1_functions.sql": "post-deploy", - "infra/supabase/migrations/post/0080_rename_daily_maintenance_jobs.sql": "post-deploy" -} diff --git a/infra/supabase/migrations/retired-raw.json b/infra/supabase/migrations/retired-raw.json deleted file mode 100644 index 5fb83fbf..00000000 --- a/infra/supabase/migrations/retired-raw.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "infra/supabase/migrations/pre/0006_worker_database_roles.sql": "d02bec64d1134ffa179e43cb8cdc8239408a22476f60a937b8b29eda3bbfe2a3", - "infra/supabase/migrations/post/0025_v2_automations_grants.sql": "103de0c5c6f8ff46b9d2fdb64c7df686cca9685ceea5978ed2734b7b382edede", - "infra/supabase/migrations/post/0026_v2_replay_shares_grants.sql": "6074acf0f79499d4693fa05f248c98d5deebcd5ef13c0228741c09af74ac12f4", - "infra/supabase/migrations/post/0049_stage_qa_project_deletions.sql": "1ad266c442e7d7bc807be8bb380f78bf47b2ea57d024cf755cc4a7dbd533080e" -} diff --git a/knip.jsonc b/knip.jsonc index b1ccb755..0bb93392 100644 --- a/knip.jsonc +++ b/knip.jsonc @@ -17,16 +17,16 @@ "entry": ["drizzle.config.ts", "src/schema/drizzle.ts"] }, "infra/containers/sandbox/browser-driver": { - // The snapshot launches this service from start-browser-driver.sh. + // The snapshot launches this service from the immutable browser-driver + // launcher. Playwright and Zod are Stagehand peers, and the Docker build + // invokes Playwright's CLI to install the matching Chromium artifact. "entry": ["server.js"], - // Stagehand resolves these peer packages dynamically inside the snapshot, - // so a clean root-only CI install exposes no source-level import to Knip. "ignoreDependencies": ["playwright-core", "zod"] }, "infra/containers/sandbox/skill-runtime": { "entry": ["bin/*.mjs"], // Snapshot launchers resolve these executables by installed binary name; - // a root-only install cannot expose those child-process edges to Knip. + // neither child-process execution nor Docker symlinks are visible to Knip. "ignoreDependencies": ["agent-browser", "tsx"], "ignoreBinaries": ["agent-browser"] } diff --git a/packages/auth/src/internal-maintenance.ts b/packages/auth/src/internal-maintenance.ts index a6ebf533..802f1300 100644 --- a/packages/auth/src/internal-maintenance.ts +++ b/packages/auth/src/internal-maintenance.ts @@ -13,7 +13,6 @@ const MAX_INTERNAL_MAINTENANCE_PATHNAME_CHARACTERS = 2_048; const INTERNAL_MAINTENANCE_CAPABILITIES = [ "agent-lifecycle", "database-readiness", - "durable-object-schema", "resource-deletion", "webhook-replay", ] as const; diff --git a/packages/db/README.md b/packages/db/README.md index 96e585e0..f915af6f 100644 --- a/packages/db/README.md +++ b/packages/db/README.md @@ -1,430 +1,140 @@ # @cheatcode/db -Drizzle schema, queries, and Hyperdrive-aware Postgres client for Cheatcode V2. +Drizzle schema, tenant-scoped queries, and the Hyperdrive-aware Postgres client +for Cheatcode. -## Public exports +## Ownership + +Postgres stores product metadata and durable workflow state. User files remain +in Daytona workspaces, generated artifacts remain in R2, provider secrets remain +in Supabase Vault, and live stream state remains in Durable Objects. + +Every runtime Worker uses its own least-privilege login: + +- `app_gateway` owns authenticated product reads and writes. +- `app_agent` owns run, artifact, skill, and sandbox-related persistence. +- `app_webhooks` owns provider reconciliation and lifecycle jobs. + +Runtime transactions enter a signed tenant context through `withUserContext`. +Administrative migration credentials are never exported by this package or +loaded by an application process. + +## Current schema + +The schema modules under `src/schema/` define: + +- users and personalization profiles +- projects, threads, messages, and agent runs +- BYOK provider-key references and Composio integrations +- generated-output indexes and pending artifact-upload intents +- entitlements and sandbox/run activity +- user-authored skills +- project, account, refund, and daily-maintenance workflow jobs +- immutable Clerk deletion tombstones +- partitioned audit records and the archive manifest + +Files are not stored in Postgres. `v2_generated_outputs` contains only ownership, +mime, filename, and R2 object identity. + +## Invariants + +- All entity IDs are UUIDs and all public query helpers use branded IDs. +- User-facing reads and writes run under forced RLS. +- Project workspace slugs end in the owning project UUID and satisfy the + filesystem-safe canonical constraint. +- Agent-run terminal status and `finished_at` move together. +- Assistant transcript segments are unique by run and segment, with one final + segment marker. +- Provider-key rows contain Vault references and non-secret fingerprints only. +- Generated outputs and upload intents bind user, run, and project ownership. +- Lifecycle jobs use exact generation, phase, cursor, continuation, and lease + identities so stale Workflow steps cannot mutate a newer operation. +- Clerk deletion tombstones are permanent hashes; they prevent a deleted + external identity from being recreated by delayed webhooks. + +## Lifecycle state + +`v2_resource_deletion_jobs` and `v2_user_deletion_jobs` are durable Workflow +coordination records. They make multi-system deletion retryable across +Postgres, R2, Daytona, Composio, Polar, and Durable Objects. Successful and stale +jobs are removed; only quarantined failures remain for operator review. + +`v2_user_deletion_refund_intents` fences the one external money mutation in +account deletion. Its immutable provider identity and idempotency key prevent a +retry from issuing a second refund. + +`v2_daily_maintenance_jobs` coordinates daily activation aggregation, abandoned +upload-intent cleanup, and retention work. Each phase is leased and advances by +compare-and-swap. + +`v2_artifact_upload_intents` is the durable half of the Postgres/R2 commit +protocol. An AgentRun reserves an output identity before writing R2 and +atomically replaces the intent with `v2_generated_outputs` after the object is +verified. Daily maintenance removes only quiesced, terminal, expired intents. + +## Queries + +Public exports include: - `createDb` - `withUserContext` - `assertDatabaseRuntimeReadiness` - `resolveInternalUserId` -- `isUserAccountActive` for least-privilege fresh durable-state admission -- project/thread/message helpers, including the bounded model-context suffix reader -- run admission, status, and logical-model attribution helpers -- billing entitlement helpers, including `cancel_at_period_end` subscription - state for Polar cancellation/reactivation -- user-scoped run activity and sandbox-resource usage helpers -- 200-row keyset pages across daily `retention_d7`, `retention_d28`, and - `first_week_mau` activation cohorts -- lifecycle helpers for RLS-safe BYOK revalidation, invalid-key disablement, - tier-slot reconciliation, and Clerk deletion workflows -- bounded keyset helpers for object-first abandoned-upload cleanup -- leased project/thread deletion jobs with bounded continuation, migration fencing, backoff, and - quarantine +- project, thread, message, and agent-run helpers +- model-context suffix reads with logical-turn and byte bounds +- BYOK and integration helpers +- entitlement and usage helpers +- user-skill helpers +- lifecycle job discovery, claim, renewal, progression, and completion helpers +- audit and maintenance helpers - `schema/*` -Composio connected-account IDs are project-global provider identities and the primary -key of `v2_user_integrations`. Upserts may change status only when the stored -user and toolkit still match; an ownership/toolkit collision fails closed. -IDs must be trimmed, non-empty, and at most 256 characters. -Write helpers own a nested-safe transaction, serialize per user/toolkit, and -allow only an active account to be marked default. - -Entitlement updates and resource-consuming writes use one advisory-lock order: -entitlement, then project or provider-key catalog. Project-count and BYOK-slot -checks therefore read the authoritative entitlement row and commit their write -under the same tenant lock as Polar reconciliation. Bulk Composio upsert/delete -helpers keep ownership and default selection in one short nested-safe database -transaction; provider I/O is deliberately outside this package and outside the -RLS transaction. - -BYOK revalidation claims return the current non-secret fingerprint plus an exact -15-minute UUID lease. Plaintext is read only while both still match. A conclusive -validation records `last_revalidated_at` and clears the lease under the normal -provider-mutation lock; invalid-key disablement uses the same fingerprint/lease -compare-and-set. The provider HTTP request therefore runs with no Postgres -transaction or advisory lock held, failed requests do not suppress the key for -23 hours, and replacement/deletion/reclaim races cannot let stale work disable a -newer key. Provider-key reconciliation never resurrects a key disabled by -provider revalidation. The post-migration cleanup clears the retired -`tier_slot_limit` disable reason once; current provider-key mutations have no -subscription-slot policy or tier-based reranking behavior. - -Daily activation events are ordered by event kind and user UUID and traversed with -a stable keyset cursor. A page returns at most 200 rows, keeping both Hyperdrive -results and each Analytics Engine emission invocation below Cloudflare's 250-point -limit. Each logical activation event also has a deterministic identity so replayed -Workflow writes can be deduplicated with `count(DISTINCT blob6)` downstream. The -candidate scan uses `v2_users_activation_created_idx`; per-user activity probes use -`v2_agent_runs_user_started_idx`, alongside the separate run-deletion paging index. - -`v2_daily_maintenance_jobs` is the globally scoped orchestration aggregate for one UTC day's -activation metrics and orphan-upload cleanup chain. Its release/lease/continuation identity fences -every Workflow generation, and its phase and activation cursor are compared exactly on every -progress mutation. Abandoned-intent deletion and maintenance progress advancement share one -transaction, while external R2 deletion must first renew the same exact position. The -`app_webhooks` role has global maintenance policies but can insert only `day`/`scheduled_at` and -update only the orchestration columns; forced RLS and the production target contract reject broader -access. - -`v2_artifact_upload_intents` is the durable half of the Postgres/R2 commit protocol. An AgentRun -reserves a deterministic output/key identity before R2 is touched, then atomically replaces that -intent with `v2_generated_outputs` only after the create-only object write is verified. Terminal -run persistence marks any remaining intents quiesced only after the active execution and artifact -promises have settled. Reservation and the final pre-write guard extend `cleanup_not_before` by two -hours. Daily maintenance can therefore remove only intents whose immutable terminal run, explicit -quiescence proof, and remote-side-effect grace deadline all precede the day's fixed cutoff. -Committed generated outputs do not expire: they persist until their project or account is deleted. -An idempotent committed replay may acknowledge only the same committed output, closing the -post-commit response-loss window without reviving terminal work. -Postgres makes a terminal run's status and `finished_at` immutable, so maintenance cannot lose its -terminal proof between page selection and exact row deletion. -Composite NO ACTION foreign keys keep a pending intent discoverable and make project, run, or account -finalization fail closed until its object-first cleanup is complete. - -Account deletion uses `v2_users.deletion_fence` as an irreversible-phase -fence, `v2_users.deleted_at` as the durable grace deadline, and -`v2_user_deletion_jobs` as the resumable orchestration aggregate. A bounded discovery -RPC registers due generations; a separate maintenance-fenced claim RPC leases queued -or expired jobs and atomically installs the exact epoch-millisecond user fence. Clerk -deletion is terminal when first accepted: the identity advisory lock makes later or -out-of-order sync events return `in_progress`, and replayed delete events retain the original -deletion generation. Short Workflow generations persist the monotonic phase, -provider/keyset progress cursor, continuation, lease, and failure state. Failed instance -creation is deferred transactionally, and cron can reclaim both queued failures and expired -continuations without a total cleanup-page cap. - -Run state, the shared sandbox, billing, quota state, integrations, R2 objects and upload intents, -project archival, and finalization execute in that strict order. Every action renews the lease -and revalidates both job identity and deletion generation inside the destructive durable -step; database-only phases keep the check and mutation in one tenant transaction. -`v2_user_deletion_refund_intents` is the durable authority for the only provider-money mutation in -that sequence. Its composite foreign key binds one immutable order/amount/currency/idempotency -identity to the exact job, user, and generation. The `app_webhooks` role can read its own row but -can reserve or record evidence only through lease-, phase-, cursor-, and continuation-fenced -security-definer RPCs. Provider evidence is all-null or complete; provider IDs and idempotency keys -are unique, terminal status cannot regress, and an unresolved partial index supports the phase and -finalization guards. A `BEFORE UPDATE OF phase OR DELETE` trigger rejects leaving `billing` or -removing the job until the recorded Polar status is `succeeded`; the application repeats that -predicate before advance and before final user deletion. -The final delete and every Clerk identity sync also share a transaction-scoped advisory -lock derived from the external identity. The delete atomically records only a -SHA-256 identity tombstone before removing the user row, preventing an in-flight -or stale webhook from recreating an identity whose external resources were already -erased. Tombstones are permanent and contain no Clerk ID or user ID. Runtime -roles have no direct tombstone access; the postgres-owned finalization RPC owns -the advisory lock, tombstone insert, and exact fenced user delete atomically. -Retries after a lost delete response are idempotent. - -Clerk identity sync stores the provider's nonnegative millisecond `updated_at` in -`v2_users.clerk_updated_at_ms`. Newer source versions update the canonical email, -display name, and avatar; an equal version is an idempotent no-op and an older version -returns a typed stale outcome with the current row. Deletion remains terminal regardless -of source version. - -Project, thread, and message lists use versioned keyset cursors with stable timestamp/segment/id -ordering; invalid or cross-collection cursors fail instead of restarting at page one. -Message traversal starts at the latest page and continues toward older records, while the -gateway reverses each page into chronological rendering order. -Model-context traversal is a separate chronological suffix query: PostgreSQL groups physical -segments by logical run, skips a turn that cannot fit, and applies both its logical-turn count -and cumulative serialized-row byte limits before returning data through Hyperdrive. The Worker -therefore receives complete logical messages only and coalesces within the existing byte bound. -Project workspace slugs use a filesystem-safe display-name base of at most 27 bytes followed -by a hyphen and the project's full UUID. The validated ownership check makes the UUID suffix -mandatory while still allowing project renames without moving an immutable folder. User-scoped -advisory locks serialize project/thread/run lifecycle mutations. Project and thread deletion -use millisecond tombstones consumed by the object-first resource-deletion Workflow. Durable job -rows hold the exact generation, phase, cursor, continuation, lease, and failure state; successful -and stale jobs are removed, while only quarantined failures remain for operator review. Every -destructive action renews the exact resource generation and NULL-safe phase/cursor position; -advancement is a transition-checked compare-and-swap, so stale Workflow steps cannot regress or -act from a prior page. Daytona is the sole durable owner of each per-user workspace; Postgres -records only the immutable project workspace slug. - -Agent-run creation persists SHA-256 idempotency-key and request-body identities under a -per-key advisory lock and unique user/key constraint. Confirmed-absent Durable Object starts -are compensated by locking the run row, terminalizing a nonterminal run, and clearing only -the matching thread pointer in the same transaction. Assistant transcripts use ordered, -byte-bounded rows unique by run/segment plus one unique final marker. Incomplete runs remain -invisible; conflict handling compares bounded JSONB in PostgreSQL, so object-key order does not -change replay identity. Account-deletion run and integration identifiers are read in bounded keyset -pages rather than materialized into one Workflow payload. - -Permanent database checks mirror those domain transitions: thread launch intent is project-less -and one-shot, active runs require a materialized project, run terminal state and `finished_at` are -equivalent, quota/archive state moves as one pair, Polar subscription identities are globally -unique, and provider fingerprints are exact lowercase 12-hex projections. JSONB columns retain -their object/array containers and canonical logical-model IDs at the database boundary. Message -pagination is indexed by its complete `(created_at, agent_run_segment, id)` cursor, while worked-time -and active-run foreign-key paths have dedicated partial indexes. Generated-output R2 keys bind the -user, project-shaped UUID segment, run, output, and filename; transcript rows restrict run deletion -so their segment identity cannot be silently nulled. Raw post-deploy migration `0057` owns the -closed-gate repair/validation and removes the now-redundant workspace-slug uniqueness index. -It also installs the postgres-owned `ensure_v2_audit_partitions()` maintenance function and one -named daily `pg_cron` job. The function serializes DDL with an advisory lock, maintains only the -current month plus three future partitions, and grants execution to no application or Data API -role. The production target validates the exact function implementation, job owner/schedule/SQL, -and attached current/next partition runway. - -## Code Checks - -```bash -pnpm --filter @cheatcode/db typecheck -``` +List endpoints use versioned keyset cursors. Destructive workflows use bounded +pages and never serialize an unbounded tenant inventory into Workflow history. +External provider calls occur outside database transactions and advisory locks. ## Migrations +The repository keeps a single current-schema Drizzle baseline at +`drizzle/0000_current_schema.sql`, its generated snapshot, and the journal. +Future schema changes append ordinary forward Drizzle migrations. The +pre-launch historical migration archive is intentionally absent. + ```bash pnpm --filter @cheatcode/db db:generate -pnpm tsx scripts/migrate.ts --dry-run --phase=all -pnpm tsx scripts/migrate.ts --apply --phase=pre-deploy -pnpm tsx scripts/migrate.ts --apply --phase=post-deploy -pnpm tsx scripts/migrate.ts --apply --phase=release-finalization +pnpm db:migrate -- --dry-run +pnpm db:migrate -- --apply ``` -Production applies require the reviewed administrative connection URL and the -pinned database host/database/role/system identity values in the operator -environment. The default `all` phase is for read-only planning; mutating -multiple phases in one invocation is intentionally refused. Apply pre-deploy -expansions before dependent Workers, and apply post-deploy contractions and -release finalization only after every deployed writer is compatible with the -contracted schema. The migration runner pins the database host/database/role/system ID, -holds the shared database-maintenance advisory lock, verifies raw and Drizzle -history identities, executes the Drizzle journal through that same pinned -session, and refuses contractions until the complete pre-deploy phase is -recorded. Release finalization additionally refuses to start until every -post-deploy contraction is recorded. After taking that shared lock it also refuses to plan or apply DDL -while any durable resource-deletion job remains leased. Foundations, pre-deploy -expansions, post-deploy contractions, and the protected finalization each retain -their own monotonic stream; a completed contraction wave does not prevent a -later release from adding a new expansion wave. - -Workspace canonicalization is a cross-system maintenance transition, not an ordinary schema -backfill. No account or project is hard-coded, tombstoned, or deleted to make the transition pass. -During the exact-SHA closed-writer phase, the ops Workflow discovers every active owner and derives -each destination from the current canonical generator. Owner discovery returns compact IDs only; -each durable step reloads the exact owner's project inventory locally so Workflow history never -serializes a multi-owner project page. Bounded keyset generations carry their cursor and cumulative -evidence digest until every owner is complete. The user's -`ProjectSandbox` Durable Object drains and fences workspace operations, stops affected processes, -collision-checks and renames Daytona folders, reconciles durable process/port state, and records -prepare evidence. A maintenance-locked Postgres transaction then compare-and-swaps the complete -owner inventory before the Durable Object verifies and finalizes that same transition. Only after -every owner has produced exact release evidence may migration `0050` validate all remaining rows -and install the canonical ownership check. Neither the Workflow nor migration contains an owner, -project, or workspace mapping. - -Pre-deploy migration `0051` installs the durable resource-deletion job table before the new -webhooks Worker is deployed. Job claims remain fail-closed until generated outputs all have run -ownership, `0050` has validated the canonical workspace contract, and the shared database -maintenance advisory lock is available. This lets staged jobs exist safely across the release -barrier without racing post-deploy DDL or cascading ownerless output rows. - -The protected OPEN release creates and verifies an encrypted pre-contraction -backup before it may run any post-deploy migration. The archive contains a -custom-format dump of the `drizzle`, `public`, and `vault` schemas, an explicit -Vault plaintext export inside that encrypted envelope, database identity -evidence, and file checksums. The gate decrypts the artifact, verifies all -checksums, and makes `pg_restore` parse the entire dump. The encryption key stays -in the protected GitHub environment and is never available to a Worker. - -Post-deploy migration `0052` contracts generated-output identity to the object key in the single -`cheatcode-outputs` R2 bucket and removes the write-only billing-event diagnostic table. Polar -webhook acceptance, replay, and idempotency remain authoritative in `WebhookIdempotencyStore`; -current customer state and entitlements remain authoritative in Polar and `v2_entitlements`. - -Every raw-ledger row has a required SHA-256 identity. Missing identities, -modified executable migrations, and retired-manifest mismatches all fail closed; -the runner has no checksum repair or adoption mode. - -Raw migration `0046` is the only member of the protected -`release-finalization` stream and is additionally guarded by an external-cleanup -attestation whenever `public.projects` still exists. The JSON envelope is supplied -through the production-only `CHEATCODE_MIGRATION_ATTESTATIONS` secret under the -`v1-external-cleanup` key. Its exact payload binds the current database name and -system identifier, the live full-row V1 project inventory count/SHA-256, and the -current, unchanged `0046` file SHA-256. Daytona and Vercel proofs must each be -`verified-clean`, cover exactly 297 and 9 referenced resources respectively, -report zero remaining references, identify an immutable evidence artifact and its -nonzero SHA-256, and have been checked within seven days. The envelope must expire -within seven days. The runner validates this contract before planning or applying -release-finalization plan and passes the verified payload through transaction-local -Postgres settings; `0046` independently revalidates it before dropping anything. -Fresh V2-only databases bypass the one-time proof because they have no V1 project -inventory. Remove the protected secret after `0046` is recorded in the raw ledger. -The protected value has this envelope shape (replace every placeholder from the -reviewed database/provider evidence; do not commit the completed payload): - -```json -{ - "v1-external-cleanup": { - "schemaVersion": 1, - "scope": "v1-external-cleanup", - "migration": "infra/supabase/migrations/post/0046_remove_v1_database_surface.sql", - "migrationSha256": "", - "database": { - "name": "", - "systemIdentifier": "" - }, - "inventory": { "count": 300, "sha256": "" }, - "providers": { - "daytona": { - "status": "verified-clean", - "checkedAt": "", - "referencedResourceCount": 297, - "remainingResourceCount": 0, - "evidenceReference": "", - "evidenceSha256": "" - }, - "vercel": { - "status": "verified-clean", - "checkedAt": "", - "referencedResourceCount": 9, - "remainingResourceCount": 0, - "evidenceReference": "", - "evidenceSha256": "" - } - }, - "expiresAt": "" - } -} +The migration runner: + +1. Loads the git-ignored `.env.migrate`. +2. pins the expected host, database, role, and Postgres system identity; +3. acquires the shared database-maintenance advisory lock; +4. verifies the Drizzle journal checksum and ordering; +5. applies pending migrations only with `--apply`; and +6. validates the complete current table, column, constraint, index, function, + RLS, grant, role, audit-partition, and data-integrity contract. + +The laptop application environment contains only the three runtime-role URLs. +Administrative migration credentials stay in `.env.migrate` or a protected +operations environment. + +## Code checks + +```bash +pnpm --filter @cheatcode/db typecheck +pnpm --filter @cheatcode/db lint +pnpm --filter @cheatcode/db build ``` -Provision `app_gateway`, `app_agent`, and `app_webhooks` with three distinct managed credentials -before creating their matching production Hyperdrives. The production target validates their exact -table-operation, read/update-column, function, schema, database, role-attribute, membership, -default-ACL, and RLS-policy matrix. Full-table reads remain only where aggregate callers consume the -whole record; partial callers receive exact column-level `SELECT`. All three are `LOGIN`, `NOINHERIT`, -`NOBYPASSRLS`, and free of elevated capabilities. The historical `app_worker` identity remains -`NOLOGIN` only during the staged transition and is dropped by post-deploy finalization. Production -readiness fails if that role still exists. Password creation and rotation never belong in -version-controlled operations. - -The Agent role's exact `v2_users` read projection includes `deletion_fence` because -account/run Durable Object cleanup must compare the signed lifecycle request with the -current irreversible deletion generation. It receives no broader user-row access. - -Every tenant-owned V2 table has forced RLS. `createDb` requires the Worker's exact -database audience and role-specific signing binding; `withUserContext` resolves that -binding request-locally, signs the audience, canonical user UUID, epoch-millisecond issue -time, and random nonce, and installs the tuple with transaction-local settings. The -postgres-owned `current_app_user()` function selects the exact Vault key for -`session_user`, enforces a 15-second past/2-second future freshness window, and compares -the HMAC in fixed work before any tenant policy can resolve. `SET LOCAL` clears the tuple -at transaction end. The nonce provides per-request domain separation rather than a -database replay ledger, so a fully disclosed tuple is valid only inside that short -freshness window; signed tuples never cross the Worker/database boundary or enter logs. - -The three Cloudflare Secrets Store bindings must hold values identical to their matching -Supabase Vault entries, with no shared fallback: - -- `DATABASE_CONTEXT_SIGNING_SECRET_GATEWAY` ↔ - `cheatcode-database-context-app-gateway-v1` -- `DATABASE_CONTEXT_SIGNING_SECRET_AGENT` ↔ - `cheatcode-database-context-app-agent-v1` -- `DATABASE_CONTEXT_SIGNING_SECRET_WEBHOOKS` ↔ - `cheatcode-database-context-app-webhooks-v1` - -Each value is distinct and at least 32 bytes. Fleet maintenance crosses tenants only -through postgres-owned, bounded, role-specific RPCs; runtime roles cannot directly read -the tombstone or audit surfaces. Pre-deploy migration `0060` installs those bounded RPCs -and rejects missing/misdescribed Vault keys. Post-deploy migration `0061` installs the -signed verifier, forces RLS, removes prior policies, and regrants the exact final role -matrix. The closed-release database-readiness probe signs a fixed non-tenant sentinel and -verifies both `current_app_user()` and `session_user`; it reads or mutates no tenant row. - -The Composio identity migration is staged: pre-deploy migration `0031` rejects -duplicates and installs the unique provider-ID index required by new Workers; -post-deploy migration `0032` repairs default state and promotes that index to -the table primary key. Do not deploy the new integration upsert before `0031`. - -Drizzle migration `0020_user_deletion_fence.sql` is an expand-only pre-deploy -column addition and must land before the fenced lifecycle code. -Drizzle migration `0021_clerk_deletion_tombstone.sql` and pre-deploy security -overlay `0033_clerk_deletion_tombstone_access.sql` must land before Workers that -write or check identity tombstones. -Drizzle migrations `0022_agent_run_idempotency.sql`, -`0023_project_cleanup_and_keyset_indexes.sql`, and -`0024_deletion_pages_and_assistant_message_identity.sql` must land before the matching -gateway, agent, and deletion Workflow code. Post-deploy migration -`0034_remove_superseded_thread_index.sql` removes the narrower prior sidebar index only -after its keyset-ready replacement is live. The output-integrity overlay in `0028` -validates historical rows and protects new writes before deployment; post-deploy -migration `0035_finalize_security_integrity.sql` makes `sha256` physically non-null, -forces security-sensitive RLS, and removes direct audit-log mutation only after the -matching Workers are live. -Drizzle migration `0026_first_artifact_milestone.sql` adds and backfills the durable -first-artifact timestamp so later project or account cleanup cannot cause the activation event to -fire again. -Drizzle migration `0040_tiresome_jack_murdock.sql` adds the bounded account-deletion -due index. Drizzle migration `0041_great_adam_warlock.sql` adds the durable deletion-job -aggregate. Pre-deploy overlay `0062_user_deletion_jobs.sql` installs its least-privilege -RLS and bounded discovery/claim RPCs; post-deploy `0063_remove_legacy_user_deletion_admission.sql` -removes the superseded due-page RPC and restores only the reviewed steady-state grants -after the global role contraction. Post-deploy `0065_enforce_terminal_clerk_deletion.sql` -makes the first accepted Clerk deletion and its generation irreversible to delayed sync or -replayed delete events. -Drizzle migration `0043_third_sleeper.sql` adds the bounded Clerk source-version column and -widens user-deletion generations from millisecond to microsecond timestamp precision without -changing their epoch-millisecond external fence. Post-deploy `0066_enforce_monotonic_clerk_identity_sync.sql` -removes the temporary backfill default, drops the superseded four-argument sync function, -installs the version-aware function, and makes database fence derivation truncate exactly like -JavaScript `Date` rather than round sub-millisecond timestamps. -Drizzle migration `0027_remove_project_backup_scaffolding.sql` records the schema snapshot -contraction without executing destructive SQL before deployment. Post-deploy migration -`0036_remove_project_backup_scaffolding.sql` removes `v2_projects.container_backup` only after -Workers that no longer read or write the obsolete backup handle have been verified. -Drizzle migration `0032_finalize_agent_run_model_attribution.sql` records the required agent-run model -attribution schema without executing its contraction before deployment. After Workers -persist a canonical logical model on every run, raw post-deploy migration -`0041_finalize_agent_run_model_attribution.sql` attributes historical automatic runs and -makes `v2_agent_runs.model_id` physically non-null. -Drizzle migration `0034_broken_nighthawk.sql` adds the bounded assistant-segment columns, -indexes, and integrity checks after refusing any historical row above the database unit bound. -It deliberately retains the former one-row-per-run index for old-Worker rollout safety. With -the gateway closed and AgentRuns drained, post-deploy migration -`0053_finalize_assistant_transcript_segments.sql` locks run/message writes and removes that old -index. Until the contraction lands, multi-segment finalization remains hidden and durably retries. -Drizzle migration `0038_pretty_nocturne.sql` adds the exact user/assistant role check without -scanning historical rows; post-deploy migration `0055_finalize_message_roles.sql` removes obsolete -experimental-role rows and validates it. Post-deploy migration -`0056_remove_unused_llamaparse_provider.sql` deletes the unused provider and its owned Vault secret, -reranks tier-slot state for affected users without clearing provider-invalid disables, and contracts -both the provider table check and Vault write RPC to the seven live providers. - -Audit retention uses a resumable detach/archive/purge state machine. Daily database-owned -partition creation is deliberately separate from archival and does not grant DDL to a Worker. -Detach and -its recovery manifest commit atomically; R2 objects are content-addressed and -download-verified. The version-1 NDJSON envelope retains event/time/type -evidence but omits user IDs, resource IDs, metadata, IP addresses, and user -agents. A failed upload leaves the full detached table available for the next -run. Database copies may be purged only in a separate run after at least 30 -verified days and a typed confirmation; the R2 object is re-verified and is not -deleted. - -Production archive planning and apply run only through the protected manual -`Audit Archive` workflow. Select `dry-run` with `PLAN_AUDIT_ARCHIVE`, or `apply` -with `APPLY_AUDIT_ARCHIVE`. Purge additionally requires -`DROP_VERIFIED_AUDIT_PARTITIONS`. Laptop and all non-workflow archive operations -are rejected. - -`packages/db/src/schema/drizzle.ts` is the Drizzle migration-generation barrel. -It intentionally omits `auditLog`, because `v2_audit_log` is partitioned and owned -by `infra/supabase/migrations/pre/0003_audit_log_partitioned.sql`. - -## Env - -- Workers pass `env.HYPERDRIVE.connectionString`. -- Each database-backed Worker passes only its matching - `DATABASE_CONTEXT_SIGNING_SECRET_GATEWAY`, - `DATABASE_CONTEXT_SIGNING_SECRET_AGENT`, or - `DATABASE_CONTEXT_SIGNING_SECRET_WEBHOOKS` binding to `createDb`. -- Migration scripts read `SUPABASE_MIGRATION_URL` from root `.env.migrate` on an - authorized operator workstation or protected process environment variables in - automation. The app, Compose, Next.js, and Wrangler never load this file. -- Audit archive production operations receive `CLOUDFLARE_ACCOUNT_ID` and the - protected `AUDIT_ARCHIVE_CLOUDFLARE_API_TOKEN`. Scope that token only to - `Workers R2 Storage Bucket Item Write` on the `cheatcode-audit` bucket; it is - exposed to Wrangler as `CLOUDFLARE_API_TOKEN` only inside the workflow job. +## Environment + +Runtime callers supply their Worker-specific Hyperdrive binding and matching +tenant-context signing secret. Migration tooling uses: + +- `SUPABASE_MIGRATION_URL` +- `SUPABASE_MIGRATION_EXPECTED_HOST` +- `SUPABASE_MIGRATION_EXPECTED_DATABASE` +- `SUPABASE_MIGRATION_EXPECTED_ROLE` +- `SUPABASE_MIGRATION_EXPECTED_SYSTEM_IDENTIFIER` diff --git a/packages/db/drizzle/0000_current_schema.sql b/packages/db/drizzle/0000_current_schema.sql new file mode 100644 index 00000000..11e28e78 --- /dev/null +++ b/packages/db/drizzle/0000_current_schema.sql @@ -0,0 +1,6764 @@ +-- +-- PostgreSQL database dump +-- + +-- Cheatcode runs only on Supabase Postgres. Bootstrap the external objects that +-- are intentionally outside the public schema dump before restoring it. +CREATE SCHEMA IF NOT EXISTS extensions; + +CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA extensions; +CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA extensions; +CREATE EXTENSION IF NOT EXISTS supabase_vault WITH SCHEMA extensions; +CREATE EXTENSION IF NOT EXISTS moddatetime WITH SCHEMA extensions; + +DO $roles$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'app_gateway') THEN + CREATE ROLE app_gateway + LOGIN NOINHERIT NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS; + END IF; + IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'app_agent') THEN + CREATE ROLE app_agent + LOGIN NOINHERIT NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS; + END IF; + IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'app_webhooks') THEN + CREATE ROLE app_webhooks + LOGIN NOINHERIT NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS; + END IF; +END +$roles$; + +ALTER ROLE app_gateway SET search_path = public, pg_catalog; +ALTER ROLE app_agent SET search_path = public, pg_catalog; +ALTER ROLE app_webhooks SET search_path = public, pg_catalog; + +DO $database_access$ +BEGIN + EXECUTE pg_catalog.format( + 'GRANT CONNECT ON DATABASE %I TO app_gateway, app_agent, app_webhooks', + pg_catalog.current_database() + ); +END +$database_access$; + + +-- Dumped from database version 17.4 +-- Dumped by pg_dump version 17.10 + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET transaction_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +-- +-- Name: public; Type: SCHEMA; Schema: -; Owner: - +-- + +CREATE SCHEMA IF NOT EXISTS public; + + +-- +-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON SCHEMA public IS 'standard public schema'; + + +-- +-- Name: claim_provider_key_revalidation_targets(integer); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.claim_provider_key_revalidation_targets(p_limit integer) RETURNS TABLE(user_id uuid, provider text, fingerprint text, lease_token uuid) + LANGUAGE sql SECURITY DEFINER + SET search_path TO '' + AS $$ + with targets as ( + select key.user_id, key.provider + from public.v2_provider_keys key + where key.disabled_at is null + and ( + key.last_revalidated_at is null + or key.last_revalidated_at < pg_catalog.now() - interval '23 hours' + ) + and ( + key.revalidation_claimed_at is null + or key.revalidation_claimed_at < pg_catalog.now() - interval '15 minutes' + ) + order by + key.last_revalidated_at asc nulls first, + key.revalidation_claimed_at asc nulls first, + key.created_at, + key.user_id, + key.provider + for update skip locked + limit least(greatest(coalesce(p_limit, 10), 1), 10) + ), claimed as ( + update public.v2_provider_keys key + set revalidation_claimed_at = pg_catalog.now(), + revalidation_lease_token = public.uuidv7() + from targets + where key.user_id = targets.user_id + and key.provider = targets.provider + returning key.user_id, key.provider, key.fingerprint, key.revalidation_lease_token + ) + select claimed.user_id, claimed.provider, claimed.fingerprint, claimed.revalidation_lease_token + from claimed +$$; + + +-- +-- Name: current_app_user(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.current_app_user() RETURNS uuid + LANGUAGE plpgsql STABLE SECURITY DEFINER + SET search_path TO '' + AS $_$ +declare + actor_id uuid; + actor_text text := pg_catalog.current_setting('app.user_id', true); + audience text := session_user; + context_secret text; + expected_description text; + expected_hmac bytea; + expected_name text; + issued_at bigint; + issued_text text := pg_catalog.current_setting('app.context_issued_at', true); + nonce_text text := pg_catalog.current_setting('app.context_nonce', true); + now_ms bigint; + payload text; + signature_difference integer; + signature_text text := pg_catalog.current_setting('app.context_signature', true); + supplied_hmac bytea; +begin + if audience not in ('app_agent', 'app_gateway', 'app_webhooks') then + raise exception using + errcode = '42501', + message = 'signed tenant context is unavailable to this database role'; + end if; + if actor_text is null + or actor_text !~ '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' + or issued_text is null + or issued_text !~ '^[0-9]{13}$' + or nonce_text is null + or nonce_text !~ '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' + or signature_text is null + or signature_text !~ '^[0-9a-f]{64}$' then + raise exception using + errcode = '42501', + message = 'signed tenant context is malformed'; + end if; + + actor_id := actor_text::uuid; + issued_at := issued_text::bigint; + now_ms := ( + extract(epoch from pg_catalog.transaction_timestamp()) * 1000 + )::bigint; + if issued_at < now_ms - 15000 or issued_at > now_ms + 2000 then + raise exception using + errcode = '42501', + message = 'signed tenant context is outside its freshness window'; + end if; + + expected_name := 'cheatcode-database-context-' || + pg_catalog.replace(audience, '_', '-') || '-v1'; + expected_description := 'Cheatcode signed tenant context HMAC for ' || audience; + select secret.decrypted_secret into strict context_secret + from vault.decrypted_secrets secret + where secret.name = expected_name + and secret.description = expected_description; + if pg_catalog.octet_length(context_secret) < 32 then + raise exception 'signed tenant context secret is invalid'; + end if; + + payload := 'cheatcode-database-context-v1' || pg_catalog.chr(10) || + audience || pg_catalog.chr(10) || actor_text || pg_catalog.chr(10) || + issued_text || pg_catalog.chr(10) || nonce_text; + expected_hmac := extensions.hmac( + pg_catalog.convert_to(payload, 'UTF8'), + pg_catalog.convert_to(context_secret, 'UTF8'), + 'sha256' + ); + supplied_hmac := pg_catalog.decode(signature_text, 'hex'); + select pg_catalog.bit_or( + pg_catalog.get_byte(expected_hmac, offset_value) # + pg_catalog.get_byte(supplied_hmac, offset_value) + ) into signature_difference + from pg_catalog.generate_series(0, 31) as offsets(offset_value); + if signature_difference is distinct from 0 then + raise exception using + errcode = '42501', + message = 'signed tenant context signature is invalid'; + end if; + return actor_id; +exception + when no_data_found or too_many_rows then + raise exception using + errcode = '42501', + message = 'signed tenant context secret contract is invalid'; +end +$_$; + + +-- +-- Name: delete_all_provider_keys(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.delete_all_provider_keys() RETURNS integer + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + actor_id uuid := public.current_app_user(); + deleted_count integer; +begin + perform pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended( + 'cheatcode:provider-keys:' || actor_id::text, + 0 + ) + ); + delete from public.v2_provider_keys where user_id = actor_id; + get diagnostics deleted_count = row_count; + return deleted_count; +end +$$; + + +-- +-- Name: delete_provider_key(text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.delete_provider_key(p_provider text) RETURNS void + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + actor_id uuid := public.current_app_user(); +begin + perform pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended( + 'cheatcode:provider-keys:' || actor_id::text, + 0 + ) + ); + delete from public.v2_provider_keys + where user_id = actor_id and provider = p_provider; +end +$$; + + +-- +-- Name: ensure_v2_audit_partitions(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.ensure_v2_audit_partitions() RETURNS integer + LANGUAGE plpgsql + SET search_path TO '' + AS $$ +declare + child_oid oid; + created_count integer := 0; + expected_bound text; + month_offset integer; + partition_bound text; + partition_end date; + partition_name text; + partition_start date; +begin + if pg_catalog.to_regclass('public.v2_audit_log') is null then + raise exception 'audit partition maintenance requires public.v2_audit_log'; + end if; + perform pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended('cheatcode:v2:audit-partitions', 0) + ); + + for month_offset in 0..3 loop + partition_start := ( + pg_catalog.date_trunc( + 'month', + pg_catalog.timezone('UTC', pg_catalog.statement_timestamp()) + ) + pg_catalog.make_interval(months => month_offset) + )::date; + partition_end := (partition_start + pg_catalog.make_interval(months => 1))::date; + partition_name := 'v2_audit_log_' || pg_catalog.to_char(partition_start, 'YYYY_MM'); + expected_bound := pg_catalog.format( + 'FOR VALUES FROM (%L) TO (%L)', + partition_start::text || ' 00:00:00+00', + partition_end::text || ' 00:00:00+00' + ); + child_oid := pg_catalog.to_regclass(pg_catalog.format('public.%I', partition_name)); + + if child_oid is null then + execute pg_catalog.format( + 'create table public.%I partition of public.v2_audit_log for values from (%L) to (%L)', + partition_name, + partition_start::text || ' 00:00:00+00', + partition_end::text || ' 00:00:00+00' + ); + child_oid := pg_catalog.to_regclass(pg_catalog.format('public.%I', partition_name)); + created_count := created_count + 1; + elsif not exists ( + select 1 from pg_catalog.pg_inherits inheritance + where inheritance.inhrelid = child_oid + and inheritance.inhparent = 'public.v2_audit_log'::regclass + ) then + raise exception 'audit partition name % is occupied by an unattached relation', + partition_name; + else + select pg_catalog.pg_get_expr(relation.relpartbound, relation.oid) + into partition_bound + from pg_catalog.pg_class relation + where relation.oid = child_oid; + if partition_bound is distinct from expected_bound then + raise exception 'audit partition % has unexpected bounds: %', + partition_name, + partition_bound; + end if; + end if; + + execute pg_catalog.format( + 'alter table public.%I enable row level security', partition_name + ); + execute pg_catalog.format( + 'alter table public.%I force row level security', partition_name + ); + execute pg_catalog.format( + 'revoke all privileges on table public.%I from app_gateway, app_agent, app_webhooks', + partition_name + ); + execute pg_catalog.format( + 'drop policy if exists v2_audit_partition_postgres_all on public.%I', partition_name + ); + execute pg_catalog.format( + 'create policy v2_audit_partition_postgres_all on public.%I for all to postgres using (true) with check (true)', + partition_name + ); + end loop; + return created_count; +end +$$; + + +-- +-- Name: gateway_resolve_clerk_user(text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.gateway_resolve_clerk_user(p_clerk_id text) RETURNS uuid + LANGUAGE sql STABLE SECURITY DEFINER + SET search_path TO '' + AS $$ + select app_user.id + from public.v2_users app_user + where app_user.clerk_id = p_clerk_id and app_user.deleted_at is null + limit 1 +$$; + + +-- +-- Name: get_provider_key(text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.get_provider_key(p_provider text) RETURNS text + LANGUAGE sql STABLE SECURITY DEFINER + SET search_path TO '' + AS $$ + select secret.decrypted_secret + from public.v2_provider_keys key + join vault.decrypted_secrets secret on secret.id = key.vault_secret_id + where key.user_id = public.current_app_user() + and key.provider = p_provider + and key.disabled_at is null +$$; + + +-- +-- Name: scrub_current_user_audit(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.scrub_current_user_audit() RETURNS bigint + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + actor_id uuid := public.current_app_user(); + scrubbed_count bigint; +begin + update public.v2_audit_log + set user_id = null, + resource_id = null, + metadata = jsonb_build_object('subject_erased', true) + where user_id = actor_id; + get diagnostics scrubbed_count = row_count; + return scrubbed_count; +end +$$; + + +-- +-- Name: set_provider_key(text, text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.set_provider_key(p_provider text, p_key text) RETURNS void + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + actor_id uuid := public.current_app_user(); + secret_id uuid; + key_fingerprint text; +begin + if p_provider is null or p_provider not in ( + 'anthropic', + 'openai', + 'google', + 'openrouter', + 'deepseek', + 'exa', + 'firecrawl' + ) then + raise exception 'unsupported provider'; + end if; + if p_key is null or btrim(p_key) = '' or octet_length(p_key) > 65536 then + raise exception 'provider key must contain between 1 and 65536 bytes'; + end if; + + perform pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended( + 'cheatcode:provider-keys:' || actor_id::text, + 0 + ) + ); + + key_fingerprint := substring( + encode(extensions.digest(convert_to(p_key, 'UTF8'), 'sha256'), 'hex') + for 12 + ); + + delete from public.v2_provider_keys + where user_id = actor_id and provider = p_provider; + + secret_id := vault.create_secret( + p_key, + actor_id::text || ':' || p_provider || ':' || public.uuidv7()::text, + 'Cheatcode V2 BYOK provider key' + ); + + insert into public.v2_provider_keys ( + user_id, + provider, + vault_secret_id, + fingerprint + ) values ( + actor_id, + p_provider, + secret_id, + key_fingerprint + ); +end +$$; + + +-- +-- Name: sync_clerk_user(text, text, text, text, bigint); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.sync_clerk_user(p_clerk_id text, p_email text, p_display_name text, p_avatar_url text, p_clerk_updated_at_ms bigint) RETURNS TABLE(sync_state text, user_id uuid, email text, display_name text, avatar_url text, polar_customer_id text, clerk_updated_at_ms bigint, email_changed boolean, profile_changed boolean) + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + has_existing boolean; + identity_hash text; + existing record; + persisted record; +begin + if p_clerk_id is null or btrim(p_clerk_id) = '' or octet_length(p_clerk_id) > 512 then + raise exception 'invalid Clerk identity'; + end if; + if p_email is null or btrim(p_email) = '' or octet_length(p_email) > 512 then + raise exception 'invalid Clerk email'; + end if; + if p_clerk_updated_at_ms is null + or p_clerk_updated_at_ms < 0 + or p_clerk_updated_at_ms > 9007199254740991 then + raise exception 'invalid Clerk source version'; + end if; + if octet_length(coalesce(p_display_name, '')) > 1024 + or octet_length(coalesce(p_avatar_url, '')) > 4096 then + raise exception 'invalid Clerk profile payload'; + end if; + + identity_hash := pg_catalog.encode( + extensions.digest(pg_catalog.convert_to(p_clerk_id, 'UTF8'), 'sha256'), + 'hex' + ); + perform pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended('cheatcode:clerk-identity:' || identity_hash, 0) + ); + if exists ( + select 1 from public.v2_deleted_clerk_identities retired + where retired.clerk_identity_hash = identity_hash + ) then + return query select 'completed', null::uuid, null::text, null::text, + null::text, null::text, null::bigint, false, false; + return; + end if; + + select app_user.id, app_user.avatar_url, app_user.clerk_updated_at_ms, + app_user.deleted_at, app_user.display_name, app_user.email, + app_user.polar_customer_id + into existing + from public.v2_users app_user + where app_user.clerk_id = p_clerk_id; + has_existing := found; + if has_existing and existing.deleted_at is not null then + return query select 'in_progress', null::uuid, null::text, null::text, + null::text, null::text, null::bigint, false, false; + return; + end if; + if has_existing and existing.clerk_updated_at_ms > p_clerk_updated_at_ms then + return query select 'stale', existing.id, existing.email, existing.display_name, + existing.avatar_url, existing.polar_customer_id, existing.clerk_updated_at_ms, + false, false; + return; + end if; + if has_existing and existing.clerk_updated_at_ms = p_clerk_updated_at_ms then + return query select 'unchanged', existing.id, existing.email, existing.display_name, + existing.avatar_url, existing.polar_customer_id, existing.clerk_updated_at_ms, + false, false; + return; + end if; + + if has_existing then + update public.v2_users app_user + set email = btrim(p_email), + display_name = nullif(btrim(p_display_name), ''), + avatar_url = nullif(btrim(p_avatar_url), ''), + clerk_updated_at_ms = p_clerk_updated_at_ms + where app_user.id = existing.id + and app_user.deleted_at is null + and app_user.deletion_fence is null + and app_user.clerk_updated_at_ms < p_clerk_updated_at_ms + returning app_user.id, app_user.email, app_user.display_name, + app_user.avatar_url, app_user.polar_customer_id, + app_user.clerk_updated_at_ms + into persisted; + else + insert into public.v2_users ( + clerk_id, clerk_updated_at_ms, email, display_name, avatar_url + ) values ( + p_clerk_id, + p_clerk_updated_at_ms, + btrim(p_email), + nullif(btrim(p_display_name), ''), + nullif(btrim(p_avatar_url), '') + ) + returning id, public.v2_users.email, public.v2_users.display_name, + public.v2_users.avatar_url, public.v2_users.polar_customer_id, + public.v2_users.clerk_updated_at_ms + into persisted; + end if; + if not found then + return query select 'in_progress', null::uuid, null::text, null::text, + null::text, null::text, null::bigint, false, false; + return; + end if; + + insert into public.v2_entitlements (user_id, tier) + values (persisted.id, 'free') + on conflict on constraint v2_entitlements_pkey do nothing; + return query select + case when has_existing then 'updated' else 'created' end, + persisted.id, + persisted.email, + persisted.display_name, + persisted.avatar_url, + persisted.polar_customer_id, + persisted.clerk_updated_at_ms, + has_existing and existing.email is distinct from persisted.email, + has_existing and ( + existing.email is distinct from persisted.email + or existing.display_name is distinct from persisted.display_name + or existing.avatar_url is distinct from persisted.avatar_url + ); +end +$$; + + +-- +-- Name: uuidv7(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.uuidv7() RETURNS uuid + LANGUAGE sql SECURITY DEFINER + SET search_path TO '' + AS $$ + with + timestamp_bytes as ( + select substring( + int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) + from 3 + for 6 + ) as value + ), + random_bytes as ( + select extensions.gen_random_bytes(10) as value + ), + uuid_bytes as ( + select + timestamp_bytes.value + || set_byte( + substring(random_bytes.value from 1 for 2), + 0, + (get_byte(random_bytes.value, 0) & 15) | 112 + ) + || set_byte( + substring(random_bytes.value from 3 for 8), + 0, + (get_byte(random_bytes.value, 2) & 63) | 128 + ) as value + from timestamp_bytes, random_bytes + ) + select encode(uuid_bytes.value, 'hex')::uuid + from uuid_bytes; +$$; + + +-- +-- Name: v2_audit_entitlement_change(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.v2_audit_entitlement_change() RETURNS trigger + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +begin + if TG_OP = 'UPDATE' and + (NEW.tier, NEW.subscription_status, NEW.cancel_at_period_end) + is not distinct from + (OLD.tier, OLD.subscription_status, OLD.cancel_at_period_end) then + return NEW; + end if; + insert into public.v2_audit_log (user_id, action, resource_type, resource_id, metadata) + values ( + coalesce(NEW.user_id, OLD.user_id), + 'billing.entitlement.' || lower(TG_OP), + 'entitlement', + null, + jsonb_strip_nulls(jsonb_build_object( + 'tier', case when TG_OP = 'DELETE' then OLD.tier else NEW.tier end, + 'subscription_status', + case when TG_OP = 'DELETE' then OLD.subscription_status else NEW.subscription_status end, + 'cancel_at_period_end', + case when TG_OP = 'DELETE' then OLD.cancel_at_period_end else NEW.cancel_at_period_end end + )) + ); + return coalesce(NEW, OLD); +end +$$; + + +-- +-- Name: v2_audit_integration_change(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.v2_audit_integration_change() RETURNS trigger + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +begin + if tg_op = 'UPDATE' + and (new.status, new.is_default) is not distinct from (old.status, old.is_default) then + return new; + end if; + + insert into public.v2_audit_log ( + user_id, + action, + resource_type, + resource_id, + metadata + ) values ( + coalesce(new.user_id, old.user_id), + 'integration.' || lower(tg_op), + 'integration', + coalesce(new.integration, old.integration), + jsonb_build_object('status', coalesce(new.status, old.status)) + ); + return coalesce(new, old); +end +$$; + + +-- +-- Name: v2_audit_provider_key_change(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.v2_audit_provider_key_change() RETURNS trigger + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + audit_action text; +begin + if tg_op = 'UPDATE' + and (to_jsonb(new) - array[ + 'last_revalidated_at', + 'revalidation_claimed_at', + 'revalidation_lease_token' + ]) is not distinct from (to_jsonb(old) - array[ + 'last_revalidated_at', + 'revalidation_claimed_at', + 'revalidation_lease_token' + ]) then + return new; + end if; + + audit_action := case + when tg_op = 'INSERT' then 'provider_key.create' + when tg_op = 'DELETE' then 'provider_key.delete' + when old.disabled_at is null and new.disabled_at is not null then 'provider_key.disable' + when old.disabled_at is not null and new.disabled_at is null then 'provider_key.enable' + else 'provider_key.update' + end; + + insert into public.v2_audit_log ( + user_id, + action, + resource_type, + resource_id, + metadata + ) values ( + coalesce(new.user_id, old.user_id), + audit_action, + 'provider_key', + coalesce(new.provider, old.provider), + jsonb_build_object('fingerprint', coalesce(new.fingerprint, old.fingerprint)) + ); + return coalesce(new, old); +end +$$; + + +-- +-- Name: v2_delete_provider_vault_secret(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.v2_delete_provider_vault_secret() RETURNS trigger + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + secret_name text; + secret_description text; +begin + delete from vault.secrets + where id = old.vault_secret_id + returning name, description into secret_name, secret_description; + + if not found then + raise exception 'refusing to delete a provider key with a missing Vault secret'; + end if; + if secret_name not like old.user_id::text || ':' || old.provider || ':%' + or secret_description is distinct from 'Cheatcode V2 BYOK provider key' then + raise exception 'refusing to delete a provider key with mismatched Vault ownership metadata'; + end if; + return old; +end +$$; + + +-- +-- Name: v2_guard_terminal_agent_run_state(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.v2_guard_terminal_agent_run_state() RETURNS trigger + LANGUAGE plpgsql + SET search_path TO '' + AS $$ +begin + if old.status in ('completed', 'failed', 'canceled') + and ( + new.status is distinct from old.status + or new.finished_at is distinct from old.finished_at + ) then + raise exception 'terminal agent-run state is immutable' + using errcode = '23514'; + end if; + return new; +end +$$; + + +-- +-- Name: v2_guard_user_deletion_refund_resolution(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.v2_guard_user_deletion_refund_resolution() RETURNS trigger + LANGUAGE plpgsql + SET search_path TO '' + AS $$ +begin + if ( + tg_op = 'DELETE' + or (old.phase = 'billing' and new.phase <> 'billing') + ) and exists ( + select 1 + from public.v2_user_deletion_refund_intents refund_intent + where refund_intent.job_id = old.id + and refund_intent.provider_status is distinct from 'succeeded' + ) then + raise exception 'user-deletion job has an unresolved refund intent'; + end if; + return case when tg_op = 'DELETE' then old else new end; +end +$$; + + +-- +-- Name: v2_touch_updated_at(); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.v2_touch_updated_at() RETURNS trigger + LANGUAGE plpgsql + SET search_path TO '' + AS $$ +begin + new.updated_at := pg_catalog.now(); + return new; +end +$$; + + +-- +-- Name: webhooks_claim_ready_resource_deletion_jobs(uuid, integer, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_claim_ready_resource_deletion_jobs(p_lease_token uuid, p_limit integer, p_max_failures integer, p_now timestamp with time zone) RETURNS TABLE(disposition text, job_id uuid, user_id uuid, continuation integer) + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + candidate_ids uuid[]; + quarantine_ids uuid[]; +begin + if p_lease_token is null or p_now is null or p_max_failures < 1 then + raise exception 'invalid resource-deletion claim input'; + end if; + if not pg_catalog.pg_try_advisory_xact_lock( + pg_catalog.hashtextextended('cheatcode:database-maintenance:v1', 0) + ) then + return; + end if; + select coalesce(array_agg(candidate.id), array[]::uuid[]) + into candidate_ids + from ( + select job.id + from public.v2_resource_deletion_jobs job + where (job.status = 'queued' and job.next_attempt_at <= p_now) + or (job.status = 'leased' and job.lease_expires_at <= p_now) + order by job.next_attempt_at, job.id + limit greatest(1, least(coalesce(p_limit, 1), 25)) + for update skip locked + ) candidate; + select coalesce(array_agg(job.id), array[]::uuid[]) + into quarantine_ids + from public.v2_resource_deletion_jobs job + where job.id = any(candidate_ids) + and job.status = 'leased' + and job.failure_count + 1 >= p_max_failures; + + return query + update public.v2_resource_deletion_jobs job + set continuation = job.continuation + 1, + failure_count = job.failure_count + 1, + last_error_code = 'resource_deletion_lease_expired', + lease_expires_at = null, + lease_token = null, + status = 'quarantined' + where job.id = any(quarantine_ids) + returning 'quarantined'::text, job.id, job.user_id, job.continuation; + return query + update public.v2_resource_deletion_jobs job + set continuation = case when job.status = 'leased' + then job.continuation + 1 else job.continuation end, + failure_count = case when job.status = 'leased' + then job.failure_count + 1 else job.failure_count end, + last_error_code = case when job.status = 'leased' + then 'resource_deletion_lease_expired' else job.last_error_code end, + lease_expires_at = p_now + interval '2 hours', + lease_token = p_lease_token, + next_attempt_at = case when job.status = 'leased' + then p_now else job.next_attempt_at end, + status = 'leased' + where job.id = any(candidate_ids) + and not (job.id = any(quarantine_ids)) + returning 'leased'::text, job.id, job.user_id, job.continuation; +end +$$; + + +-- +-- Name: webhooks_claim_ready_user_deletion_jobs(uuid, integer, integer, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_claim_ready_user_deletion_jobs(p_lease_token uuid, p_limit integer, p_max_failures integer, p_now timestamp with time zone) RETURNS TABLE(disposition text, job_id uuid, user_id uuid, continuation integer) + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + candidate record; + expected_fence text; + page_size integer := greatest(1, least(coalesce(p_limit, 1), 25)); +begin + if p_lease_token is null or p_now is null or p_max_failures is null + or p_max_failures < 1 then + raise exception 'invalid user-deletion claim input'; + end if; + if not pg_catalog.pg_try_advisory_xact_lock( + pg_catalog.hashtextextended('cheatcode:database-maintenance:v1', 0) + ) then + return; + end if; + for candidate in + select job.id, job.user_id, job.generation, job.continuation, + job.failure_count, job.status + from public.v2_user_deletion_jobs job + where (job.status = 'queued' and job.next_attempt_at <= p_now) + or (job.status = 'leased' and job.lease_expires_at <= p_now) + order by job.next_attempt_at, job.id + limit page_size + for update skip locked + loop + expected_fence := ( + pg_catalog.trunc(extract(epoch from candidate.generation) * 1000)::bigint + )::text; + update public.v2_users app_user + set deletion_fence = expected_fence + where app_user.id = candidate.user_id + and app_user.deleted_at = candidate.generation + and ( + app_user.deletion_fence is null + or app_user.deletion_fence = expected_fence + ); + if not found then + delete from public.v2_user_deletion_jobs job where job.id = candidate.id; + return query select 'stale'::text, candidate.id, candidate.user_id, + candidate.continuation; + elsif candidate.status = 'leased' + and candidate.failure_count + 1 >= p_max_failures then + return query + update public.v2_user_deletion_jobs job + set continuation = job.continuation + 1, + failure_count = job.failure_count + 1, + last_error_code = 'user_deletion_lease_expired', + lease_expires_at = null, + lease_token = null, + status = 'quarantined' + where job.id = candidate.id + returning 'quarantined'::text, job.id, job.user_id, job.continuation; + else + return query + update public.v2_user_deletion_jobs job + set continuation = case when candidate.status = 'leased' + then job.continuation + 1 else job.continuation end, + failure_count = case when candidate.status = 'leased' + then job.failure_count + 1 else job.failure_count end, + last_error_code = case when candidate.status = 'leased' + then 'user_deletion_lease_expired' else job.last_error_code end, + lease_expires_at = p_now + interval '2 hours', + lease_token = p_lease_token, + next_attempt_at = case when candidate.status = 'leased' + then p_now else job.next_attempt_at end, + status = 'leased' + where job.id = candidate.id + returning 'leased'::text, job.id, job.user_id, job.continuation; + end if; + end loop; +end +$$; + + +-- +-- Name: webhooks_discover_resource_deletion_jobs(integer); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_discover_resource_deletion_jobs(p_limit integer) RETURNS TABLE(projects integer, threads integer) + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + project_count integer; + page_size integer := greatest(1, least(coalesce(p_limit, 1), 25)); + thread_count integer; +begin + with candidates as ( + select project.user_id, project.id, project.deleted_at + from public.v2_projects project + join public.v2_users app_user on app_user.id = project.user_id + where project.deleted_at is not null and app_user.deleted_at is null + order by project.deleted_at, project.id + limit page_size + ), inserted as ( + insert into public.v2_resource_deletion_jobs (user_id, kind, resource_id, generation) + select candidate.user_id, 'project-deletion', candidate.id, candidate.deleted_at + from candidates candidate + on conflict (kind, resource_id, generation) do nothing + returning id + ) select count(*)::integer into project_count from inserted; + + with candidates as ( + select thread.user_id, thread.id, thread.deleted_at + from public.v2_threads thread + join public.v2_users app_user on app_user.id = thread.user_id + left join public.v2_projects project + on project.id = thread.project_id and project.user_id = thread.user_id + where thread.deleted_at is not null + and app_user.deleted_at is null + and (thread.project_id is null or project.deleted_at is null) + order by thread.deleted_at, thread.id + limit page_size + ), inserted as ( + insert into public.v2_resource_deletion_jobs (user_id, kind, resource_id, generation) + select candidate.user_id, 'thread-deletion', candidate.id, candidate.deleted_at + from candidates candidate + on conflict (kind, resource_id, generation) do nothing + returning id + ) select count(*)::integer into thread_count from inserted; + return query select project_count, thread_count; +end +$$; + + +-- +-- Name: webhooks_discover_user_deletion_jobs(timestamp with time zone, integer); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_discover_user_deletion_jobs(p_before timestamp with time zone, p_limit integer) RETURNS integer + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + discovered integer; + page_size integer := greatest(1, least(coalesce(p_limit, 1), 25)); +begin + if p_before is null then + raise exception 'invalid user-deletion discovery cutoff'; + end if; + if not pg_catalog.pg_try_advisory_xact_lock( + pg_catalog.hashtextextended('cheatcode:database-maintenance:v1', 0) + ) then + return 0; + end if; + with candidates as ( + select app_user.id, app_user.deleted_at + from public.v2_users app_user + where app_user.deleted_at <= p_before + and ( + app_user.deletion_fence is null + or app_user.deletion_fence = ( + pg_catalog.trunc(extract(epoch from app_user.deleted_at) * 1000)::bigint + )::text + ) + and not exists ( + select 1 + from public.v2_user_deletion_jobs existing + where existing.user_id = app_user.id + and existing.generation = app_user.deleted_at + ) + order by app_user.deleted_at, app_user.id + limit page_size + ), inserted as ( + insert into public.v2_user_deletion_jobs (user_id, generation) + select candidate.id, candidate.deleted_at + from candidates candidate + on conflict (user_id, generation) do nothing + returning id + ) + select count(*)::integer into discovered from inserted; + return discovered; +end +$$; + + +-- +-- Name: webhooks_expire_composio_connection(text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_expire_composio_connection(p_connection_id text) RETURNS boolean + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + target record; +begin + select connection.user_id, connection.integration + into target + from public.v2_user_integrations connection + where connection.composio_connection_id = p_connection_id + for update; + if not found then + return false; + end if; + perform pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended(target.user_id::text || ':' || target.integration, 0) + ); + update public.v2_user_integrations connection + set status = 'expired', is_default = false + where connection.composio_connection_id = p_connection_id + and (connection.status is distinct from 'expired' or connection.is_default); + update public.v2_user_integrations connection + set is_default = false + where connection.user_id = target.user_id + and connection.integration = target.integration + and connection.is_default + and lower(connection.status) not in ('active', 'authorized', 'connected', 'enabled'); + update public.v2_user_integrations connection + set is_default = true + where connection.composio_connection_id = ( + select candidate.composio_connection_id + from public.v2_user_integrations candidate + where candidate.user_id = target.user_id + and candidate.integration = target.integration + and lower(candidate.status) in ('active', 'authorized', 'connected', 'enabled') + order by candidate.updated_at desc, candidate.composio_connection_id + limit 1 + ) and not exists ( + select 1 from public.v2_user_integrations existing + where existing.user_id = target.user_id + and existing.integration = target.integration + and existing.is_default + ); + return true; +end +$$; + + +-- +-- Name: webhooks_finalize_current_user_deletion(text, text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_finalize_current_user_deletion(p_deletion_fence text, p_clerk_identity_hash text) RETURNS boolean + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $_$ +declare + actor_id uuid := public.current_app_user(); + deleted_id uuid; +begin + if p_deletion_fence is null or p_deletion_fence = '' + or p_clerk_identity_hash !~ '^[0-9a-f]{64}$' then + raise exception 'invalid user-deletion finalization identity'; + end if; + perform pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended('cheatcode:clerk-identity:' || p_clerk_identity_hash, 0) + ); + if exists ( + select 1 from public.v2_deleted_clerk_identities retired + where retired.clerk_identity_hash = p_clerk_identity_hash + ) then + return false; + end if; + if not exists ( + select 1 from public.v2_users app_user + where app_user.id = actor_id and app_user.deletion_fence = p_deletion_fence + ) then + raise exception 'user deletion fence is no longer valid'; + end if; + insert into public.v2_deleted_clerk_identities (clerk_identity_hash) + values (p_clerk_identity_hash); + delete from public.v2_users app_user + where app_user.id = actor_id and app_user.deletion_fence = p_deletion_fence + returning app_user.id into deleted_id; + if deleted_id is null then + raise exception 'claimed user deletion did not remove exactly one user'; + end if; + return true; +end +$_$; + + +-- +-- Name: webhooks_list_daily_activation_events(date, text, uuid, integer); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_list_daily_activation_events(p_day date, p_cursor_event text, p_cursor_user_id uuid, p_limit integer) RETURNS TABLE(event_order integer, event_name text, user_id uuid, cohort_week text, cohort_month text) + LANGUAGE sql STABLE SECURITY DEFINER + SET search_path TO '' + AS $$ + with bounded as ( + select greatest(1, least(coalesce(p_limit, 1), 200)) as page_size, + case + when p_cursor_event is null then null + when p_cursor_event = 'retention_d7' then 1 + when p_cursor_event = 'retention_d28' then 2 + when p_cursor_event = 'first_week_mau' then 3 + else -1 + end as cursor_order + ), activation_events as ( + select 1 as event_order, 'retention_d7'::text as event_name, + candidate.id as user_id, + to_char(date_trunc('week', candidate.created_at), 'YYYY-MM-DD') as cohort_week, + to_char(date_trunc('month', candidate.created_at), 'YYYY-MM-DD') as cohort_month + from public.v2_users candidate + where candidate.deleted_at is null + and candidate.created_at >= p_day - interval '7 days' + and candidate.created_at < p_day - interval '6 days' + and exists ( + select 1 from public.v2_agent_runs run + where run.user_id = candidate.id + and run.started_at >= p_day + and run.started_at < p_day + interval '1 day' + ) + union all + select 2, 'retention_d28'::text, candidate.id, + to_char(date_trunc('week', candidate.created_at), 'YYYY-MM-DD'), + to_char(date_trunc('month', candidate.created_at), 'YYYY-MM-DD') + from public.v2_users candidate + where candidate.deleted_at is null + and candidate.created_at >= p_day - interval '28 days' + and candidate.created_at < p_day - interval '27 days' + and exists ( + select 1 from public.v2_agent_runs run + where run.user_id = candidate.id + and run.started_at >= p_day + and run.started_at < p_day + interval '1 day' + ) + union all + select 3, 'first_week_mau'::text, candidate.id, + to_char(date_trunc('week', candidate.created_at), 'YYYY-MM-DD'), null::text + from public.v2_users candidate + where candidate.deleted_at is null + and candidate.created_at >= p_day - interval '7 days' + and candidate.created_at < p_day - interval '6 days' + and ( + select count(*) from public.v2_agent_runs run + where run.user_id = candidate.id + and run.started_at >= candidate.created_at + and run.started_at < candidate.created_at + interval '7 days' + ) >= 3 + ) + select event.event_order, event.event_name, event.user_id, + event.cohort_week, event.cohort_month + from activation_events event, bounded + where (bounded.cursor_order is null and p_cursor_user_id is null) + or ( + bounded.cursor_order > 0 + and p_cursor_user_id is not null + and (event.event_order, event.user_id) > (bounded.cursor_order, p_cursor_user_id) + ) + order by event.event_order, event.user_id + limit (select page_size + 1 from bounded) +$$; + + +-- +-- Name: webhooks_mark_clerk_user_deleted(text, timestamp with time zone); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_mark_clerk_user_deleted(p_clerk_id text, p_deleted_at timestamp with time zone) RETURNS uuid + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $$ +declare + identity_hash text; + deleted_user_id uuid; +begin + if p_clerk_id is null or btrim(p_clerk_id) = '' or p_deleted_at is null then + raise exception 'invalid Clerk deletion payload'; + end if; + identity_hash := pg_catalog.encode( + extensions.digest(pg_catalog.convert_to(p_clerk_id, 'UTF8'), 'sha256'), + 'hex' + ); + perform pg_catalog.pg_advisory_xact_lock( + pg_catalog.hashtextextended('cheatcode:clerk-identity:' || identity_hash, 0) + ); + update public.v2_users app_user + set deleted_at = coalesce(app_user.deleted_at, p_deleted_at), + deletion_fence = null + where app_user.clerk_id = p_clerk_id and app_user.deletion_fence is null + returning app_user.id into deleted_user_id; + return deleted_user_id; +end +$$; + + +-- +-- Name: webhooks_record_user_deletion_refund_evidence(uuid, timestamp with time zone, integer, uuid, text, text, integer, text, text, text, text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_record_user_deletion_refund_evidence(p_job_id uuid, p_generation timestamp with time zone, p_continuation integer, p_lease_token uuid, p_cursor text, p_order_id text, p_amount integer, p_currency text, p_idempotency_key text, p_provider_refund_id text, p_provider_status text) RETURNS TABLE(job_id uuid, user_id uuid, generation timestamp with time zone, order_id text, amount integer, currency text, idempotency_key text, provider_refund_id text, provider_status text, created_at timestamp with time zone, reconciled_at timestamp with time zone) + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $_$ +declare + actor_id uuid := public.current_app_user(); + current_intent public.v2_user_deletion_refund_intents%rowtype; +begin + if actor_id is null or p_job_id is null or p_generation is null + or p_continuation is null or p_continuation < 0 + or p_lease_token is null or p_order_id is null or btrim(p_order_id) = '' + or p_amount is null or p_amount < 1 + or p_currency is null or p_currency !~ '^[a-z]{3}$' + or p_idempotency_key is null or p_idempotency_key = '' + or p_provider_refund_id is null or btrim(p_provider_refund_id) = '' + or p_provider_status is null + or p_provider_status not in ('pending', 'succeeded', 'failed', 'canceled') then + raise exception 'invalid user-deletion refund evidence'; + end if; + + perform 1 + from public.v2_user_deletion_jobs deletion_job + where deletion_job.id = p_job_id + and deletion_job.user_id = actor_id + and deletion_job.generation = p_generation + and deletion_job.continuation = p_continuation + and deletion_job.status = 'leased' + and deletion_job.lease_token = p_lease_token + and deletion_job.phase = 'billing' + and deletion_job.cursor is not distinct from p_cursor + for update; + if not found then + return; + end if; + + select intent.* into current_intent + from public.v2_user_deletion_refund_intents intent + where intent.job_id = p_job_id + and intent.user_id = actor_id + and intent.generation = p_generation + for update; + if not found then + raise exception 'user-deletion refund intent is missing'; + end if; + + if current_intent.order_id <> p_order_id + or current_intent.amount <> p_amount + or current_intent.currency <> p_currency + or current_intent.idempotency_key <> p_idempotency_key then + raise exception 'user-deletion refund immutable identity changed'; + end if; + if current_intent.provider_refund_id is not null + and current_intent.provider_refund_id <> p_provider_refund_id then + raise exception 'user-deletion provider refund identity changed'; + end if; + if current_intent.provider_status is not null + and current_intent.provider_status <> 'pending' + and current_intent.provider_status <> p_provider_status then + raise exception 'user-deletion provider refund status regressed'; + end if; + + update public.v2_user_deletion_refund_intents intent + set provider_refund_id = p_provider_refund_id, + provider_status = p_provider_status, + reconciled_at = now() + where intent.job_id = p_job_id; + + return query + select intent.job_id, + intent.user_id, + intent.generation, + intent.order_id, + intent.amount, + intent.currency, + intent.idempotency_key, + intent.provider_refund_id, + intent.provider_status, + intent.created_at, + intent.reconciled_at + from public.v2_user_deletion_refund_intents intent + where intent.job_id = p_job_id; +end +$_$; + + +-- +-- Name: webhooks_reserve_user_deletion_refund_intent(uuid, timestamp with time zone, integer, uuid, text, text, integer, text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_reserve_user_deletion_refund_intent(p_job_id uuid, p_generation timestamp with time zone, p_continuation integer, p_lease_token uuid, p_cursor text, p_order_id text, p_amount integer, p_currency text) RETURNS TABLE(job_id uuid, user_id uuid, generation timestamp with time zone, order_id text, amount integer, currency text, idempotency_key text, provider_refund_id text, provider_status text, created_at timestamp with time zone, reconciled_at timestamp with time zone) + LANGUAGE plpgsql SECURITY DEFINER + SET search_path TO '' + AS $_$ +declare + actor_id uuid := public.current_app_user(); +begin + if actor_id is null or p_job_id is null or p_generation is null + or p_continuation is null or p_continuation < 0 + or p_lease_token is null or p_order_id is null or btrim(p_order_id) = '' + or p_amount is null or p_amount < 1 + or p_currency is null or p_currency !~ '^[a-z]{3}$' then + raise exception 'invalid user-deletion refund reservation'; + end if; + + perform 1 + from public.v2_user_deletion_jobs deletion_job + where deletion_job.id = p_job_id + and deletion_job.user_id = actor_id + and deletion_job.generation = p_generation + and deletion_job.continuation = p_continuation + and deletion_job.status = 'leased' + and deletion_job.lease_token = p_lease_token + and deletion_job.phase = 'billing' + and deletion_job.cursor is not distinct from p_cursor + for update; + if not found then + return; + end if; + + insert into public.v2_user_deletion_refund_intents ( + job_id, + user_id, + generation, + order_id, + amount, + currency, + idempotency_key + ) values ( + p_job_id, + actor_id, + p_generation, + p_order_id, + p_amount, + p_currency, + 'cheatcode:user-deletion-refund:' || p_job_id::text + ) + on conflict on constraint v2_user_deletion_refund_intents_pkey do nothing; + + return query + select intent.job_id, + intent.user_id, + intent.generation, + intent.order_id, + intent.amount, + intent.currency, + intent.idempotency_key, + intent.provider_refund_id, + intent.provider_status, + intent.created_at, + intent.reconciled_at + from public.v2_user_deletion_refund_intents intent + where intent.job_id = p_job_id + and intent.user_id = actor_id + and intent.generation = p_generation; +end +$_$; + + +-- +-- Name: webhooks_resolve_polar_customer(text); Type: FUNCTION; Schema: public; Owner: - +-- + +CREATE FUNCTION public.webhooks_resolve_polar_customer(p_polar_customer_id text) RETURNS TABLE(user_id uuid, email text, polar_customer_id text) + LANGUAGE sql STABLE SECURITY DEFINER + SET search_path TO '' + AS $$ + select app_user.id, app_user.email, app_user.polar_customer_id + from public.v2_users app_user + where app_user.polar_customer_id = p_polar_customer_id + and app_user.deleted_at is null + limit 1 +$$; + + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- Name: _audit_archive_manifest; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public._audit_archive_manifest ( + partition_name text NOT NULL, + month_start date NOT NULL, + bucket text NOT NULL, + format_version integer DEFAULT 1 NOT NULL, + object_key text, + row_count bigint, + size_bytes bigint, + sha256 text, + state text NOT NULL, + detached_at timestamp with time zone NOT NULL, + verified_at timestamp with time zone, + dropped_at timestamp with time zone, + CONSTRAINT _audit_archive_manifest_bucket_check CHECK ((bucket ~ '^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$'::text)), + CONSTRAINT _audit_archive_manifest_check CHECK (((object_key IS NULL) OR (object_key ~ (('^[0-9]{4}-(0[1-9]|1[0-2])/audit_log-'::text || sha256) || '\.ndjson\.gz$'::text)))), + CONSTRAINT _audit_archive_manifest_check1 CHECK ((((state = 'detached'::text) AND (object_key IS NULL) AND (row_count IS NULL) AND (size_bytes IS NULL) AND (sha256 IS NULL) AND (verified_at IS NULL) AND (dropped_at IS NULL)) OR ((state = 'verified'::text) AND (object_key IS NOT NULL) AND (row_count IS NOT NULL) AND (size_bytes IS NOT NULL) AND (sha256 IS NOT NULL) AND (verified_at IS NOT NULL) AND (dropped_at IS NULL)) OR ((state = 'dropped'::text) AND (object_key IS NOT NULL) AND (row_count IS NOT NULL) AND (size_bytes IS NOT NULL) AND (sha256 IS NOT NULL) AND (verified_at IS NOT NULL) AND (dropped_at IS NOT NULL)))), + CONSTRAINT _audit_archive_manifest_format_version_check CHECK ((format_version = 1)), + CONSTRAINT _audit_archive_manifest_partition_name_check CHECK ((partition_name ~ '^v2_audit_log_[0-9]{4}_(0[1-9]|1[0-2])$'::text)), + CONSTRAINT _audit_archive_manifest_row_count_check CHECK ((row_count >= 0)), + CONSTRAINT _audit_archive_manifest_sha256_check CHECK ((sha256 ~ '^[0-9a-f]{64}$'::text)), + CONSTRAINT _audit_archive_manifest_size_bytes_check CHECK ((size_bytes >= 0)), + CONSTRAINT _audit_archive_manifest_state_check CHECK ((state = ANY (ARRAY['detached'::text, 'verified'::text, 'dropped'::text]))) +); + + +-- +-- Name: v2_agent_runs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_agent_runs ( + id uuid DEFAULT public.uuidv7() NOT NULL, + thread_id uuid NOT NULL, + user_id uuid NOT NULL, + status text NOT NULL, + model_id text NOT NULL, + started_at timestamp with time zone DEFAULT now() NOT NULL, + finished_at timestamp with time zone, + idempotency_key_hash text, + request_body_hash text, + CONSTRAINT v2_agent_runs_finished_order_check CHECK (((finished_at IS NULL) OR (finished_at >= started_at))), + CONSTRAINT v2_agent_runs_idempotency_key_hash_check CHECK (((idempotency_key_hash IS NULL) OR (idempotency_key_hash ~ '^[0-9a-f]{64}$'::text))), + CONSTRAINT v2_agent_runs_model_id_canonical_check CHECK (((char_length(model_id) <= 200) AND (model_id ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'::text))), + CONSTRAINT v2_agent_runs_request_body_hash_check CHECK (((request_body_hash IS NULL) OR (request_body_hash ~ '^[0-9a-f]{64}$'::text))), + CONSTRAINT v2_agent_runs_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'running'::text, 'completed'::text, 'failed'::text, 'canceled'::text]))), + CONSTRAINT v2_agent_runs_terminal_timestamp_check CHECK (((status = ANY (ARRAY['completed'::text, 'failed'::text, 'canceled'::text])) = (finished_at IS NOT NULL))) +); + +ALTER TABLE ONLY public.v2_agent_runs FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_artifact_upload_intents; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_artifact_upload_intents ( + id uuid NOT NULL, + user_id uuid NOT NULL, + project_id uuid NOT NULL, + agent_run_id uuid NOT NULL, + r2_key text NOT NULL, + cleanup_not_before timestamp(3) with time zone NOT NULL, + quiesced_at timestamp(3) with time zone, + CONSTRAINT v2_artifact_upload_intents_r2_identity_check CHECK (((r2_key ~~ ((((((((user_id)::text || '/'::text) || (project_id)::text) || '/'::text) || (agent_run_id)::text) || '/'::text) || (id)::text) || '-%'::text)) AND (strpos(substr(r2_key, (length(((((((((user_id)::text || '/'::text) || (project_id)::text) || '/'::text) || (agent_run_id)::text) || '/'::text) || (id)::text) || '-'::text)) + 1)), '/'::text) = 0) AND (octet_length(r2_key) <= 512))) +); + +ALTER TABLE ONLY public.v2_artifact_upload_intents FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_audit_log; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +) +PARTITION BY RANGE (created_at); + +ALTER TABLE ONLY public.v2_audit_log FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_audit_log_2026_04; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_04 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2026_05; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_05 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2026_06; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_06 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2026_07; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_07 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + +ALTER TABLE ONLY public.v2_audit_log_2026_07 FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_audit_log_2026_08; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_08 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + +ALTER TABLE ONLY public.v2_audit_log_2026_08 FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_audit_log_2026_09; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_09 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + +ALTER TABLE ONLY public.v2_audit_log_2026_09 FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_audit_log_2026_10; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_10 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + +ALTER TABLE ONLY public.v2_audit_log_2026_10 FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_audit_log_2026_11; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_11 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2026_12; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2026_12 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_01; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_01 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_02; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_02 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_03; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_03 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_04; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_04 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_05; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_05 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_06; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_06 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_07; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_07 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_08; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_08 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_09; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_09 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_10; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_10 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_11; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_11 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2027_12; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2027_12 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2028_01; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2028_01 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2028_02; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2028_02 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2028_03; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2028_03 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2028_04; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2028_04 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_audit_log_2028_05; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_audit_log_2028_05 ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid, + action text NOT NULL, + resource_type text, + resource_id text, + metadata jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL +); + + +-- +-- Name: v2_daily_maintenance_jobs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_daily_maintenance_jobs ( + day date NOT NULL, + scheduled_at timestamp(3) with time zone NOT NULL, + phase text DEFAULT 'activation'::text NOT NULL, + activation_cursor_event text, + activation_cursor_user_id uuid, + continuation integer DEFAULT 0 NOT NULL, + status text DEFAULT 'queued'::text NOT NULL, + release_version_id uuid, + lease_token uuid, + lease_expires_at timestamp(3) with time zone, + failure_count integer DEFAULT 0 NOT NULL, + next_attempt_at timestamp(3) with time zone DEFAULT now() NOT NULL, + last_error_code text, + completed_at timestamp(3) with time zone, + CONSTRAINT v2_daily_maintenance_jobs_activation_cursor_check CHECK ((((activation_cursor_event IS NULL) AND (activation_cursor_user_id IS NULL)) OR ((phase = 'activation'::text) AND (activation_cursor_event = ANY (ARRAY['retention_d7'::text, 'retention_d28'::text, 'first_week_mau'::text])) AND (activation_cursor_user_id IS NOT NULL)))), + CONSTRAINT v2_daily_maintenance_jobs_counter_check CHECK (((continuation >= 0) AND (failure_count >= 0))), + CONSTRAINT v2_daily_maintenance_jobs_day_check CHECK ((day = (((scheduled_at AT TIME ZONE 'UTC'::text))::date - 1))), + CONSTRAINT v2_daily_maintenance_jobs_error_code_check CHECK (((last_error_code IS NULL) OR (octet_length(last_error_code) <= 128))), + CONSTRAINT v2_daily_maintenance_jobs_lease_check CHECK ((((status = 'leased'::text) AND (release_version_id IS NOT NULL) AND (lease_token IS NOT NULL) AND (lease_expires_at IS NOT NULL) AND (completed_at IS NULL)) OR ((status = 'queued'::text) AND (release_version_id IS NULL) AND (lease_token IS NULL) AND (lease_expires_at IS NULL) AND (completed_at IS NULL)) OR ((status = 'complete'::text) AND (release_version_id IS NULL) AND (lease_token IS NULL) AND (lease_expires_at IS NULL) AND (completed_at IS NOT NULL)))), + CONSTRAINT v2_daily_maintenance_jobs_phase_check CHECK ((phase = ANY (ARRAY['activation'::text, 'orphan-upload-cleanup'::text]))), + CONSTRAINT v2_daily_maintenance_jobs_phase_cursor_check CHECK (((phase = 'activation'::text) OR ((phase = 'orphan-upload-cleanup'::text) AND (activation_cursor_event IS NULL) AND (activation_cursor_user_id IS NULL)))), + CONSTRAINT v2_daily_maintenance_jobs_status_check CHECK ((status = ANY (ARRAY['queued'::text, 'leased'::text, 'complete'::text]))), + CONSTRAINT v2_daily_maintenance_jobs_terminal_phase_check CHECK (((status <> 'complete'::text) OR (phase = 'orphan-upload-cleanup'::text))) +); + +ALTER TABLE ONLY public.v2_daily_maintenance_jobs FORCE ROW LEVEL SECURITY; + + +-- +-- Name: TABLE v2_daily_maintenance_jobs; Type: COMMENT; Schema: public; Owner: - +-- + +COMMENT ON TABLE public.v2_daily_maintenance_jobs IS 'Durable daily activation-metric and orphan-upload-cleanup workflow state.'; + + +-- +-- Name: v2_deleted_clerk_identities; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_deleted_clerk_identities ( + clerk_identity_hash text NOT NULL, + CONSTRAINT v2_deleted_clerk_identities_hash_check CHECK ((clerk_identity_hash ~ '^[0-9a-f]{64}$'::text)) +); + +ALTER TABLE ONLY public.v2_deleted_clerk_identities FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_entitlements; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_entitlements ( + user_id uuid NOT NULL, + tier text DEFAULT 'free'::text NOT NULL, + polar_subscription_id text, + subscription_status text DEFAULT 'none'::text NOT NULL, + current_period_start timestamp with time zone, + current_period_end timestamp with time zone, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + cancel_at_period_end boolean DEFAULT false NOT NULL, + CONSTRAINT v2_entitlements_period_order_check CHECK (((current_period_start IS NULL) OR (current_period_end IS NULL) OR (current_period_start <= current_period_end))), + CONSTRAINT v2_entitlements_tier_check CHECK ((tier = ANY (ARRAY['free'::text, 'pro'::text, 'premium'::text, 'ultra'::text, 'max'::text]))) +); + +ALTER TABLE ONLY public.v2_entitlements FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_generated_outputs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_generated_outputs ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid NOT NULL, + agent_run_id uuid NOT NULL, + filename text NOT NULL, + r2_key text NOT NULL, + mime_type text NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT v2_generated_outputs_filename_check CHECK (((btrim(filename) <> ''::text) AND (length(filename) <= 255))), + CONSTRAINT v2_generated_outputs_key_check CHECK (((btrim(r2_key) <> ''::text) AND (length(r2_key) <= 1024))), + CONSTRAINT v2_generated_outputs_mime_type_check CHECK (((btrim(mime_type) <> ''::text) AND (length(mime_type) <= 255))), + CONSTRAINT v2_generated_outputs_r2_identity_check CHECK (((r2_key = (((((((((user_id)::text || '/'::text) || split_part(r2_key, '/'::text, 2)) || '/'::text) || (agent_run_id)::text) || '/'::text) || (id)::text) || '-'::text) || filename)) AND (split_part(r2_key, '/'::text, 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'::text) AND (strpos(filename, '/'::text) = 0))) +); + +ALTER TABLE ONLY public.v2_generated_outputs FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_messages; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_messages ( + id uuid DEFAULT public.uuidv7() NOT NULL, + thread_id uuid NOT NULL, + user_id uuid NOT NULL, + role text NOT NULL, + parts jsonb NOT NULL, + agent_run_id uuid, + created_at timestamp with time zone DEFAULT now() NOT NULL, + agent_run_segment integer DEFAULT 0 NOT NULL, + agent_run_segment_final boolean DEFAULT true NOT NULL, + CONSTRAINT v2_messages_agent_run_segment_check CHECK ((agent_run_segment >= 0)), + CONSTRAINT v2_messages_agent_run_segment_scope_check CHECK ((((agent_run_segment = 0) AND agent_run_segment_final) OR ((role = 'assistant'::text) AND (agent_run_id IS NOT NULL)))), + CONSTRAINT v2_messages_parts_array_check CHECK ((jsonb_typeof(parts) = 'array'::text)), + CONSTRAINT v2_messages_parts_size_check CHECK ((octet_length((parts)::text) <= 196608)), + CONSTRAINT v2_messages_role_check CHECK ((role = ANY (ARRAY['assistant'::text, 'user'::text]))) +); + +ALTER TABLE ONLY public.v2_messages FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_projects; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_projects ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid NOT NULL, + name text NOT NULL, + mode text NOT NULL, + settings jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp(3) with time zone, + over_quota boolean DEFAULT false NOT NULL, + archive_after timestamp with time zone, + workspace_slug text NOT NULL, + CONSTRAINT v2_projects_mode_check CHECK ((mode = ANY (ARRAY['app-builder'::text, 'app-builder-mobile'::text, 'general'::text]))), + CONSTRAINT v2_projects_quota_archive_pair_check CHECK ((over_quota = (archive_after IS NOT NULL))), + CONSTRAINT v2_projects_settings_default_model_check CHECK (((NOT (settings ? 'defaultModel'::text)) OR ((jsonb_typeof((settings -> 'defaultModel'::text)) = 'string'::text) AND (char_length((settings ->> 'defaultModel'::text)) <= 200) AND ((settings ->> 'defaultModel'::text) ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'::text)))), + CONSTRAINT v2_projects_settings_object_check CHECK ((jsonb_typeof(settings) = 'object'::text)), + CONSTRAINT v2_projects_workspace_slug_canonical_check CHECK ((((octet_length(workspace_slug) >= 38) AND (octet_length(workspace_slug) <= 64)) AND ("right"(workspace_slug, 37) = ('-'::text || (id)::text)) AND ("left"(workspace_slug, (length(workspace_slug) - 37)) ~ '^[a-z0-9]+(-[a-z0-9]+)*$'::text))) +); + +ALTER TABLE ONLY public.v2_projects FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_provider_keys; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_provider_keys ( + user_id uuid NOT NULL, + provider text NOT NULL, + vault_secret_id uuid NOT NULL, + fingerprint text NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + disabled_at timestamp with time zone, + disabled_reason text, + last_revalidated_at timestamp with time zone, + revalidation_claimed_at timestamp with time zone, + revalidation_lease_token uuid, + CONSTRAINT v2_provider_keys_disabled_pair_check CHECK ((((disabled_at IS NULL) AND (disabled_reason IS NULL)) OR ((disabled_at IS NOT NULL) AND (disabled_reason IS NOT NULL)))), + CONSTRAINT v2_provider_keys_fingerprint_check CHECK ((fingerprint ~ '^[0-9a-f]{12}$'::text)), + CONSTRAINT v2_provider_keys_provider_check CHECK ((provider = ANY (ARRAY['anthropic'::text, 'openai'::text, 'google'::text, 'openrouter'::text, 'deepseek'::text, 'exa'::text, 'firecrawl'::text]))), + CONSTRAINT v2_provider_keys_revalidation_lease_pair_check CHECK ((((revalidation_claimed_at IS NULL) AND (revalidation_lease_token IS NULL)) OR ((revalidation_claimed_at IS NOT NULL) AND (revalidation_lease_token IS NOT NULL)))) +); + +ALTER TABLE ONLY public.v2_provider_keys FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_resource_deletion_jobs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_resource_deletion_jobs ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid NOT NULL, + kind text NOT NULL, + resource_id uuid NOT NULL, + generation timestamp(3) with time zone NOT NULL, + phase text DEFAULT 'runs'::text NOT NULL, + cursor uuid, + continuation integer DEFAULT 0 NOT NULL, + status text DEFAULT 'queued'::text NOT NULL, + lease_token uuid, + lease_expires_at timestamp(3) with time zone, + failure_count integer DEFAULT 0 NOT NULL, + next_attempt_at timestamp(3) with time zone DEFAULT now() NOT NULL, + last_error_code text, + CONSTRAINT v2_resource_deletion_jobs_counter_check CHECK (((continuation >= 0) AND (failure_count >= 0))), + CONSTRAINT v2_resource_deletion_jobs_kind_check CHECK ((kind = ANY (ARRAY['project-deletion'::text, 'thread-deletion'::text]))), + CONSTRAINT v2_resource_deletion_jobs_lease_check CHECK ((((status = 'leased'::text) AND (lease_token IS NOT NULL) AND (lease_expires_at IS NOT NULL)) OR ((status <> 'leased'::text) AND (lease_token IS NULL) AND (lease_expires_at IS NULL)))), + CONSTRAINT v2_resource_deletion_jobs_phase_check CHECK ((phase = ANY (ARRAY['runs'::text, 'run-objects'::text, 'workspace'::text, 'outputs'::text, 'prefix'::text, 'pointer'::text, 'finalize'::text]))), + CONSTRAINT v2_resource_deletion_jobs_status_check CHECK ((status = ANY (ARRAY['queued'::text, 'leased'::text, 'quarantined'::text]))) +); + +ALTER TABLE ONLY public.v2_resource_deletion_jobs FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_threads; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_threads ( + id uuid DEFAULT public.uuidv7() NOT NULL, + project_id uuid, + user_id uuid NOT NULL, + title text, + active_run_id uuid, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp(3) with time zone, + launch_intent jsonb, + latest_model_id text, + CONSTRAINT v2_threads_latest_model_id_check CHECK (((latest_model_id IS NULL) OR ((char_length(latest_model_id) <= 200) AND (latest_model_id ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'::text)))), + CONSTRAINT v2_threads_launch_default_model_check CHECK (((launch_intent IS NULL) OR (NOT (launch_intent ? 'defaultModel'::text)) OR ((jsonb_typeof((launch_intent -> 'defaultModel'::text)) = 'string'::text) AND (char_length((launch_intent ->> 'defaultModel'::text)) <= 200) AND ((launch_intent ->> 'defaultModel'::text) ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'::text)))), + CONSTRAINT v2_threads_launch_intent_object_check CHECK (((launch_intent IS NULL) OR (jsonb_typeof(launch_intent) = 'object'::text))), + CONSTRAINT v2_threads_project_launch_intent_check CHECK (((project_id IS NULL) OR (launch_intent IS NULL))) +); + +ALTER TABLE ONLY public.v2_threads FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_user_deletion_jobs; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_user_deletion_jobs ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid NOT NULL, + generation timestamp with time zone NOT NULL, + phase text DEFAULT 'runs'::text NOT NULL, + cursor text, + continuation integer DEFAULT 0 NOT NULL, + status text DEFAULT 'queued'::text NOT NULL, + lease_token uuid, + lease_expires_at timestamp(3) with time zone, + failure_count integer DEFAULT 0 NOT NULL, + next_attempt_at timestamp(3) with time zone DEFAULT now() NOT NULL, + last_error_code text, + CONSTRAINT v2_user_deletion_jobs_counter_check CHECK (((continuation >= 0) AND (failure_count >= 0))), + CONSTRAINT v2_user_deletion_jobs_lease_check CHECK ((((status = 'leased'::text) AND (lease_token IS NOT NULL) AND (lease_expires_at IS NOT NULL)) OR ((status <> 'leased'::text) AND (lease_token IS NULL) AND (lease_expires_at IS NULL)))), + CONSTRAINT v2_user_deletion_jobs_phase_check CHECK ((phase = ANY (ARRAY['runs'::text, 'sandbox'::text, 'billing'::text, 'quota'::text, 'integrations'::text, 'objects'::text, 'archive'::text, 'finalize'::text]))), + CONSTRAINT v2_user_deletion_jobs_status_check CHECK ((status = ANY (ARRAY['queued'::text, 'leased'::text, 'quarantined'::text]))) +); + +ALTER TABLE ONLY public.v2_user_deletion_jobs FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_user_deletion_refund_intents; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_user_deletion_refund_intents ( + job_id uuid NOT NULL, + user_id uuid NOT NULL, + generation timestamp with time zone NOT NULL, + order_id text NOT NULL, + amount integer NOT NULL, + currency text NOT NULL, + idempotency_key text NOT NULL, + provider_refund_id text, + provider_status text, + created_at timestamp(3) with time zone DEFAULT now() NOT NULL, + reconciled_at timestamp(3) with time zone, + CONSTRAINT v2_user_deletion_refund_intents_amount_check CHECK ((amount > 0)), + CONSTRAINT v2_user_deletion_refund_intents_currency_check CHECK ((currency ~ '^[a-z]{3}$'::text)), + CONSTRAINT v2_user_deletion_refund_intents_identity_check CHECK ((idempotency_key = ('cheatcode:user-deletion-refund:'::text || (job_id)::text))), + CONSTRAINT v2_user_deletion_refund_intents_order_check CHECK ((length(btrim(order_id)) > 0)), + CONSTRAINT v2_user_deletion_refund_intents_provider_check CHECK ((((provider_refund_id IS NULL) AND (provider_status IS NULL) AND (reconciled_at IS NULL)) OR ((provider_refund_id IS NOT NULL) AND (length(btrim(provider_refund_id)) > 0) AND (provider_status IS NOT NULL) AND (provider_status = ANY (ARRAY['pending'::text, 'succeeded'::text, 'failed'::text, 'canceled'::text])) AND (reconciled_at IS NOT NULL)))) +); + +ALTER TABLE ONLY public.v2_user_deletion_refund_intents FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_user_integrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_user_integrations ( + user_id uuid NOT NULL, + integration text NOT NULL, + composio_connection_id text NOT NULL, + status text NOT NULL, + connected_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + is_default boolean DEFAULT false NOT NULL, + CONSTRAINT v2_user_integrations_connection_id_check CHECK (((composio_connection_id = btrim(composio_connection_id)) AND ((length(composio_connection_id) >= 1) AND (length(composio_connection_id) <= 256)))), + CONSTRAINT v2_user_integrations_default_active_check CHECK (((NOT is_default) OR (lower(status) = ANY (ARRAY['active'::text, 'authorized'::text, 'connected'::text, 'enabled'::text])))), + CONSTRAINT v2_user_integrations_integration_check CHECK ((integration ~ '^[a-z0-9_]{1,64}$'::text)) +); + +ALTER TABLE ONLY public.v2_user_integrations FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_user_profiles; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_user_profiles ( + user_id uuid NOT NULL, + agent_display_name text, + global_memory text, + disabled_models jsonb DEFAULT '[]'::jsonb NOT NULL, + onboarding_completed_at timestamp with time zone, + onboarding_state jsonb DEFAULT '{}'::jsonb NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT v2_user_profiles_disabled_models_array_check CHECK ((jsonb_typeof(disabled_models) = 'array'::text)), + CONSTRAINT v2_user_profiles_onboarding_state_object_check CHECK ((jsonb_typeof(onboarding_state) = 'object'::text)) +); + +ALTER TABLE ONLY public.v2_user_profiles FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_user_skills; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_user_skills ( + id uuid DEFAULT public.uuidv7() NOT NULL, + user_id uuid NOT NULL, + name text NOT NULL, + description text NOT NULL, + category text NOT NULL, + tags jsonb DEFAULT '[]'::jsonb NOT NULL, + body text NOT NULL, + created_at timestamp with time zone DEFAULT now() NOT NULL, + updated_at timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT v2_user_skills_tags_array_check CHECK ((jsonb_typeof(tags) = 'array'::text)) +); + +ALTER TABLE ONLY public.v2_user_skills FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_users; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.v2_users ( + id uuid DEFAULT public.uuidv7() NOT NULL, + clerk_id text NOT NULL, + email text NOT NULL, + polar_customer_id text, + created_at timestamp with time zone DEFAULT now() NOT NULL, + deleted_at timestamp with time zone, + display_name text, + avatar_url text, + deletion_fence text, + first_artifact_at timestamp with time zone, + clerk_updated_at_ms bigint NOT NULL, + CONSTRAINT v2_users_clerk_updated_at_ms_check CHECK (((clerk_updated_at_ms >= 0) AND (clerk_updated_at_ms <= '9007199254740991'::bigint))) +); + +ALTER TABLE ONLY public.v2_users FORCE ROW LEVEL SECURITY; + + +-- +-- Name: v2_audit_log_2026_04; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_04 FOR VALUES FROM ('2026-04-01 00:00:00+00') TO ('2026-05-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2026_05; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_05 FOR VALUES FROM ('2026-05-01 00:00:00+00') TO ('2026-06-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2026_06; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_06 FOR VALUES FROM ('2026-06-01 00:00:00+00') TO ('2026-07-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2026_07; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_07 FOR VALUES FROM ('2026-07-01 00:00:00+00') TO ('2026-08-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2026_08; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_08 FOR VALUES FROM ('2026-08-01 00:00:00+00') TO ('2026-09-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2026_09; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_09 FOR VALUES FROM ('2026-09-01 00:00:00+00') TO ('2026-10-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2026_10; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_10 FOR VALUES FROM ('2026-10-01 00:00:00+00') TO ('2026-11-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2026_11; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_11 FOR VALUES FROM ('2026-11-01 00:00:00+00') TO ('2026-12-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2026_12; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2026_12 FOR VALUES FROM ('2026-12-01 00:00:00+00') TO ('2027-01-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_01; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_01 FOR VALUES FROM ('2027-01-01 00:00:00+00') TO ('2027-02-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_02; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_02 FOR VALUES FROM ('2027-02-01 00:00:00+00') TO ('2027-03-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_03; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_03 FOR VALUES FROM ('2027-03-01 00:00:00+00') TO ('2027-04-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_04; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_04 FOR VALUES FROM ('2027-04-01 00:00:00+00') TO ('2027-05-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_05; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_05 FOR VALUES FROM ('2027-05-01 00:00:00+00') TO ('2027-06-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_06; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_06 FOR VALUES FROM ('2027-06-01 00:00:00+00') TO ('2027-07-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_07; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_07 FOR VALUES FROM ('2027-07-01 00:00:00+00') TO ('2027-08-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_08; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_08 FOR VALUES FROM ('2027-08-01 00:00:00+00') TO ('2027-09-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_09; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_09 FOR VALUES FROM ('2027-09-01 00:00:00+00') TO ('2027-10-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_10; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_10 FOR VALUES FROM ('2027-10-01 00:00:00+00') TO ('2027-11-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_11; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_11 FOR VALUES FROM ('2027-11-01 00:00:00+00') TO ('2027-12-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2027_12; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2027_12 FOR VALUES FROM ('2027-12-01 00:00:00+00') TO ('2028-01-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2028_01; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2028_01 FOR VALUES FROM ('2028-01-01 00:00:00+00') TO ('2028-02-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2028_02; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2028_02 FOR VALUES FROM ('2028-02-01 00:00:00+00') TO ('2028-03-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2028_03; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2028_03 FOR VALUES FROM ('2028-03-01 00:00:00+00') TO ('2028-04-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2028_04; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2028_04 FOR VALUES FROM ('2028-04-01 00:00:00+00') TO ('2028-05-01 00:00:00+00'); + + +-- +-- Name: v2_audit_log_2028_05; Type: TABLE ATTACH; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log ATTACH PARTITION public.v2_audit_log_2028_05 FOR VALUES FROM ('2028-05-01 00:00:00+00') TO ('2028-06-01 00:00:00+00'); + + +-- +-- Name: _audit_archive_manifest _audit_archive_manifest_month_start_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public._audit_archive_manifest + ADD CONSTRAINT _audit_archive_manifest_month_start_key UNIQUE (month_start); + + +-- +-- Name: _audit_archive_manifest _audit_archive_manifest_object_key_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public._audit_archive_manifest + ADD CONSTRAINT _audit_archive_manifest_object_key_key UNIQUE (object_key); + + +-- +-- Name: _audit_archive_manifest _audit_archive_manifest_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public._audit_archive_manifest + ADD CONSTRAINT _audit_archive_manifest_pkey PRIMARY KEY (partition_name); + + +-- +-- Name: v2_agent_runs v2_agent_runs_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_agent_runs + ADD CONSTRAINT v2_agent_runs_id_user_id_key UNIQUE (id, user_id); + + +-- +-- Name: v2_agent_runs v2_agent_runs_id_user_id_thread_id_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_agent_runs + ADD CONSTRAINT v2_agent_runs_id_user_id_thread_id_key UNIQUE (id, user_id, thread_id); + + +-- +-- Name: v2_agent_runs v2_agent_runs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_agent_runs + ADD CONSTRAINT v2_agent_runs_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_artifact_upload_intents + ADD CONSTRAINT v2_artifact_upload_intents_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_r2_key_unique; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_artifact_upload_intents + ADD CONSTRAINT v2_artifact_upload_intents_r2_key_unique UNIQUE (r2_key); + + +-- +-- Name: v2_audit_log v2_audit_log_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log + ADD CONSTRAINT v2_audit_log_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_04 v2_audit_log_2026_04_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_04 + ADD CONSTRAINT v2_audit_log_2026_04_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_05 v2_audit_log_2026_05_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_05 + ADD CONSTRAINT v2_audit_log_2026_05_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_06 v2_audit_log_2026_06_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_06 + ADD CONSTRAINT v2_audit_log_2026_06_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_07 v2_audit_log_2026_07_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_07 + ADD CONSTRAINT v2_audit_log_2026_07_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_08 v2_audit_log_2026_08_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_08 + ADD CONSTRAINT v2_audit_log_2026_08_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_09 v2_audit_log_2026_09_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_09 + ADD CONSTRAINT v2_audit_log_2026_09_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_10 v2_audit_log_2026_10_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_10 + ADD CONSTRAINT v2_audit_log_2026_10_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_11 v2_audit_log_2026_11_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_11 + ADD CONSTRAINT v2_audit_log_2026_11_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2026_12 v2_audit_log_2026_12_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2026_12 + ADD CONSTRAINT v2_audit_log_2026_12_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_01 v2_audit_log_2027_01_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_01 + ADD CONSTRAINT v2_audit_log_2027_01_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_02 v2_audit_log_2027_02_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_02 + ADD CONSTRAINT v2_audit_log_2027_02_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_03 v2_audit_log_2027_03_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_03 + ADD CONSTRAINT v2_audit_log_2027_03_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_04 v2_audit_log_2027_04_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_04 + ADD CONSTRAINT v2_audit_log_2027_04_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_05 v2_audit_log_2027_05_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_05 + ADD CONSTRAINT v2_audit_log_2027_05_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_06 v2_audit_log_2027_06_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_06 + ADD CONSTRAINT v2_audit_log_2027_06_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_07 v2_audit_log_2027_07_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_07 + ADD CONSTRAINT v2_audit_log_2027_07_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_08 v2_audit_log_2027_08_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_08 + ADD CONSTRAINT v2_audit_log_2027_08_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_09 v2_audit_log_2027_09_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_09 + ADD CONSTRAINT v2_audit_log_2027_09_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_10 v2_audit_log_2027_10_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_10 + ADD CONSTRAINT v2_audit_log_2027_10_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_11 v2_audit_log_2027_11_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_11 + ADD CONSTRAINT v2_audit_log_2027_11_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2027_12 v2_audit_log_2027_12_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2027_12 + ADD CONSTRAINT v2_audit_log_2027_12_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2028_01 v2_audit_log_2028_01_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2028_01 + ADD CONSTRAINT v2_audit_log_2028_01_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2028_02 v2_audit_log_2028_02_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2028_02 + ADD CONSTRAINT v2_audit_log_2028_02_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2028_03 v2_audit_log_2028_03_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2028_03 + ADD CONSTRAINT v2_audit_log_2028_03_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2028_04 v2_audit_log_2028_04_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2028_04 + ADD CONSTRAINT v2_audit_log_2028_04_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_audit_log_2028_05 v2_audit_log_2028_05_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_audit_log_2028_05 + ADD CONSTRAINT v2_audit_log_2028_05_pkey PRIMARY KEY (id, created_at); + + +-- +-- Name: v2_daily_maintenance_jobs v2_daily_maintenance_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_daily_maintenance_jobs + ADD CONSTRAINT v2_daily_maintenance_jobs_pkey PRIMARY KEY (day); + + +-- +-- Name: v2_deleted_clerk_identities v2_deleted_clerk_identities_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_deleted_clerk_identities + ADD CONSTRAINT v2_deleted_clerk_identities_pkey PRIMARY KEY (clerk_identity_hash); + + +-- +-- Name: v2_entitlements v2_entitlements_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_entitlements + ADD CONSTRAINT v2_entitlements_pkey PRIMARY KEY (user_id); + + +-- +-- Name: v2_generated_outputs v2_generated_outputs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_generated_outputs + ADD CONSTRAINT v2_generated_outputs_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_generated_outputs v2_generated_outputs_r2_key_unique; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_generated_outputs + ADD CONSTRAINT v2_generated_outputs_r2_key_unique UNIQUE (r2_key); + + +-- +-- Name: v2_messages v2_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_messages + ADD CONSTRAINT v2_messages_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_projects v2_projects_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_projects + ADD CONSTRAINT v2_projects_id_user_id_key UNIQUE (id, user_id); + + +-- +-- Name: v2_projects v2_projects_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_projects + ADD CONSTRAINT v2_projects_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_provider_keys v2_provider_keys_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_provider_keys + ADD CONSTRAINT v2_provider_keys_pkey PRIMARY KEY (user_id, provider); + + +-- +-- Name: v2_resource_deletion_jobs v2_resource_deletion_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_resource_deletion_jobs + ADD CONSTRAINT v2_resource_deletion_jobs_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_threads v2_threads_id_user_id_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_threads + ADD CONSTRAINT v2_threads_id_user_id_key UNIQUE (id, user_id); + + +-- +-- Name: v2_threads v2_threads_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_threads + ADD CONSTRAINT v2_threads_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_user_deletion_jobs v2_user_deletion_jobs_id_user_generation_key; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_deletion_jobs + ADD CONSTRAINT v2_user_deletion_jobs_id_user_generation_key UNIQUE (id, user_id, generation); + + +-- +-- Name: v2_user_deletion_jobs v2_user_deletion_jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_deletion_jobs + ADD CONSTRAINT v2_user_deletion_jobs_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_user_deletion_refund_intents v2_user_deletion_refund_intents_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_deletion_refund_intents + ADD CONSTRAINT v2_user_deletion_refund_intents_pkey PRIMARY KEY (job_id); + + +-- +-- Name: v2_user_integrations v2_user_integrations_composio_connection_id_pk; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_integrations + ADD CONSTRAINT v2_user_integrations_composio_connection_id_pk PRIMARY KEY (composio_connection_id); + + +-- +-- Name: v2_user_profiles v2_user_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_profiles + ADD CONSTRAINT v2_user_profiles_pkey PRIMARY KEY (user_id); + + +-- +-- Name: v2_user_skills v2_user_skills_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_skills + ADD CONSTRAINT v2_user_skills_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_users v2_users_clerk_id_unique; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_users + ADD CONSTRAINT v2_users_clerk_id_unique UNIQUE (clerk_id); + + +-- +-- Name: v2_users v2_users_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_users + ADD CONSTRAINT v2_users_pkey PRIMARY KEY (id); + + +-- +-- Name: v2_users v2_users_polar_customer_id_unique; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_users + ADD CONSTRAINT v2_users_polar_customer_id_unique UNIQUE (polar_customer_id); + + +-- +-- Name: v2_agent_runs_thread_delete_page_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_agent_runs_thread_delete_page_idx ON public.v2_agent_runs USING btree (user_id, thread_id, id); + + +-- +-- Name: v2_agent_runs_thread_started_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_agent_runs_thread_started_idx ON public.v2_agent_runs USING btree (thread_id, started_at DESC); + + +-- +-- Name: v2_agent_runs_user_delete_page_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_agent_runs_user_delete_page_idx ON public.v2_agent_runs USING btree (user_id, id); + + +-- +-- Name: v2_agent_runs_user_finished_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_agent_runs_user_finished_idx ON public.v2_agent_runs USING btree (user_id, finished_at) WHERE (finished_at IS NOT NULL); + + +-- +-- Name: v2_agent_runs_user_idempotency_key_unique; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_agent_runs_user_idempotency_key_unique ON public.v2_agent_runs USING btree (user_id, idempotency_key_hash); + + +-- +-- Name: v2_agent_runs_user_started_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_agent_runs_user_started_idx ON public.v2_agent_runs USING btree (user_id, started_at DESC); + + +-- +-- Name: v2_artifact_upload_intents_cleanup_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_artifact_upload_intents_cleanup_idx ON public.v2_artifact_upload_intents USING btree (cleanup_not_before, quiesced_at, id) WHERE (quiesced_at IS NOT NULL); + + +-- +-- Name: v2_artifact_upload_intents_project_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_artifact_upload_intents_project_idx ON public.v2_artifact_upload_intents USING btree (user_id, project_id, id); + + +-- +-- Name: v2_artifact_upload_intents_run_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_artifact_upload_intents_run_idx ON public.v2_artifact_upload_intents USING btree (user_id, agent_run_id, id); + + +-- +-- Name: v2_artifact_upload_intents_user_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_artifact_upload_intents_user_idx ON public.v2_artifact_upload_intents USING btree (user_id, id); + + +-- +-- Name: v2_audit_log_action_created_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_action_created_idx ON ONLY public.v2_audit_log USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_04_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_04_action_created_at_idx ON public.v2_audit_log_2026_04 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_created_brin_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_created_brin_idx ON ONLY public.v2_audit_log USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_04_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_04_created_at_idx ON public.v2_audit_log_2026_04 USING brin (created_at); + + +-- +-- Name: v2_audit_log_user_created_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_user_created_idx ON ONLY public.v2_audit_log USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_04_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_04_user_id_created_at_idx ON public.v2_audit_log_2026_04 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_05_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_05_action_created_at_idx ON public.v2_audit_log_2026_05 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_05_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_05_created_at_idx ON public.v2_audit_log_2026_05 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_05_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_05_user_id_created_at_idx ON public.v2_audit_log_2026_05 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_06_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_06_action_created_at_idx ON public.v2_audit_log_2026_06 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_06_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_06_created_at_idx ON public.v2_audit_log_2026_06 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_06_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_06_user_id_created_at_idx ON public.v2_audit_log_2026_06 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_07_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_07_action_created_at_idx ON public.v2_audit_log_2026_07 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_07_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_07_created_at_idx ON public.v2_audit_log_2026_07 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_07_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_07_user_id_created_at_idx ON public.v2_audit_log_2026_07 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_08_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_08_action_created_at_idx ON public.v2_audit_log_2026_08 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_08_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_08_created_at_idx ON public.v2_audit_log_2026_08 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_08_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_08_user_id_created_at_idx ON public.v2_audit_log_2026_08 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_09_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_09_action_created_at_idx ON public.v2_audit_log_2026_09 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_09_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_09_created_at_idx ON public.v2_audit_log_2026_09 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_09_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_09_user_id_created_at_idx ON public.v2_audit_log_2026_09 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_10_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_10_action_created_at_idx ON public.v2_audit_log_2026_10 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_10_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_10_created_at_idx ON public.v2_audit_log_2026_10 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_10_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_10_user_id_created_at_idx ON public.v2_audit_log_2026_10 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_11_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_11_action_created_at_idx ON public.v2_audit_log_2026_11 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_11_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_11_created_at_idx ON public.v2_audit_log_2026_11 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_11_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_11_user_id_created_at_idx ON public.v2_audit_log_2026_11 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_12_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_12_action_created_at_idx ON public.v2_audit_log_2026_12 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2026_12_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_12_created_at_idx ON public.v2_audit_log_2026_12 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2026_12_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2026_12_user_id_created_at_idx ON public.v2_audit_log_2026_12 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_01_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_01_action_created_at_idx ON public.v2_audit_log_2027_01 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_01_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_01_created_at_idx ON public.v2_audit_log_2027_01 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_01_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_01_user_id_created_at_idx ON public.v2_audit_log_2027_01 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_02_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_02_action_created_at_idx ON public.v2_audit_log_2027_02 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_02_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_02_created_at_idx ON public.v2_audit_log_2027_02 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_02_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_02_user_id_created_at_idx ON public.v2_audit_log_2027_02 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_03_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_03_action_created_at_idx ON public.v2_audit_log_2027_03 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_03_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_03_created_at_idx ON public.v2_audit_log_2027_03 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_03_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_03_user_id_created_at_idx ON public.v2_audit_log_2027_03 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_04_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_04_action_created_at_idx ON public.v2_audit_log_2027_04 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_04_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_04_created_at_idx ON public.v2_audit_log_2027_04 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_04_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_04_user_id_created_at_idx ON public.v2_audit_log_2027_04 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_05_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_05_action_created_at_idx ON public.v2_audit_log_2027_05 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_05_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_05_created_at_idx ON public.v2_audit_log_2027_05 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_05_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_05_user_id_created_at_idx ON public.v2_audit_log_2027_05 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_06_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_06_action_created_at_idx ON public.v2_audit_log_2027_06 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_06_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_06_created_at_idx ON public.v2_audit_log_2027_06 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_06_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_06_user_id_created_at_idx ON public.v2_audit_log_2027_06 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_07_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_07_action_created_at_idx ON public.v2_audit_log_2027_07 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_07_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_07_created_at_idx ON public.v2_audit_log_2027_07 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_07_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_07_user_id_created_at_idx ON public.v2_audit_log_2027_07 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_08_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_08_action_created_at_idx ON public.v2_audit_log_2027_08 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_08_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_08_created_at_idx ON public.v2_audit_log_2027_08 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_08_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_08_user_id_created_at_idx ON public.v2_audit_log_2027_08 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_09_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_09_action_created_at_idx ON public.v2_audit_log_2027_09 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_09_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_09_created_at_idx ON public.v2_audit_log_2027_09 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_09_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_09_user_id_created_at_idx ON public.v2_audit_log_2027_09 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_10_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_10_action_created_at_idx ON public.v2_audit_log_2027_10 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_10_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_10_created_at_idx ON public.v2_audit_log_2027_10 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_10_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_10_user_id_created_at_idx ON public.v2_audit_log_2027_10 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_11_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_11_action_created_at_idx ON public.v2_audit_log_2027_11 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_11_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_11_created_at_idx ON public.v2_audit_log_2027_11 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_11_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_11_user_id_created_at_idx ON public.v2_audit_log_2027_11 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_12_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_12_action_created_at_idx ON public.v2_audit_log_2027_12 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2027_12_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_12_created_at_idx ON public.v2_audit_log_2027_12 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2027_12_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2027_12_user_id_created_at_idx ON public.v2_audit_log_2027_12 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_01_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_01_action_created_at_idx ON public.v2_audit_log_2028_01 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_01_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_01_created_at_idx ON public.v2_audit_log_2028_01 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2028_01_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_01_user_id_created_at_idx ON public.v2_audit_log_2028_01 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_02_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_02_action_created_at_idx ON public.v2_audit_log_2028_02 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_02_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_02_created_at_idx ON public.v2_audit_log_2028_02 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2028_02_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_02_user_id_created_at_idx ON public.v2_audit_log_2028_02 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_03_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_03_action_created_at_idx ON public.v2_audit_log_2028_03 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_03_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_03_created_at_idx ON public.v2_audit_log_2028_03 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2028_03_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_03_user_id_created_at_idx ON public.v2_audit_log_2028_03 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_04_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_04_action_created_at_idx ON public.v2_audit_log_2028_04 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_04_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_04_created_at_idx ON public.v2_audit_log_2028_04 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2028_04_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_04_user_id_created_at_idx ON public.v2_audit_log_2028_04 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_05_action_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_05_action_created_at_idx ON public.v2_audit_log_2028_05 USING btree (action, created_at DESC); + + +-- +-- Name: v2_audit_log_2028_05_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_05_created_at_idx ON public.v2_audit_log_2028_05 USING brin (created_at); + + +-- +-- Name: v2_audit_log_2028_05_user_id_created_at_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_audit_log_2028_05_user_id_created_at_idx ON public.v2_audit_log_2028_05 USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_daily_maintenance_jobs_completed_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_daily_maintenance_jobs_completed_idx ON public.v2_daily_maintenance_jobs USING btree (completed_at, day) WHERE (status = 'complete'::text); + + +-- +-- Name: v2_daily_maintenance_jobs_lease_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_daily_maintenance_jobs_lease_idx ON public.v2_daily_maintenance_jobs USING btree (lease_expires_at, day) WHERE (status = 'leased'::text); + + +-- +-- Name: v2_daily_maintenance_jobs_ready_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_daily_maintenance_jobs_ready_idx ON public.v2_daily_maintenance_jobs USING btree (next_attempt_at, day) WHERE (status = 'queued'::text); + + +-- +-- Name: v2_entitlements_polar_subscription_uidx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_entitlements_polar_subscription_uidx ON public.v2_entitlements USING btree (polar_subscription_id) WHERE (polar_subscription_id IS NOT NULL); + + +-- +-- Name: v2_generated_outputs_agent_run_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_generated_outputs_agent_run_idx ON public.v2_generated_outputs USING btree (agent_run_id); + + +-- +-- Name: v2_generated_outputs_user_created_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_generated_outputs_user_created_idx ON public.v2_generated_outputs USING btree (user_id, created_at DESC); + + +-- +-- Name: v2_messages_agent_run_final_assistant_uidx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_messages_agent_run_final_assistant_uidx ON public.v2_messages USING btree (agent_run_id) WHERE ((agent_run_id IS NOT NULL) AND (role = 'assistant'::text) AND agent_run_segment_final); + + +-- +-- Name: v2_messages_agent_run_scope_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_messages_agent_run_scope_idx ON public.v2_messages USING btree (agent_run_id, user_id, thread_id); + + +-- +-- Name: v2_messages_agent_run_segment_assistant_uidx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_messages_agent_run_segment_assistant_uidx ON public.v2_messages USING btree (agent_run_id, agent_run_segment) WHERE ((agent_run_id IS NOT NULL) AND (role = 'assistant'::text)); + + +-- +-- Name: v2_messages_thread_page_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_messages_thread_page_idx ON public.v2_messages USING btree (user_id, thread_id, created_at, agent_run_segment, id); + + +-- +-- Name: v2_projects_deletion_queue_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_projects_deletion_queue_idx ON public.v2_projects USING btree (deleted_at, id) WHERE (deleted_at IS NOT NULL); + + +-- +-- Name: v2_projects_user_delete_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_projects_user_delete_idx ON public.v2_projects USING btree (user_id, id); + + +-- +-- Name: v2_projects_user_page_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_projects_user_page_idx ON public.v2_projects USING btree (user_id, updated_at DESC NULLS LAST, id DESC NULLS LAST) WHERE (deleted_at IS NULL); + + +-- +-- Name: v2_provider_keys_revalidation_lease_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_provider_keys_revalidation_lease_idx ON public.v2_provider_keys USING btree (last_revalidated_at NULLS FIRST, revalidation_claimed_at NULLS FIRST, created_at, user_id, provider) WHERE (disabled_at IS NULL); + + +-- +-- Name: v2_provider_keys_vault_secret_uidx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_provider_keys_vault_secret_uidx ON public.v2_provider_keys USING btree (vault_secret_id); + + +-- +-- Name: v2_resource_deletion_jobs_generation_uidx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_resource_deletion_jobs_generation_uidx ON public.v2_resource_deletion_jobs USING btree (kind, resource_id, generation); + + +-- +-- Name: v2_resource_deletion_jobs_lease_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_resource_deletion_jobs_lease_idx ON public.v2_resource_deletion_jobs USING btree (lease_expires_at, id) WHERE (status = 'leased'::text); + + +-- +-- Name: v2_resource_deletion_jobs_ready_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_resource_deletion_jobs_ready_idx ON public.v2_resource_deletion_jobs USING btree (next_attempt_at, id) WHERE (status = 'queued'::text); + + +-- +-- Name: v2_resource_deletion_jobs_user_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_resource_deletion_jobs_user_idx ON public.v2_resource_deletion_jobs USING btree (user_id); + + +-- +-- Name: v2_threads_active_run_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_threads_active_run_idx ON public.v2_threads USING btree (active_run_id) WHERE (active_run_id IS NOT NULL); + + +-- +-- Name: v2_threads_deletion_queue_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_threads_deletion_queue_idx ON public.v2_threads USING btree (deleted_at, id) WHERE (deleted_at IS NOT NULL); + + +-- +-- Name: v2_threads_project_delete_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_threads_project_delete_idx ON public.v2_threads USING btree (user_id, project_id, id); + + +-- +-- Name: v2_threads_project_page_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_threads_project_page_idx ON public.v2_threads USING btree (user_id, project_id, updated_at DESC NULLS LAST, id DESC NULLS LAST) WHERE (deleted_at IS NULL); + + +-- +-- Name: v2_threads_user_page_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_threads_user_page_idx ON public.v2_threads USING btree (user_id, updated_at DESC NULLS LAST, id DESC NULLS LAST) WHERE (deleted_at IS NULL); + + +-- +-- Name: v2_user_deletion_jobs_generation_uidx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_user_deletion_jobs_generation_uidx ON public.v2_user_deletion_jobs USING btree (user_id, generation); + + +-- +-- Name: v2_user_deletion_jobs_lease_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_user_deletion_jobs_lease_idx ON public.v2_user_deletion_jobs USING btree (lease_expires_at, id) WHERE (status = 'leased'::text); + + +-- +-- Name: v2_user_deletion_jobs_ready_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_user_deletion_jobs_ready_idx ON public.v2_user_deletion_jobs USING btree (next_attempt_at, id) WHERE (status = 'queued'::text); + + +-- +-- Name: v2_user_deletion_refund_intents_idempotency_uidx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_user_deletion_refund_intents_idempotency_uidx ON public.v2_user_deletion_refund_intents USING btree (idempotency_key); + + +-- +-- Name: v2_user_deletion_refund_intents_provider_uidx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_user_deletion_refund_intents_provider_uidx ON public.v2_user_deletion_refund_intents USING btree (provider_refund_id) WHERE (provider_refund_id IS NOT NULL); + + +-- +-- Name: v2_user_deletion_refund_intents_unresolved_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_user_deletion_refund_intents_unresolved_idx ON public.v2_user_deletion_refund_intents USING btree (user_id, job_id) WHERE (provider_status IS DISTINCT FROM 'succeeded'::text); + + +-- +-- Name: v2_user_integrations_delete_page_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_user_integrations_delete_page_idx ON public.v2_user_integrations USING btree (user_id, composio_connection_id); + + +-- +-- Name: v2_user_integrations_one_default_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_user_integrations_one_default_idx ON public.v2_user_integrations USING btree (user_id, integration) WHERE (is_default = true); + + +-- +-- Name: v2_user_integrations_user_toolkit_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_user_integrations_user_toolkit_idx ON public.v2_user_integrations USING btree (user_id, integration); + + +-- +-- Name: v2_user_skills_user_name_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE UNIQUE INDEX v2_user_skills_user_name_idx ON public.v2_user_skills USING btree (user_id, name); + + +-- +-- Name: v2_users_activation_created_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_users_activation_created_idx ON public.v2_users USING btree (created_at, id) WHERE (deleted_at IS NULL); + + +-- +-- Name: v2_users_deletion_due_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX v2_users_deletion_due_idx ON public.v2_users USING btree (deleted_at, id) WHERE (deleted_at IS NOT NULL); + + +-- +-- Name: v2_audit_log_2026_04_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_04_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_04_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_04_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_04_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_04_pkey; + + +-- +-- Name: v2_audit_log_2026_04_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_04_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_05_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_05_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_05_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_05_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_05_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_05_pkey; + + +-- +-- Name: v2_audit_log_2026_05_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_05_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_06_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_06_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_06_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_06_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_06_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_06_pkey; + + +-- +-- Name: v2_audit_log_2026_06_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_06_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_07_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_07_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_07_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_07_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_07_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_07_pkey; + + +-- +-- Name: v2_audit_log_2026_07_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_07_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_08_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_08_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_08_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_08_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_08_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_08_pkey; + + +-- +-- Name: v2_audit_log_2026_08_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_08_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_09_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_09_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_09_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_09_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_09_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_09_pkey; + + +-- +-- Name: v2_audit_log_2026_09_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_09_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_10_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_10_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_10_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_10_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_10_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_10_pkey; + + +-- +-- Name: v2_audit_log_2026_10_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_10_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_11_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_11_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_11_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_11_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_11_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_11_pkey; + + +-- +-- Name: v2_audit_log_2026_11_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_11_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_12_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2026_12_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_12_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2026_12_created_at_idx; + + +-- +-- Name: v2_audit_log_2026_12_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2026_12_pkey; + + +-- +-- Name: v2_audit_log_2026_12_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2026_12_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_01_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_01_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_01_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_01_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_01_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_01_pkey; + + +-- +-- Name: v2_audit_log_2027_01_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_01_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_02_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_02_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_02_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_02_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_02_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_02_pkey; + + +-- +-- Name: v2_audit_log_2027_02_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_02_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_03_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_03_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_03_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_03_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_03_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_03_pkey; + + +-- +-- Name: v2_audit_log_2027_03_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_03_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_04_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_04_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_04_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_04_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_04_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_04_pkey; + + +-- +-- Name: v2_audit_log_2027_04_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_04_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_05_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_05_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_05_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_05_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_05_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_05_pkey; + + +-- +-- Name: v2_audit_log_2027_05_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_05_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_06_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_06_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_06_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_06_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_06_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_06_pkey; + + +-- +-- Name: v2_audit_log_2027_06_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_06_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_07_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_07_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_07_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_07_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_07_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_07_pkey; + + +-- +-- Name: v2_audit_log_2027_07_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_07_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_08_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_08_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_08_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_08_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_08_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_08_pkey; + + +-- +-- Name: v2_audit_log_2027_08_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_08_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_09_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_09_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_09_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_09_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_09_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_09_pkey; + + +-- +-- Name: v2_audit_log_2027_09_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_09_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_10_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_10_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_10_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_10_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_10_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_10_pkey; + + +-- +-- Name: v2_audit_log_2027_10_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_10_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_11_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_11_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_11_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_11_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_11_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_11_pkey; + + +-- +-- Name: v2_audit_log_2027_11_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_11_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_12_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2027_12_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_12_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2027_12_created_at_idx; + + +-- +-- Name: v2_audit_log_2027_12_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2027_12_pkey; + + +-- +-- Name: v2_audit_log_2027_12_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2027_12_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_01_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2028_01_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_01_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2028_01_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_01_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2028_01_pkey; + + +-- +-- Name: v2_audit_log_2028_01_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2028_01_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_02_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2028_02_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_02_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2028_02_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_02_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2028_02_pkey; + + +-- +-- Name: v2_audit_log_2028_02_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2028_02_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_03_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2028_03_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_03_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2028_03_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_03_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2028_03_pkey; + + +-- +-- Name: v2_audit_log_2028_03_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2028_03_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_04_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2028_04_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_04_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2028_04_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_04_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2028_04_pkey; + + +-- +-- Name: v2_audit_log_2028_04_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2028_04_user_id_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_05_action_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_action_created_idx ATTACH PARTITION public.v2_audit_log_2028_05_action_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_05_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_created_brin_idx ATTACH PARTITION public.v2_audit_log_2028_05_created_at_idx; + + +-- +-- Name: v2_audit_log_2028_05_pkey; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_pkey ATTACH PARTITION public.v2_audit_log_2028_05_pkey; + + +-- +-- Name: v2_audit_log_2028_05_user_id_created_at_idx; Type: INDEX ATTACH; Schema: public; Owner: - +-- + +ALTER INDEX public.v2_audit_log_user_created_idx ATTACH PARTITION public.v2_audit_log_2028_05_user_id_created_at_idx; + + +-- +-- Name: v2_agent_runs trg_v2_agent_runs_terminal_state; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_agent_runs_terminal_state BEFORE UPDATE OF finished_at, status ON public.v2_agent_runs FOR EACH ROW EXECUTE FUNCTION public.v2_guard_terminal_agent_run_state(); + + +-- +-- Name: v2_provider_keys trg_v2_audit_provider_keys; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_audit_provider_keys AFTER INSERT OR DELETE OR UPDATE ON public.v2_provider_keys FOR EACH ROW EXECUTE FUNCTION public.v2_audit_provider_key_change(); + + +-- +-- Name: v2_entitlements trg_v2_entitlements_updated; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_entitlements_updated BEFORE UPDATE ON public.v2_entitlements FOR EACH ROW EXECUTE FUNCTION public.v2_touch_updated_at(); + + +-- +-- Name: v2_projects trg_v2_projects_updated; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_projects_updated BEFORE UPDATE ON public.v2_projects FOR EACH ROW EXECUTE FUNCTION public.v2_touch_updated_at(); + + +-- +-- Name: v2_provider_keys trg_v2_provider_keys_delete_vault; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_provider_keys_delete_vault BEFORE DELETE ON public.v2_provider_keys FOR EACH ROW EXECUTE FUNCTION public.v2_delete_provider_vault_secret(); + + +-- +-- Name: v2_threads trg_v2_threads_updated; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_threads_updated BEFORE UPDATE ON public.v2_threads FOR EACH ROW EXECUTE FUNCTION public.v2_touch_updated_at(); + + +-- +-- Name: v2_user_deletion_jobs trg_v2_user_deletion_refund_resolution; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_user_deletion_refund_resolution BEFORE DELETE OR UPDATE OF phase ON public.v2_user_deletion_jobs FOR EACH ROW EXECUTE FUNCTION public.v2_guard_user_deletion_refund_resolution(); + + +-- +-- Name: v2_user_integrations trg_v2_user_integrations_updated; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_user_integrations_updated BEFORE UPDATE ON public.v2_user_integrations FOR EACH ROW EXECUTE FUNCTION public.v2_touch_updated_at(); + + +-- +-- Name: v2_user_profiles trg_v2_user_profiles_updated; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER trg_v2_user_profiles_updated BEFORE UPDATE ON public.v2_user_profiles FOR EACH ROW EXECUTE FUNCTION public.v2_touch_updated_at(); + + +-- +-- Name: v2_entitlements v2_audit_entitlement_change_trigger; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER v2_audit_entitlement_change_trigger AFTER INSERT OR DELETE OR UPDATE ON public.v2_entitlements FOR EACH ROW EXECUTE FUNCTION public.v2_audit_entitlement_change(); + + +-- +-- Name: v2_user_integrations v2_audit_integration_change_trigger; Type: TRIGGER; Schema: public; Owner: - +-- + +CREATE TRIGGER v2_audit_integration_change_trigger AFTER INSERT OR DELETE OR UPDATE ON public.v2_user_integrations FOR EACH ROW EXECUTE FUNCTION public.v2_audit_integration_change(); + + +-- +-- Name: v2_agent_runs v2_agent_runs_thread_user_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_agent_runs + ADD CONSTRAINT v2_agent_runs_thread_user_fk FOREIGN KEY (thread_id, user_id) REFERENCES public.v2_threads(id, user_id) ON DELETE CASCADE; + + +-- +-- Name: v2_agent_runs v2_agent_runs_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_agent_runs + ADD CONSTRAINT v2_agent_runs_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_agent_run_user_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_artifact_upload_intents + ADD CONSTRAINT v2_artifact_upload_intents_agent_run_user_fk FOREIGN KEY (agent_run_id, user_id) REFERENCES public.v2_agent_runs(id, user_id); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_project_user_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_artifact_upload_intents + ADD CONSTRAINT v2_artifact_upload_intents_project_user_fk FOREIGN KEY (project_id, user_id) REFERENCES public.v2_projects(id, user_id); + + +-- +-- Name: v2_entitlements v2_entitlements_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_entitlements + ADD CONSTRAINT v2_entitlements_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_generated_outputs v2_generated_outputs_agent_run_user_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_generated_outputs + ADD CONSTRAINT v2_generated_outputs_agent_run_user_fk FOREIGN KEY (agent_run_id, user_id) REFERENCES public.v2_agent_runs(id, user_id) ON DELETE RESTRICT; + + +-- +-- Name: v2_generated_outputs v2_generated_outputs_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_generated_outputs + ADD CONSTRAINT v2_generated_outputs_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_messages v2_messages_agent_run_scope_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_messages + ADD CONSTRAINT v2_messages_agent_run_scope_fk FOREIGN KEY (agent_run_id, user_id, thread_id) REFERENCES public.v2_agent_runs(id, user_id, thread_id) ON DELETE RESTRICT; + + +-- +-- Name: v2_messages v2_messages_thread_user_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_messages + ADD CONSTRAINT v2_messages_thread_user_fk FOREIGN KEY (thread_id, user_id) REFERENCES public.v2_threads(id, user_id) ON DELETE CASCADE; + + +-- +-- Name: v2_messages v2_messages_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_messages + ADD CONSTRAINT v2_messages_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_projects v2_projects_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_projects + ADD CONSTRAINT v2_projects_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_provider_keys v2_provider_keys_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_provider_keys + ADD CONSTRAINT v2_provider_keys_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_resource_deletion_jobs v2_resource_deletion_jobs_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_resource_deletion_jobs + ADD CONSTRAINT v2_resource_deletion_jobs_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_threads v2_threads_active_run_scope_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_threads + ADD CONSTRAINT v2_threads_active_run_scope_fk FOREIGN KEY (active_run_id, user_id, id) REFERENCES public.v2_agent_runs(id, user_id, thread_id) ON DELETE SET NULL (active_run_id); + + +-- +-- Name: v2_threads v2_threads_project_user_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_threads + ADD CONSTRAINT v2_threads_project_user_fk FOREIGN KEY (project_id, user_id) REFERENCES public.v2_projects(id, user_id) ON DELETE CASCADE; + + +-- +-- Name: v2_threads v2_threads_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_threads + ADD CONSTRAINT v2_threads_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_user_deletion_jobs v2_user_deletion_jobs_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_deletion_jobs + ADD CONSTRAINT v2_user_deletion_jobs_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_user_deletion_refund_intents v2_user_deletion_refund_intents_job_identity_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_deletion_refund_intents + ADD CONSTRAINT v2_user_deletion_refund_intents_job_identity_fk FOREIGN KEY (job_id, user_id, generation) REFERENCES public.v2_user_deletion_jobs(id, user_id, generation) ON DELETE CASCADE; + + +-- +-- Name: v2_user_integrations v2_user_integrations_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_integrations + ADD CONSTRAINT v2_user_integrations_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_user_profiles v2_user_profiles_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_profiles + ADD CONSTRAINT v2_user_profiles_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_user_skills v2_user_skills_user_id_v2_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.v2_user_skills + ADD CONSTRAINT v2_user_skills_user_id_v2_users_id_fk FOREIGN KEY (user_id) REFERENCES public.v2_users(id) ON DELETE CASCADE; + + +-- +-- Name: v2_agent_runs; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_agent_runs ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_agent_runs v2_agent_runs_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_agent_runs_insert_own ON public.v2_agent_runs FOR INSERT TO app_agent WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_agent_runs v2_agent_runs_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_agent_runs_postgres_all ON public.v2_agent_runs TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_agent_runs v2_agent_runs_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_agent_runs_select_own ON public.v2_agent_runs FOR SELECT TO app_gateway, app_agent, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_agent_runs v2_agent_runs_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_agent_runs_update_own ON public.v2_agent_runs FOR UPDATE TO app_agent USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_artifact_upload_intents; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_artifact_upload_intents ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_delete_maintenance; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_artifact_upload_intents_delete_maintenance ON public.v2_artifact_upload_intents FOR DELETE TO app_webhooks USING (true); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_delete_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_artifact_upload_intents_delete_own ON public.v2_artifact_upload_intents FOR DELETE TO app_agent USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_artifact_upload_intents_insert_own ON public.v2_artifact_upload_intents FOR INSERT TO app_agent WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_artifact_upload_intents_postgres_all ON public.v2_artifact_upload_intents TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_select_maintenance; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_artifact_upload_intents_select_maintenance ON public.v2_artifact_upload_intents FOR SELECT TO app_webhooks USING (true); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_artifact_upload_intents_select_own ON public.v2_artifact_upload_intents FOR SELECT TO app_agent USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_artifact_upload_intents v2_artifact_upload_intents_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_artifact_upload_intents_update_own ON public.v2_artifact_upload_intents FOR UPDATE TO app_agent USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_audit_log; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_audit_log ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_audit_log_2026_07; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_audit_log_2026_07 ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_audit_log_2026_08; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_audit_log_2026_08 ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_audit_log_2026_09; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_audit_log_2026_09 ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_audit_log_2026_10; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_audit_log_2026_10 ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_audit_log v2_audit_log_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_audit_log_postgres_all ON public.v2_audit_log TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_audit_log_2026_07 v2_audit_partition_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_audit_partition_postgres_all ON public.v2_audit_log_2026_07 TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_audit_log_2026_08 v2_audit_partition_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_audit_partition_postgres_all ON public.v2_audit_log_2026_08 TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_audit_log_2026_09 v2_audit_partition_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_audit_partition_postgres_all ON public.v2_audit_log_2026_09 TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_audit_log_2026_10 v2_audit_partition_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_audit_partition_postgres_all ON public.v2_audit_log_2026_10 TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_daily_maintenance_jobs; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_daily_maintenance_jobs ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_daily_maintenance_jobs v2_daily_maintenance_jobs_delete_maintenance; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_daily_maintenance_jobs_delete_maintenance ON public.v2_daily_maintenance_jobs FOR DELETE TO app_webhooks USING (true); + + +-- +-- Name: v2_daily_maintenance_jobs v2_daily_maintenance_jobs_insert_maintenance; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_daily_maintenance_jobs_insert_maintenance ON public.v2_daily_maintenance_jobs FOR INSERT TO app_webhooks WITH CHECK (true); + + +-- +-- Name: v2_daily_maintenance_jobs v2_daily_maintenance_jobs_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_daily_maintenance_jobs_postgres_all ON public.v2_daily_maintenance_jobs TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_daily_maintenance_jobs v2_daily_maintenance_jobs_select_maintenance; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_daily_maintenance_jobs_select_maintenance ON public.v2_daily_maintenance_jobs FOR SELECT TO app_webhooks USING (true); + + +-- +-- Name: v2_daily_maintenance_jobs v2_daily_maintenance_jobs_update_maintenance; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_daily_maintenance_jobs_update_maintenance ON public.v2_daily_maintenance_jobs FOR UPDATE TO app_webhooks USING (true) WITH CHECK (true); + + +-- +-- Name: v2_deleted_clerk_identities; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_deleted_clerk_identities ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_deleted_clerk_identities v2_deleted_clerk_identities_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_deleted_clerk_identities_postgres_all ON public.v2_deleted_clerk_identities TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_entitlements; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_entitlements ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_entitlements v2_entitlements_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_entitlements_insert_own ON public.v2_entitlements FOR INSERT TO app_gateway, app_webhooks WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_entitlements v2_entitlements_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_entitlements_postgres_all ON public.v2_entitlements TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_entitlements v2_entitlements_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_entitlements_select_own ON public.v2_entitlements FOR SELECT TO app_gateway, app_agent, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_entitlements v2_entitlements_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_entitlements_update_own ON public.v2_entitlements FOR UPDATE TO app_gateway, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_generated_outputs; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_generated_outputs ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_generated_outputs v2_generated_outputs_delete_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_generated_outputs_delete_own ON public.v2_generated_outputs FOR DELETE TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_generated_outputs v2_generated_outputs_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_generated_outputs_insert_own ON public.v2_generated_outputs FOR INSERT TO app_agent WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_generated_outputs v2_generated_outputs_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_generated_outputs_postgres_all ON public.v2_generated_outputs TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_generated_outputs v2_generated_outputs_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_generated_outputs_select_own ON public.v2_generated_outputs FOR SELECT TO app_agent, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_messages; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_messages ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_messages v2_messages_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_messages_insert_own ON public.v2_messages FOR INSERT TO app_agent WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_messages v2_messages_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_messages_postgres_all ON public.v2_messages TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_messages v2_messages_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_messages_select_own ON public.v2_messages FOR SELECT TO app_gateway, app_agent USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_projects; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_projects ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_projects v2_projects_delete_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_projects_delete_own ON public.v2_projects FOR DELETE TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_projects v2_projects_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_projects_insert_own ON public.v2_projects FOR INSERT TO app_gateway, app_agent WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_projects v2_projects_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_projects_postgres_all ON public.v2_projects TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_projects v2_projects_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_projects_select_own ON public.v2_projects FOR SELECT TO app_gateway, app_agent, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_projects v2_projects_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_projects_update_own ON public.v2_projects FOR UPDATE TO app_gateway, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_provider_keys; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_provider_keys ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_provider_keys v2_provider_keys_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_provider_keys_postgres_all ON public.v2_provider_keys TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_provider_keys v2_provider_keys_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_provider_keys_select_own ON public.v2_provider_keys FOR SELECT TO app_gateway, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_provider_keys v2_provider_keys_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_provider_keys_update_own ON public.v2_provider_keys FOR UPDATE TO app_gateway, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_resource_deletion_jobs; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_resource_deletion_jobs ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_resource_deletion_jobs v2_resource_deletion_jobs_delete_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_resource_deletion_jobs_delete_own ON public.v2_resource_deletion_jobs FOR DELETE TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_resource_deletion_jobs v2_resource_deletion_jobs_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_resource_deletion_jobs_insert_own ON public.v2_resource_deletion_jobs FOR INSERT TO app_webhooks WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_resource_deletion_jobs v2_resource_deletion_jobs_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_resource_deletion_jobs_postgres_all ON public.v2_resource_deletion_jobs TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_resource_deletion_jobs v2_resource_deletion_jobs_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_resource_deletion_jobs_select_own ON public.v2_resource_deletion_jobs FOR SELECT TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_resource_deletion_jobs v2_resource_deletion_jobs_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_resource_deletion_jobs_update_own ON public.v2_resource_deletion_jobs FOR UPDATE TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_threads; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_threads ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_threads v2_threads_delete_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_threads_delete_own ON public.v2_threads FOR DELETE TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_threads v2_threads_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_threads_insert_own ON public.v2_threads FOR INSERT TO app_gateway WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_threads v2_threads_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_threads_postgres_all ON public.v2_threads TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_threads v2_threads_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_threads_select_own ON public.v2_threads FOR SELECT TO app_gateway, app_agent, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_threads v2_threads_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_threads_update_own ON public.v2_threads FOR UPDATE TO app_gateway, app_agent, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_deletion_jobs; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_user_deletion_jobs ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_user_deletion_jobs v2_user_deletion_jobs_delete_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_deletion_jobs_delete_own ON public.v2_user_deletion_jobs FOR DELETE TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_deletion_jobs v2_user_deletion_jobs_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_deletion_jobs_insert_own ON public.v2_user_deletion_jobs FOR INSERT TO app_webhooks WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_deletion_jobs v2_user_deletion_jobs_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_deletion_jobs_postgres_all ON public.v2_user_deletion_jobs TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_user_deletion_jobs v2_user_deletion_jobs_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_deletion_jobs_select_own ON public.v2_user_deletion_jobs FOR SELECT TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_deletion_jobs v2_user_deletion_jobs_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_deletion_jobs_update_own ON public.v2_user_deletion_jobs FOR UPDATE TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_deletion_refund_intents; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_user_deletion_refund_intents ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_user_deletion_refund_intents v2_user_deletion_refund_intents_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_deletion_refund_intents_postgres_all ON public.v2_user_deletion_refund_intents TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_user_deletion_refund_intents v2_user_deletion_refund_intents_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_deletion_refund_intents_select_own ON public.v2_user_deletion_refund_intents FOR SELECT TO app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_integrations; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_user_integrations ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_user_integrations v2_user_integrations_delete_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_integrations_delete_own ON public.v2_user_integrations FOR DELETE TO app_gateway USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_integrations v2_user_integrations_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_integrations_insert_own ON public.v2_user_integrations FOR INSERT TO app_gateway WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_integrations v2_user_integrations_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_integrations_postgres_all ON public.v2_user_integrations TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_user_integrations v2_user_integrations_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_integrations_select_own ON public.v2_user_integrations FOR SELECT TO app_gateway, app_agent, app_webhooks USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_integrations v2_user_integrations_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_integrations_update_own ON public.v2_user_integrations FOR UPDATE TO app_gateway USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_profiles; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_user_profiles ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_user_profiles v2_user_profiles_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_profiles_insert_own ON public.v2_user_profiles FOR INSERT TO app_gateway WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_profiles v2_user_profiles_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_profiles_postgres_all ON public.v2_user_profiles TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_user_profiles v2_user_profiles_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_profiles_select_own ON public.v2_user_profiles FOR SELECT TO app_gateway, app_agent USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_profiles v2_user_profiles_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_profiles_update_own ON public.v2_user_profiles FOR UPDATE TO app_gateway USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_skills; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_user_skills ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_user_skills v2_user_skills_delete_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_skills_delete_own ON public.v2_user_skills FOR DELETE TO app_gateway USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_skills v2_user_skills_insert_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_skills_insert_own ON public.v2_user_skills FOR INSERT TO app_gateway, app_agent WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_skills v2_user_skills_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_skills_postgres_all ON public.v2_user_skills TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_user_skills v2_user_skills_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_skills_select_own ON public.v2_user_skills FOR SELECT TO app_gateway, app_agent USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_user_skills v2_user_skills_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_user_skills_update_own ON public.v2_user_skills FOR UPDATE TO app_gateway, app_agent USING ((user_id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((user_id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_users; Type: ROW SECURITY; Schema: public; Owner: - +-- + +ALTER TABLE public.v2_users ENABLE ROW LEVEL SECURITY; + +-- +-- Name: v2_users v2_users_postgres_all; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_users_postgres_all ON public.v2_users TO postgres USING (true) WITH CHECK (true); + + +-- +-- Name: v2_users v2_users_select_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_users_select_own ON public.v2_users FOR SELECT TO app_gateway, app_agent, app_webhooks USING ((id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: v2_users v2_users_update_own; Type: POLICY; Schema: public; Owner: - +-- + +CREATE POLICY v2_users_update_own ON public.v2_users FOR UPDATE TO app_gateway, app_agent, app_webhooks USING ((id = ( SELECT public.current_app_user() AS current_app_user))) WITH CHECK ((id = ( SELECT public.current_app_user() AS current_app_user))); + + +-- +-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: - +-- + +REVOKE USAGE ON SCHEMA public FROM PUBLIC; +GRANT USAGE ON SCHEMA public TO postgres; +GRANT USAGE ON SCHEMA public TO anon; +GRANT USAGE ON SCHEMA public TO authenticated; +GRANT USAGE ON SCHEMA public TO service_role; +GRANT USAGE ON SCHEMA public TO app_gateway; +GRANT USAGE ON SCHEMA public TO app_agent; +GRANT USAGE ON SCHEMA public TO app_webhooks; + + +-- +-- Name: FUNCTION claim_provider_key_revalidation_targets(p_limit integer); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.claim_provider_key_revalidation_targets(p_limit integer) FROM PUBLIC; +GRANT ALL ON FUNCTION public.claim_provider_key_revalidation_targets(p_limit integer) TO app_webhooks; + + +-- +-- Name: FUNCTION current_app_user(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.current_app_user() FROM PUBLIC; +GRANT ALL ON FUNCTION public.current_app_user() TO app_gateway; +GRANT ALL ON FUNCTION public.current_app_user() TO app_agent; +GRANT ALL ON FUNCTION public.current_app_user() TO app_webhooks; + + +-- +-- Name: FUNCTION delete_all_provider_keys(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.delete_all_provider_keys() FROM PUBLIC; +GRANT ALL ON FUNCTION public.delete_all_provider_keys() TO app_webhooks; + + +-- +-- Name: FUNCTION delete_provider_key(p_provider text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.delete_provider_key(p_provider text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.delete_provider_key(p_provider text) TO app_gateway; + + +-- +-- Name: FUNCTION ensure_v2_audit_partitions(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.ensure_v2_audit_partitions() FROM PUBLIC; + + +-- +-- Name: FUNCTION gateway_resolve_clerk_user(p_clerk_id text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.gateway_resolve_clerk_user(p_clerk_id text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.gateway_resolve_clerk_user(p_clerk_id text) TO app_gateway; + + +-- +-- Name: FUNCTION get_provider_key(p_provider text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.get_provider_key(p_provider text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.get_provider_key(p_provider text) TO app_agent; +GRANT ALL ON FUNCTION public.get_provider_key(p_provider text) TO app_webhooks; + + +-- +-- Name: FUNCTION scrub_current_user_audit(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.scrub_current_user_audit() FROM PUBLIC; +GRANT ALL ON FUNCTION public.scrub_current_user_audit() TO app_webhooks; + + +-- +-- Name: FUNCTION set_provider_key(p_provider text, p_key text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.set_provider_key(p_provider text, p_key text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.set_provider_key(p_provider text, p_key text) TO app_gateway; + + +-- +-- Name: FUNCTION sync_clerk_user(p_clerk_id text, p_email text, p_display_name text, p_avatar_url text, p_clerk_updated_at_ms bigint); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.sync_clerk_user(p_clerk_id text, p_email text, p_display_name text, p_avatar_url text, p_clerk_updated_at_ms bigint) FROM PUBLIC; +GRANT ALL ON FUNCTION public.sync_clerk_user(p_clerk_id text, p_email text, p_display_name text, p_avatar_url text, p_clerk_updated_at_ms bigint) TO app_gateway; +GRANT ALL ON FUNCTION public.sync_clerk_user(p_clerk_id text, p_email text, p_display_name text, p_avatar_url text, p_clerk_updated_at_ms bigint) TO app_webhooks; + + +-- +-- Name: FUNCTION uuidv7(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.uuidv7() FROM PUBLIC; +GRANT ALL ON FUNCTION public.uuidv7() TO app_gateway; +GRANT ALL ON FUNCTION public.uuidv7() TO app_agent; +GRANT ALL ON FUNCTION public.uuidv7() TO app_webhooks; + + +-- +-- Name: FUNCTION v2_audit_entitlement_change(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.v2_audit_entitlement_change() FROM PUBLIC; + + +-- +-- Name: FUNCTION v2_audit_integration_change(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.v2_audit_integration_change() FROM PUBLIC; + + +-- +-- Name: FUNCTION v2_audit_provider_key_change(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.v2_audit_provider_key_change() FROM PUBLIC; + + +-- +-- Name: FUNCTION v2_delete_provider_vault_secret(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.v2_delete_provider_vault_secret() FROM PUBLIC; + + +-- +-- Name: FUNCTION v2_guard_terminal_agent_run_state(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.v2_guard_terminal_agent_run_state() FROM PUBLIC; + + +-- +-- Name: FUNCTION v2_guard_user_deletion_refund_resolution(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.v2_guard_user_deletion_refund_resolution() FROM PUBLIC; + + +-- +-- Name: FUNCTION v2_touch_updated_at(); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.v2_touch_updated_at() FROM PUBLIC; + + +-- +-- Name: FUNCTION webhooks_claim_ready_resource_deletion_jobs(p_lease_token uuid, p_limit integer, p_max_failures integer, p_now timestamp with time zone); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_claim_ready_resource_deletion_jobs(p_lease_token uuid, p_limit integer, p_max_failures integer, p_now timestamp with time zone) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_claim_ready_resource_deletion_jobs(p_lease_token uuid, p_limit integer, p_max_failures integer, p_now timestamp with time zone) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_claim_ready_user_deletion_jobs(p_lease_token uuid, p_limit integer, p_max_failures integer, p_now timestamp with time zone); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_claim_ready_user_deletion_jobs(p_lease_token uuid, p_limit integer, p_max_failures integer, p_now timestamp with time zone) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_claim_ready_user_deletion_jobs(p_lease_token uuid, p_limit integer, p_max_failures integer, p_now timestamp with time zone) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_discover_resource_deletion_jobs(p_limit integer); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_discover_resource_deletion_jobs(p_limit integer) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_discover_resource_deletion_jobs(p_limit integer) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_discover_user_deletion_jobs(p_before timestamp with time zone, p_limit integer); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_discover_user_deletion_jobs(p_before timestamp with time zone, p_limit integer) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_discover_user_deletion_jobs(p_before timestamp with time zone, p_limit integer) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_expire_composio_connection(p_connection_id text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_expire_composio_connection(p_connection_id text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_expire_composio_connection(p_connection_id text) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_finalize_current_user_deletion(p_deletion_fence text, p_clerk_identity_hash text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_finalize_current_user_deletion(p_deletion_fence text, p_clerk_identity_hash text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_finalize_current_user_deletion(p_deletion_fence text, p_clerk_identity_hash text) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_list_daily_activation_events(p_day date, p_cursor_event text, p_cursor_user_id uuid, p_limit integer); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_list_daily_activation_events(p_day date, p_cursor_event text, p_cursor_user_id uuid, p_limit integer) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_list_daily_activation_events(p_day date, p_cursor_event text, p_cursor_user_id uuid, p_limit integer) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_mark_clerk_user_deleted(p_clerk_id text, p_deleted_at timestamp with time zone); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_mark_clerk_user_deleted(p_clerk_id text, p_deleted_at timestamp with time zone) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_mark_clerk_user_deleted(p_clerk_id text, p_deleted_at timestamp with time zone) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_record_user_deletion_refund_evidence(p_job_id uuid, p_generation timestamp with time zone, p_continuation integer, p_lease_token uuid, p_cursor text, p_order_id text, p_amount integer, p_currency text, p_idempotency_key text, p_provider_refund_id text, p_provider_status text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_record_user_deletion_refund_evidence(p_job_id uuid, p_generation timestamp with time zone, p_continuation integer, p_lease_token uuid, p_cursor text, p_order_id text, p_amount integer, p_currency text, p_idempotency_key text, p_provider_refund_id text, p_provider_status text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_record_user_deletion_refund_evidence(p_job_id uuid, p_generation timestamp with time zone, p_continuation integer, p_lease_token uuid, p_cursor text, p_order_id text, p_amount integer, p_currency text, p_idempotency_key text, p_provider_refund_id text, p_provider_status text) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_reserve_user_deletion_refund_intent(p_job_id uuid, p_generation timestamp with time zone, p_continuation integer, p_lease_token uuid, p_cursor text, p_order_id text, p_amount integer, p_currency text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_reserve_user_deletion_refund_intent(p_job_id uuid, p_generation timestamp with time zone, p_continuation integer, p_lease_token uuid, p_cursor text, p_order_id text, p_amount integer, p_currency text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_reserve_user_deletion_refund_intent(p_job_id uuid, p_generation timestamp with time zone, p_continuation integer, p_lease_token uuid, p_cursor text, p_order_id text, p_amount integer, p_currency text) TO app_webhooks; + + +-- +-- Name: FUNCTION webhooks_resolve_polar_customer(p_polar_customer_id text); Type: ACL; Schema: public; Owner: - +-- + +REVOKE ALL ON FUNCTION public.webhooks_resolve_polar_customer(p_polar_customer_id text) FROM PUBLIC; +GRANT ALL ON FUNCTION public.webhooks_resolve_polar_customer(p_polar_customer_id text) TO app_webhooks; + + +-- +-- Name: TABLE v2_agent_runs; Type: ACL; Schema: public; Owner: - +-- + +GRANT INSERT ON TABLE public.v2_agent_runs TO app_agent; + + +-- +-- Name: COLUMN v2_agent_runs.id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(id) ON TABLE public.v2_agent_runs TO app_gateway; +GRANT SELECT(id) ON TABLE public.v2_agent_runs TO app_agent; +GRANT SELECT(id) ON TABLE public.v2_agent_runs TO app_webhooks; + + +-- +-- Name: COLUMN v2_agent_runs.thread_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(thread_id) ON TABLE public.v2_agent_runs TO app_agent; +GRANT SELECT(thread_id) ON TABLE public.v2_agent_runs TO app_webhooks; + + +-- +-- Name: COLUMN v2_agent_runs.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id) ON TABLE public.v2_agent_runs TO app_gateway; +GRANT SELECT(user_id) ON TABLE public.v2_agent_runs TO app_agent; +GRANT SELECT(user_id) ON TABLE public.v2_agent_runs TO app_webhooks; + + +-- +-- Name: COLUMN v2_agent_runs.status; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(status) ON TABLE public.v2_agent_runs TO app_gateway; +GRANT SELECT(status),UPDATE(status) ON TABLE public.v2_agent_runs TO app_agent; +GRANT SELECT(status) ON TABLE public.v2_agent_runs TO app_webhooks; + + +-- +-- Name: COLUMN v2_agent_runs.model_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(model_id),UPDATE(model_id) ON TABLE public.v2_agent_runs TO app_agent; + + +-- +-- Name: COLUMN v2_agent_runs.started_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(started_at) ON TABLE public.v2_agent_runs TO app_gateway; +GRANT SELECT(started_at) ON TABLE public.v2_agent_runs TO app_webhooks; + + +-- +-- Name: COLUMN v2_agent_runs.finished_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(finished_at) ON TABLE public.v2_agent_runs TO app_gateway; +GRANT UPDATE(finished_at) ON TABLE public.v2_agent_runs TO app_agent; +GRANT SELECT(finished_at) ON TABLE public.v2_agent_runs TO app_webhooks; + + +-- +-- Name: COLUMN v2_agent_runs.idempotency_key_hash; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(idempotency_key_hash) ON TABLE public.v2_agent_runs TO app_agent; + + +-- +-- Name: COLUMN v2_agent_runs.request_body_hash; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(request_body_hash) ON TABLE public.v2_agent_runs TO app_agent; + + +-- +-- Name: TABLE v2_artifact_upload_intents; Type: ACL; Schema: public; Owner: - +-- + +GRANT DELETE ON TABLE public.v2_artifact_upload_intents TO app_agent; +GRANT DELETE ON TABLE public.v2_artifact_upload_intents TO app_webhooks; + + +-- +-- Name: COLUMN v2_artifact_upload_intents.id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(id),INSERT(id) ON TABLE public.v2_artifact_upload_intents TO app_agent; +GRANT SELECT(id) ON TABLE public.v2_artifact_upload_intents TO app_webhooks; + + +-- +-- Name: COLUMN v2_artifact_upload_intents.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id),INSERT(user_id) ON TABLE public.v2_artifact_upload_intents TO app_agent; +GRANT SELECT(user_id) ON TABLE public.v2_artifact_upload_intents TO app_webhooks; + + +-- +-- Name: COLUMN v2_artifact_upload_intents.project_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(project_id),INSERT(project_id) ON TABLE public.v2_artifact_upload_intents TO app_agent; +GRANT SELECT(project_id) ON TABLE public.v2_artifact_upload_intents TO app_webhooks; + + +-- +-- Name: COLUMN v2_artifact_upload_intents.agent_run_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(agent_run_id),INSERT(agent_run_id) ON TABLE public.v2_artifact_upload_intents TO app_agent; +GRANT SELECT(agent_run_id) ON TABLE public.v2_artifact_upload_intents TO app_webhooks; + + +-- +-- Name: COLUMN v2_artifact_upload_intents.r2_key; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(r2_key),INSERT(r2_key) ON TABLE public.v2_artifact_upload_intents TO app_agent; +GRANT SELECT(r2_key) ON TABLE public.v2_artifact_upload_intents TO app_webhooks; + + +-- +-- Name: COLUMN v2_artifact_upload_intents.cleanup_not_before; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(cleanup_not_before),INSERT(cleanup_not_before),UPDATE(cleanup_not_before) ON TABLE public.v2_artifact_upload_intents TO app_agent; +GRANT SELECT(cleanup_not_before) ON TABLE public.v2_artifact_upload_intents TO app_webhooks; + + +-- +-- Name: COLUMN v2_artifact_upload_intents.quiesced_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(quiesced_at),UPDATE(quiesced_at) ON TABLE public.v2_artifact_upload_intents TO app_agent; +GRANT SELECT(quiesced_at) ON TABLE public.v2_artifact_upload_intents TO app_webhooks; + + +-- +-- Name: TABLE v2_daily_maintenance_jobs; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,DELETE ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.day; Type: ACL; Schema: public; Owner: - +-- + +GRANT INSERT(day) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.scheduled_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT INSERT(scheduled_at) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.phase; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(phase) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.activation_cursor_event; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(activation_cursor_event) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.activation_cursor_user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(activation_cursor_user_id) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.continuation; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(continuation) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.status; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(status) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.release_version_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(release_version_id) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.lease_token; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(lease_token) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.lease_expires_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(lease_expires_at) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.failure_count; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(failure_count) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.next_attempt_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(next_attempt_at) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.last_error_code; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(last_error_code) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_daily_maintenance_jobs.completed_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(completed_at) ON TABLE public.v2_daily_maintenance_jobs TO app_webhooks; + + +-- +-- Name: TABLE v2_entitlements; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,INSERT ON TABLE public.v2_entitlements TO app_gateway; +GRANT SELECT,INSERT ON TABLE public.v2_entitlements TO app_webhooks; + + +-- +-- Name: COLUMN v2_entitlements.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id) ON TABLE public.v2_entitlements TO app_agent; + + +-- +-- Name: COLUMN v2_entitlements.tier; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(tier) ON TABLE public.v2_entitlements TO app_agent; +GRANT UPDATE(tier) ON TABLE public.v2_entitlements TO app_webhooks; + + +-- +-- Name: COLUMN v2_entitlements.polar_subscription_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(polar_subscription_id) ON TABLE public.v2_entitlements TO app_gateway; +GRANT UPDATE(polar_subscription_id) ON TABLE public.v2_entitlements TO app_webhooks; + + +-- +-- Name: COLUMN v2_entitlements.subscription_status; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(subscription_status) ON TABLE public.v2_entitlements TO app_gateway; +GRANT SELECT(subscription_status) ON TABLE public.v2_entitlements TO app_agent; +GRANT UPDATE(subscription_status) ON TABLE public.v2_entitlements TO app_webhooks; + + +-- +-- Name: COLUMN v2_entitlements.current_period_start; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(current_period_start) ON TABLE public.v2_entitlements TO app_gateway; +GRANT SELECT(current_period_start) ON TABLE public.v2_entitlements TO app_agent; +GRANT UPDATE(current_period_start) ON TABLE public.v2_entitlements TO app_webhooks; + + +-- +-- Name: COLUMN v2_entitlements.current_period_end; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(current_period_end) ON TABLE public.v2_entitlements TO app_gateway; +GRANT SELECT(current_period_end) ON TABLE public.v2_entitlements TO app_agent; +GRANT UPDATE(current_period_end) ON TABLE public.v2_entitlements TO app_webhooks; + + +-- +-- Name: COLUMN v2_entitlements.updated_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(updated_at) ON TABLE public.v2_entitlements TO app_gateway; +GRANT SELECT(updated_at) ON TABLE public.v2_entitlements TO app_agent; +GRANT UPDATE(updated_at) ON TABLE public.v2_entitlements TO app_webhooks; + + +-- +-- Name: COLUMN v2_entitlements.cancel_at_period_end; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(cancel_at_period_end) ON TABLE public.v2_entitlements TO app_gateway; +GRANT UPDATE(cancel_at_period_end) ON TABLE public.v2_entitlements TO app_webhooks; + + +-- +-- Name: TABLE v2_generated_outputs; Type: ACL; Schema: public; Owner: - +-- + +GRANT INSERT ON TABLE public.v2_generated_outputs TO app_agent; +GRANT DELETE ON TABLE public.v2_generated_outputs TO app_webhooks; + + +-- +-- Name: COLUMN v2_generated_outputs.id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(id) ON TABLE public.v2_generated_outputs TO app_agent; +GRANT SELECT(id) ON TABLE public.v2_generated_outputs TO app_webhooks; + + +-- +-- Name: COLUMN v2_generated_outputs.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id) ON TABLE public.v2_generated_outputs TO app_agent; +GRANT SELECT(user_id) ON TABLE public.v2_generated_outputs TO app_webhooks; + + +-- +-- Name: COLUMN v2_generated_outputs.agent_run_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(agent_run_id) ON TABLE public.v2_generated_outputs TO app_webhooks; +GRANT SELECT(agent_run_id) ON TABLE public.v2_generated_outputs TO app_agent; + + +-- +-- Name: COLUMN v2_generated_outputs.filename; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(filename) ON TABLE public.v2_generated_outputs TO app_agent; + + +-- +-- Name: COLUMN v2_generated_outputs.r2_key; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(r2_key) ON TABLE public.v2_generated_outputs TO app_agent; +GRANT SELECT(r2_key) ON TABLE public.v2_generated_outputs TO app_webhooks; + + +-- +-- Name: COLUMN v2_generated_outputs.mime_type; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(mime_type) ON TABLE public.v2_generated_outputs TO app_agent; + + +-- +-- Name: TABLE v2_messages; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT ON TABLE public.v2_messages TO app_gateway; +GRANT SELECT,INSERT ON TABLE public.v2_messages TO app_agent; + + +-- +-- Name: TABLE v2_projects; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,INSERT ON TABLE public.v2_projects TO app_gateway; +GRANT SELECT,INSERT ON TABLE public.v2_projects TO app_agent; +GRANT DELETE ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(id) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.name; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(name) ON TABLE public.v2_projects TO app_gateway; +GRANT SELECT(name) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.settings; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(settings) ON TABLE public.v2_projects TO app_gateway; + + +-- +-- Name: COLUMN v2_projects.created_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(created_at) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.updated_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(updated_at) ON TABLE public.v2_projects TO app_gateway; +GRANT SELECT(updated_at),UPDATE(updated_at) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.deleted_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(deleted_at) ON TABLE public.v2_projects TO app_gateway; +GRANT SELECT(deleted_at),UPDATE(deleted_at) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.over_quota; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(over_quota),UPDATE(over_quota) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.archive_after; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(archive_after),UPDATE(archive_after) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_projects.workspace_slug; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(workspace_slug),UPDATE(workspace_slug) ON TABLE public.v2_projects TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id) ON TABLE public.v2_provider_keys TO app_gateway; +GRANT SELECT(user_id) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.provider; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(provider) ON TABLE public.v2_provider_keys TO app_gateway; +GRANT SELECT(provider) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.fingerprint; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(fingerprint) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.created_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(created_at) ON TABLE public.v2_provider_keys TO app_gateway; +GRANT SELECT(created_at) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.disabled_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(disabled_at),UPDATE(disabled_at) ON TABLE public.v2_provider_keys TO app_gateway; +GRANT SELECT(disabled_at),UPDATE(disabled_at) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.disabled_reason; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(disabled_reason),UPDATE(disabled_reason) ON TABLE public.v2_provider_keys TO app_gateway; +GRANT SELECT(disabled_reason),UPDATE(disabled_reason) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.last_revalidated_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(last_revalidated_at) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.revalidation_claimed_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(revalidation_claimed_at),UPDATE(revalidation_claimed_at) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: COLUMN v2_provider_keys.revalidation_lease_token; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(revalidation_lease_token),UPDATE(revalidation_lease_token) ON TABLE public.v2_provider_keys TO app_webhooks; + + +-- +-- Name: TABLE v2_resource_deletion_jobs; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,INSERT,DELETE ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.phase; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(phase) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.cursor; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(cursor) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.continuation; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(continuation) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.status; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(status) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.lease_token; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(lease_token) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.lease_expires_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(lease_expires_at) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.failure_count; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(failure_count) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.next_attempt_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(next_attempt_at) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_resource_deletion_jobs.last_error_code; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(last_error_code) ON TABLE public.v2_resource_deletion_jobs TO app_webhooks; + + +-- +-- Name: TABLE v2_threads; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,INSERT ON TABLE public.v2_threads TO app_gateway; +GRANT SELECT ON TABLE public.v2_threads TO app_agent; +GRANT DELETE ON TABLE public.v2_threads TO app_webhooks; + + +-- +-- Name: COLUMN v2_threads.id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(id) ON TABLE public.v2_threads TO app_webhooks; + + +-- +-- Name: COLUMN v2_threads.project_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(project_id) ON TABLE public.v2_threads TO app_agent; +GRANT SELECT(project_id) ON TABLE public.v2_threads TO app_webhooks; + + +-- +-- Name: COLUMN v2_threads.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id) ON TABLE public.v2_threads TO app_webhooks; + + +-- +-- Name: COLUMN v2_threads.title; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(title) ON TABLE public.v2_threads TO app_gateway; + + +-- +-- Name: COLUMN v2_threads.active_run_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(active_run_id) ON TABLE public.v2_threads TO app_agent; +GRANT SELECT(active_run_id),UPDATE(active_run_id) ON TABLE public.v2_threads TO app_webhooks; + + +-- +-- Name: COLUMN v2_threads.updated_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(updated_at) ON TABLE public.v2_threads TO app_gateway; +GRANT UPDATE(updated_at) ON TABLE public.v2_threads TO app_agent; +GRANT UPDATE(updated_at) ON TABLE public.v2_threads TO app_webhooks; + + +-- +-- Name: COLUMN v2_threads.deleted_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(deleted_at) ON TABLE public.v2_threads TO app_gateway; +GRANT SELECT(deleted_at),UPDATE(deleted_at) ON TABLE public.v2_threads TO app_webhooks; + + +-- +-- Name: COLUMN v2_threads.launch_intent; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(launch_intent) ON TABLE public.v2_threads TO app_agent; + + +-- +-- Name: COLUMN v2_threads.latest_model_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(latest_model_id) ON TABLE public.v2_threads TO app_gateway; +GRANT UPDATE(latest_model_id) ON TABLE public.v2_threads TO app_agent; + + +-- +-- Name: TABLE v2_user_deletion_jobs; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,INSERT,DELETE ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.phase; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(phase) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.cursor; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(cursor) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.continuation; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(continuation) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.status; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(status) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.lease_token; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(lease_token) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.lease_expires_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(lease_expires_at) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.failure_count; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(failure_count) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.next_attempt_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(next_attempt_at) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_deletion_jobs.last_error_code; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(last_error_code) ON TABLE public.v2_user_deletion_jobs TO app_webhooks; + + +-- +-- Name: TABLE v2_user_deletion_refund_intents; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT ON TABLE public.v2_user_deletion_refund_intents TO app_webhooks; + + +-- +-- Name: TABLE v2_user_integrations; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,INSERT,DELETE ON TABLE public.v2_user_integrations TO app_gateway; + + +-- +-- Name: COLUMN v2_user_integrations.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id) ON TABLE public.v2_user_integrations TO app_agent; +GRANT SELECT(user_id) ON TABLE public.v2_user_integrations TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_integrations.integration; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(integration) ON TABLE public.v2_user_integrations TO app_agent; +GRANT SELECT(integration) ON TABLE public.v2_user_integrations TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_integrations.composio_connection_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(composio_connection_id) ON TABLE public.v2_user_integrations TO app_agent; +GRANT SELECT(composio_connection_id) ON TABLE public.v2_user_integrations TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_integrations.status; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(status) ON TABLE public.v2_user_integrations TO app_gateway; +GRANT SELECT(status) ON TABLE public.v2_user_integrations TO app_agent; +GRANT SELECT(status) ON TABLE public.v2_user_integrations TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_integrations.updated_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(updated_at) ON TABLE public.v2_user_integrations TO app_agent; +GRANT SELECT(updated_at) ON TABLE public.v2_user_integrations TO app_webhooks; + + +-- +-- Name: COLUMN v2_user_integrations.is_default; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(is_default) ON TABLE public.v2_user_integrations TO app_gateway; +GRANT SELECT(is_default) ON TABLE public.v2_user_integrations TO app_agent; +GRANT SELECT(is_default) ON TABLE public.v2_user_integrations TO app_webhooks; + + +-- +-- Name: TABLE v2_user_profiles; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,INSERT ON TABLE public.v2_user_profiles TO app_gateway; + + +-- +-- Name: COLUMN v2_user_profiles.user_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(user_id) ON TABLE public.v2_user_profiles TO app_agent; + + +-- +-- Name: COLUMN v2_user_profiles.agent_display_name; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(agent_display_name) ON TABLE public.v2_user_profiles TO app_gateway; +GRANT SELECT(agent_display_name) ON TABLE public.v2_user_profiles TO app_agent; + + +-- +-- Name: COLUMN v2_user_profiles.global_memory; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(global_memory) ON TABLE public.v2_user_profiles TO app_gateway; +GRANT SELECT(global_memory) ON TABLE public.v2_user_profiles TO app_agent; + + +-- +-- Name: COLUMN v2_user_profiles.disabled_models; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(disabled_models) ON TABLE public.v2_user_profiles TO app_gateway; +GRANT SELECT(disabled_models) ON TABLE public.v2_user_profiles TO app_agent; + + +-- +-- Name: COLUMN v2_user_profiles.onboarding_completed_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(onboarding_completed_at) ON TABLE public.v2_user_profiles TO app_gateway; + + +-- +-- Name: COLUMN v2_user_profiles.onboarding_state; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(onboarding_state) ON TABLE public.v2_user_profiles TO app_gateway; + + +-- +-- Name: TABLE v2_user_skills; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT,INSERT,DELETE ON TABLE public.v2_user_skills TO app_gateway; +GRANT SELECT,INSERT ON TABLE public.v2_user_skills TO app_agent; + + +-- +-- Name: COLUMN v2_user_skills.description; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(description) ON TABLE public.v2_user_skills TO app_gateway; +GRANT UPDATE(description) ON TABLE public.v2_user_skills TO app_agent; + + +-- +-- Name: COLUMN v2_user_skills.category; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(category) ON TABLE public.v2_user_skills TO app_gateway; +GRANT UPDATE(category) ON TABLE public.v2_user_skills TO app_agent; + + +-- +-- Name: COLUMN v2_user_skills.tags; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(tags) ON TABLE public.v2_user_skills TO app_gateway; +GRANT UPDATE(tags) ON TABLE public.v2_user_skills TO app_agent; + + +-- +-- Name: COLUMN v2_user_skills.body; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(body) ON TABLE public.v2_user_skills TO app_gateway; +GRANT UPDATE(body) ON TABLE public.v2_user_skills TO app_agent; + + +-- +-- Name: COLUMN v2_user_skills.updated_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT UPDATE(updated_at) ON TABLE public.v2_user_skills TO app_gateway; +GRANT UPDATE(updated_at) ON TABLE public.v2_user_skills TO app_agent; + + +-- +-- Name: COLUMN v2_users.id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(id) ON TABLE public.v2_users TO app_gateway; +GRANT SELECT(id) ON TABLE public.v2_users TO app_agent; +GRANT SELECT(id) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.clerk_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(clerk_id) ON TABLE public.v2_users TO app_gateway; +GRANT SELECT(clerk_id) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.email; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(email) ON TABLE public.v2_users TO app_gateway; +GRANT SELECT(email) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.polar_customer_id; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(polar_customer_id) ON TABLE public.v2_users TO app_gateway; +GRANT SELECT(polar_customer_id),UPDATE(polar_customer_id) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.created_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(created_at) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.deleted_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(deleted_at) ON TABLE public.v2_users TO app_gateway; +GRANT SELECT(deleted_at) ON TABLE public.v2_users TO app_agent; +GRANT SELECT(deleted_at),UPDATE(deleted_at) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.display_name; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(display_name),UPDATE(display_name) ON TABLE public.v2_users TO app_gateway; +GRANT SELECT(display_name) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.avatar_url; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(avatar_url) ON TABLE public.v2_users TO app_gateway; +GRANT SELECT(avatar_url) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.deletion_fence; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(deletion_fence) ON TABLE public.v2_users TO app_gateway; +GRANT SELECT(deletion_fence) ON TABLE public.v2_users TO app_agent; +GRANT SELECT(deletion_fence),UPDATE(deletion_fence) ON TABLE public.v2_users TO app_webhooks; + + +-- +-- Name: COLUMN v2_users.first_artifact_at; Type: ACL; Schema: public; Owner: - +-- + +GRANT SELECT(first_artifact_at),UPDATE(first_artifact_at) ON TABLE public.v2_users TO app_agent; + + +-- +-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: - +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres; + + +-- +-- Name: DEFAULT PRIVILEGES FOR SEQUENCES; Type: DEFAULT ACL; Schema: public; Owner: - +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO anon; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role; + + +-- +-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: public; Owner: - +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres; + + +-- +-- Name: DEFAULT PRIVILEGES FOR FUNCTIONS; Type: DEFAULT ACL; Schema: public; Owner: - +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role; + + +-- +-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: - +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO postgres; + + +-- +-- Name: DEFAULT PRIVILEGES FOR TABLES; Type: DEFAULT ACL; Schema: public; Owner: - +-- + +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO postgres; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO anon; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO authenticated; +ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO service_role; + + +-- +-- PostgreSQL database dump complete +-- + diff --git a/packages/db/drizzle/0000_yielding_wallflower.sql b/packages/db/drizzle/0000_yielding_wallflower.sql deleted file mode 100644 index c39c205e..00000000 --- a/packages/db/drizzle/0000_yielding_wallflower.sql +++ /dev/null @@ -1,182 +0,0 @@ -CREATE TABLE "v2_agent_runs" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "thread_id" uuid NOT NULL, - "user_id" uuid NOT NULL, - "status" text NOT NULL, - "model_id" text, - "tokens_in" integer DEFAULT 0 NOT NULL, - "tokens_out" integer DEFAULT 0 NOT NULL, - "tokens_cached" integer DEFAULT 0 NOT NULL, - "cost_usd" numeric(12, 6) DEFAULT '0' NOT NULL, - "config" jsonb DEFAULT '{}'::jsonb NOT NULL, - "error" jsonb, - "started_at" timestamp with time zone DEFAULT now() NOT NULL, - "finished_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "v2_billing_events" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid, - "event_type" text NOT NULL, - "polar_event_id" text, - "payload" jsonb, - "processed_at" timestamp with time zone DEFAULT now(), - CONSTRAINT "v2_billing_events_polar_event_id_unique" UNIQUE("polar_event_id") -); ---> statement-breakpoint -CREATE TABLE "v2_entitlements" ( - "user_id" uuid PRIMARY KEY NOT NULL, - "tier" text DEFAULT 'free' NOT NULL, - "polar_customer_id" text, - "polar_subscription_id" text, - "subscription_status" text DEFAULT 'none' NOT NULL, - "cancel_at_period_end" boolean DEFAULT false NOT NULL, - "current_period_start" timestamp with time zone, - "current_period_end" timestamp with time zone, - "max_projects" integer DEFAULT 3 NOT NULL, - "max_concurrent_sandboxes" integer DEFAULT 1 NOT NULL, - "max_seats" integer DEFAULT 1 NOT NULL, - "quota_sandbox_hours" numeric DEFAULT '5' NOT NULL, - "quota_composio_calls" integer DEFAULT 1000 NOT NULL, - "quota_deployments" integer DEFAULT 5 NOT NULL, - "flag_private_projects" boolean DEFAULT false NOT NULL, - "flag_sso" boolean DEFAULT false NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "webhook_event_id" text, - "source" text, - CONSTRAINT "v2_entitlements_tier_check" CHECK ("v2_entitlements"."tier" in ('free','pro','team','enterprise')) -); ---> statement-breakpoint -CREATE TABLE "v2_generated_outputs" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid NOT NULL, - "project_id" uuid, - "agent_run_id" uuid, - "kind" text NOT NULL, - "filename" text NOT NULL, - "r2_bucket" text DEFAULT 'cheatcode-outputs' NOT NULL, - "r2_key" text NOT NULL, - "mime_type" text NOT NULL, - "size_bytes" bigint NOT NULL, - "sha256" text, - "metadata" jsonb DEFAULT '{}'::jsonb NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "expires_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "v2_messages" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "thread_id" uuid NOT NULL, - "user_id" uuid NOT NULL, - "role" text NOT NULL, - "parts" jsonb NOT NULL, - "agent_run_id" uuid, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "v2_projects" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid NOT NULL, - "name" text NOT NULL, - "mode" text NOT NULL, - "master_instructions" text, - "sandbox_id" text, - "container_backup" jsonb, - "settings" jsonb DEFAULT '{}'::jsonb NOT NULL, - "over_quota" boolean DEFAULT false NOT NULL, - "archived_pending_action" boolean DEFAULT false NOT NULL, - "archive_after" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "v2_provider_keys" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid NOT NULL, - "provider" text NOT NULL, - "vault_secret_id" uuid NOT NULL, - "fingerprint" text NOT NULL, - "last_used_at" timestamp with time zone, - "disabled_at" timestamp with time zone, - "disabled_reason" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "v2_threads" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "project_id" uuid NOT NULL, - "user_id" uuid NOT NULL, - "title" text, - "active_run_id" uuid, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "v2_usage_daily_totals" ( - "user_id" uuid NOT NULL, - "day" date NOT NULL, - "total_input_tokens" bigint DEFAULT 0 NOT NULL, - "total_output_tokens" bigint DEFAULT 0 NOT NULL, - "total_cached_tokens" bigint DEFAULT 0 NOT NULL, - "total_cost_usd" numeric(12, 4) DEFAULT '0' NOT NULL, - "agent_run_count" integer DEFAULT 0 NOT NULL, - CONSTRAINT "v2_usage_daily_totals_user_id_day_pk" PRIMARY KEY("user_id","day") -); ---> statement-breakpoint -CREATE TABLE "v2_usage_events" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid NOT NULL, - "agent_run_id" uuid, - "event_type" text NOT NULL, - "provider" text, - "model" text, - "input_tokens" integer DEFAULT 0 NOT NULL, - "output_tokens" integer DEFAULT 0 NOT NULL, - "cached_tokens" integer DEFAULT 0 NOT NULL, - "cost_usd" numeric(12, 6) DEFAULT '0' NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "v2_user_integrations" ( - "user_id" uuid NOT NULL, - "integration" text NOT NULL, - "composio_connection_id" text NOT NULL, - "status" text NOT NULL, - "connected_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - CONSTRAINT "v2_user_integrations_user_id_integration_pk" PRIMARY KEY("user_id","integration") -); ---> statement-breakpoint -CREATE TABLE "v2_users" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "clerk_id" text NOT NULL, - "email" text NOT NULL, - "display_name" text, - "avatar_url" text, - "polar_customer_id" text, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone, - CONSTRAINT "v2_users_clerk_id_unique" UNIQUE("clerk_id"), - CONSTRAINT "v2_users_polar_customer_id_unique" UNIQUE("polar_customer_id") -); ---> statement-breakpoint -ALTER TABLE "v2_agent_runs" ADD CONSTRAINT "v2_agent_runs_thread_id_v2_threads_id_fk" FOREIGN KEY ("thread_id") REFERENCES "public"."v2_threads"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_agent_runs" ADD CONSTRAINT "v2_agent_runs_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_billing_events" ADD CONSTRAINT "v2_billing_events_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_entitlements" ADD CONSTRAINT "v2_entitlements_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_generated_outputs" ADD CONSTRAINT "v2_generated_outputs_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_generated_outputs" ADD CONSTRAINT "v2_generated_outputs_project_id_v2_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."v2_projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_generated_outputs" ADD CONSTRAINT "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk" FOREIGN KEY ("agent_run_id") REFERENCES "public"."v2_agent_runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_messages" ADD CONSTRAINT "v2_messages_thread_id_v2_threads_id_fk" FOREIGN KEY ("thread_id") REFERENCES "public"."v2_threads"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_messages" ADD CONSTRAINT "v2_messages_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_projects" ADD CONSTRAINT "v2_projects_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_provider_keys" ADD CONSTRAINT "v2_provider_keys_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_threads" ADD CONSTRAINT "v2_threads_project_id_v2_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."v2_projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_threads" ADD CONSTRAINT "v2_threads_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_usage_daily_totals" ADD CONSTRAINT "v2_usage_daily_totals_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_usage_events" ADD CONSTRAINT "v2_usage_events_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_user_integrations" ADD CONSTRAINT "v2_user_integrations_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action; diff --git a/packages/db/drizzle/0001_lonely_captain_universe.sql b/packages/db/drizzle/0001_lonely_captain_universe.sql deleted file mode 100644 index f53b89f8..00000000 --- a/packages/db/drizzle/0001_lonely_captain_universe.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "v2_projects" ALTER COLUMN "over_quota" SET DEFAULT false;--> statement-breakpoint -ALTER TABLE "v2_projects" ALTER COLUMN "archived_pending_action" SET DEFAULT false; \ No newline at end of file diff --git a/packages/db/drizzle/0002_amazing_puck.sql b/packages/db/drizzle/0002_amazing_puck.sql deleted file mode 100644 index f3e22852..00000000 --- a/packages/db/drizzle/0002_amazing_puck.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "v2_user_profiles" ( - "user_id" uuid PRIMARY KEY NOT NULL, - "agent_display_name" text, - "global_memory" text, - "appbuilder_default_model" text, - "general_default_model" text, - "appbuilder_default_budget_usd" numeric(10, 2), - "general_default_budget_usd" numeric(10, 2), - "disabled_models" jsonb DEFAULT '[]'::jsonb NOT NULL, - "onboarding_completed_at" timestamp with time zone, - "onboarding_state" jsonb DEFAULT '{}'::jsonb NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -ALTER TABLE "v2_user_profiles" ADD CONSTRAINT "v2_user_profiles_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action; \ No newline at end of file diff --git a/packages/db/drizzle/0003_v2_billing_tier_premium_ultra_max.sql b/packages/db/drizzle/0003_v2_billing_tier_premium_ultra_max.sql deleted file mode 100644 index 86511f4b..00000000 --- a/packages/db/drizzle/0003_v2_billing_tier_premium_ultra_max.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE "v2_entitlements" DROP CONSTRAINT IF EXISTS "v2_entitlements_tier_check";--> statement-breakpoint -UPDATE "v2_entitlements" SET "tier" = 'premium' WHERE "tier" = 'team';--> statement-breakpoint -UPDATE "v2_entitlements" SET "tier" = 'max' WHERE "tier" = 'enterprise';--> statement-breakpoint -ALTER TABLE "v2_entitlements" ADD CONSTRAINT "v2_entitlements_tier_check" CHECK ("v2_entitlements"."tier" in ('free','pro','premium','ultra','max')); diff --git a/packages/db/drizzle/0004_amused_steve_rogers.sql b/packages/db/drizzle/0004_amused_steve_rogers.sql deleted file mode 100644 index b4ea6e69..00000000 --- a/packages/db/drizzle/0004_amused_steve_rogers.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "v2_entitlements" ADD COLUMN "free_deepseek_tokens_used" bigint DEFAULT 0 NOT NULL; \ No newline at end of file diff --git a/packages/db/drizzle/0005_absent_sir_ram.sql b/packages/db/drizzle/0005_absent_sir_ram.sql deleted file mode 100644 index 0c0197f5..00000000 --- a/packages/db/drizzle/0005_absent_sir_ram.sql +++ /dev/null @@ -1,64 +0,0 @@ -CREATE TABLE "v2_automation_run_requests" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "automation_id" uuid NOT NULL, - "user_id" uuid NOT NULL, - "source" text NOT NULL, - "dedupe_key" text NOT NULL, - "scheduled_for" timestamp with time zone, - "status" text DEFAULT 'pending' NOT NULL, - "claimed_at" timestamp with time zone, - "attempts" integer DEFAULT 0 NOT NULL, - "normalized" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "v2_automation_runs" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "automation_id" uuid NOT NULL, - "request_id" uuid, - "user_id" uuid NOT NULL, - "thread_id" uuid, - "status" text DEFAULT 'running' NOT NULL, - "summary" text, - "error" text, - "deliveries" jsonb DEFAULT '[]'::jsonb NOT NULL, - "started_at" timestamp with time zone DEFAULT now() NOT NULL, - "finished_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "v2_automations" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid NOT NULL, - "project_id" uuid, - "name" text NOT NULL, - "status" text DEFAULT 'running' NOT NULL, - "kind" text NOT NULL, - "schedule" text, - "trigger_toolkit" text, - "trigger_slug" text, - "trigger_id" text, - "prompt" text NOT NULL, - "model" text, - "delivery_channels" jsonb DEFAULT '[]'::jsonb NOT NULL, - "next_run_at" timestamp with time zone, - "last_run_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone -); ---> statement-breakpoint -ALTER TABLE "v2_automation_run_requests" ADD CONSTRAINT "v2_automation_run_requests_automation_id_v2_automations_id_fk" FOREIGN KEY ("automation_id") REFERENCES "public"."v2_automations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_automation_run_requests" ADD CONSTRAINT "v2_automation_run_requests_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_automation_runs" ADD CONSTRAINT "v2_automation_runs_automation_id_v2_automations_id_fk" FOREIGN KEY ("automation_id") REFERENCES "public"."v2_automations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_automation_runs" ADD CONSTRAINT "v2_automation_runs_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_automations" ADD CONSTRAINT "v2_automations_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_automations" ADD CONSTRAINT "v2_automations_project_id_v2_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."v2_projects"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "v2_automation_run_requests_dedupe_idx" ON "v2_automation_run_requests" USING btree ("dedupe_key");--> statement-breakpoint -CREATE INDEX "v2_automation_run_requests_status_idx" ON "v2_automation_run_requests" USING btree ("status","claimed_at");--> statement-breakpoint -CREATE INDEX "v2_automation_run_requests_automation_idx" ON "v2_automation_run_requests" USING btree ("automation_id");--> statement-breakpoint -CREATE INDEX "v2_automation_runs_automation_idx" ON "v2_automation_runs" USING btree ("automation_id","started_at");--> statement-breakpoint -CREATE UNIQUE INDEX "v2_automation_runs_active_idx" ON "v2_automation_runs" USING btree ("automation_id") WHERE status in ('running');--> statement-breakpoint -CREATE INDEX "v2_automations_user_idx" ON "v2_automations" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "v2_automations_due_idx" ON "v2_automations" USING btree ("status","next_run_at");--> statement-breakpoint -CREATE INDEX "v2_automations_trigger_idx" ON "v2_automations" USING btree ("trigger_id"); \ No newline at end of file diff --git a/packages/db/drizzle/0006_dashing_magneto.sql b/packages/db/drizzle/0006_dashing_magneto.sql deleted file mode 100644 index c0e6a3fd..00000000 --- a/packages/db/drizzle/0006_dashing_magneto.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "v2_replay_shares" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid NOT NULL, - "thread_id" uuid NOT NULL, - "visibility" text DEFAULT 'unlisted' NOT NULL, - "title" text NOT NULL, - "author_name" text NOT NULL, - "revoked_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -ALTER TABLE "v2_replay_shares" ADD CONSTRAINT "v2_replay_shares_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "v2_replay_shares" ADD CONSTRAINT "v2_replay_shares_thread_id_v2_threads_id_fk" FOREIGN KEY ("thread_id") REFERENCES "public"."v2_threads"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "v2_replay_shares_user_idx" ON "v2_replay_shares" USING btree ("user_id");--> statement-breakpoint -CREATE UNIQUE INDEX "v2_replay_shares_thread_active_idx" ON "v2_replay_shares" USING btree ("thread_id") WHERE revoked_at is null; diff --git a/packages/db/drizzle/0007_ambiguous_thunderball.sql b/packages/db/drizzle/0007_ambiguous_thunderball.sql deleted file mode 100644 index be89c1a6..00000000 --- a/packages/db/drizzle/0007_ambiguous_thunderball.sql +++ /dev/null @@ -1,16 +0,0 @@ -CREATE TABLE "v2_user_skills" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid NOT NULL, - "name" text NOT NULL, - "description" text NOT NULL, - "category" text NOT NULL, - "tags" jsonb DEFAULT '[]'::jsonb NOT NULL, - "body" text NOT NULL, - "created_at" timestamp with time zone DEFAULT now() NOT NULL, - "updated_at" timestamp with time zone DEFAULT now() NOT NULL, - "deleted_at" timestamp with time zone -); ---> statement-breakpoint -ALTER TABLE "v2_user_skills" ADD CONSTRAINT "v2_user_skills_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "v2_user_skills_user_idx" ON "v2_user_skills" USING btree ("user_id");--> statement-breakpoint -CREATE UNIQUE INDEX "v2_user_skills_user_name_idx" ON "v2_user_skills" USING btree ("user_id","name") WHERE deleted_at is null; \ No newline at end of file diff --git a/packages/db/drizzle/0008_fixed_maggott.sql b/packages/db/drizzle/0008_fixed_maggott.sql deleted file mode 100644 index b3531654..00000000 --- a/packages/db/drizzle/0008_fixed_maggott.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX "v2_threads_user_recent_idx" ON "v2_threads" USING btree ("user_id","updated_at" DESC NULLS LAST) WHERE deleted_at is null; \ No newline at end of file diff --git a/packages/db/drizzle/0009_vengeful_mother_askani.sql b/packages/db/drizzle/0009_vengeful_mother_askani.sql deleted file mode 100644 index 4444f666..00000000 --- a/packages/db/drizzle/0009_vengeful_mother_askani.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "v2_threads" ALTER COLUMN "project_id" DROP NOT NULL;--> statement-breakpoint -ALTER TABLE "v2_threads" ADD COLUMN "launch_intent" jsonb; \ No newline at end of file diff --git a/packages/db/drizzle/0010_drop_obsolete_share_table.sql b/packages/db/drizzle/0010_drop_obsolete_share_table.sql deleted file mode 100644 index 9a617bf4..00000000 --- a/packages/db/drizzle/0010_drop_obsolete_share_table.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS "v2_replay_shares"; diff --git a/packages/db/drizzle/0011_per_user_sandbox_workspace_slug.sql b/packages/db/drizzle/0011_per_user_sandbox_workspace_slug.sql deleted file mode 100644 index 887cc6e4..00000000 --- a/packages/db/drizzle/0011_per_user_sandbox_workspace_slug.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "v2_projects" ADD COLUMN "workspace_slug" text; \ No newline at end of file diff --git a/packages/db/drizzle/0012_marvelous_vertigo.sql b/packages/db/drizzle/0012_marvelous_vertigo.sql deleted file mode 100644 index ac491bed..00000000 --- a/packages/db/drizzle/0012_marvelous_vertigo.sql +++ /dev/null @@ -1,6 +0,0 @@ --- Backfill legacy null slugs FIRST so (a) the partial unique index can build and (b) pre-migration --- projects stop collapsing onto the shared /workspace/app sentinel. 'p-' + the row's own uuid (hex, --- dashless) is globally unique, so no per-user collision and no clash with name-derived slugs. -UPDATE "v2_projects" SET "workspace_slug" = 'p-' || replace("id"::text, '-', '') WHERE "workspace_slug" IS NULL; ---> statement-breakpoint -CREATE UNIQUE INDEX "v2_projects_user_workspace_slug_uidx" ON "v2_projects" USING btree ("user_id","workspace_slug") WHERE workspace_slug is not null; diff --git a/packages/db/drizzle/0013_special_lorna_dane.sql b/packages/db/drizzle/0013_special_lorna_dane.sql deleted file mode 100644 index 318f9723..00000000 --- a/packages/db/drizzle/0013_special_lorna_dane.sql +++ /dev/null @@ -1,3 +0,0 @@ -DROP INDEX "v2_projects_user_workspace_slug_uidx";--> statement-breakpoint -ALTER TABLE "v2_projects" ALTER COLUMN "workspace_slug" SET NOT NULL;--> statement-breakpoint -CREATE UNIQUE INDEX "v2_projects_user_workspace_slug_uidx" ON "v2_projects" USING btree ("user_id","workspace_slug"); \ No newline at end of file diff --git a/packages/db/drizzle/0014_strange_jackal.sql b/packages/db/drizzle/0014_strange_jackal.sql deleted file mode 100644 index 90c6dec1..00000000 --- a/packages/db/drizzle/0014_strange_jackal.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE "v2_user_profiles" DROP COLUMN "appbuilder_default_model";--> statement-breakpoint -ALTER TABLE "v2_user_profiles" DROP COLUMN "general_default_model";--> statement-breakpoint -ALTER TABLE "v2_user_profiles" DROP COLUMN "appbuilder_default_budget_usd";--> statement-breakpoint -ALTER TABLE "v2_user_profiles" DROP COLUMN "general_default_budget_usd"; \ No newline at end of file diff --git a/packages/db/drizzle/0015_dazzling_captain_marvel.sql b/packages/db/drizzle/0015_dazzling_captain_marvel.sql deleted file mode 100644 index 1a896ba7..00000000 --- a/packages/db/drizzle/0015_dazzling_captain_marvel.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE "v2_user_integrations" DROP CONSTRAINT "v2_user_integrations_user_id_integration_pk";--> statement-breakpoint -ALTER TABLE "v2_user_integrations" ADD CONSTRAINT "v2_user_integrations_user_id_composio_connection_id_pk" PRIMARY KEY("user_id","composio_connection_id");--> statement-breakpoint -ALTER TABLE "v2_user_integrations" ADD COLUMN "is_default" boolean DEFAULT false NOT NULL;--> statement-breakpoint -UPDATE "v2_user_integrations" SET "is_default" = true;--> statement-breakpoint -CREATE UNIQUE INDEX "v2_user_integrations_one_default_idx" ON "v2_user_integrations" USING btree ("user_id","integration") WHERE "v2_user_integrations"."is_default" = true;--> statement-breakpoint -CREATE INDEX "v2_user_integrations_user_toolkit_idx" ON "v2_user_integrations" USING btree ("user_id","integration"); diff --git a/packages/db/drizzle/0016_early_cargill.sql b/packages/db/drizzle/0016_early_cargill.sql deleted file mode 100644 index f018c28a..00000000 --- a/packages/db/drizzle/0016_early_cargill.sql +++ /dev/null @@ -1,16 +0,0 @@ --- The automation product surface is intentionally removed with no runtime compatibility --- layer. Preserve existing customer data under retired names so this release cannot turn --- an application cleanup into an implicit production data-destruction event. A later, --- separately approved retention migration may export and drop these retired tables. -ALTER TABLE IF EXISTS "v2_automation_run_requests" - RENAME TO "v2_retired_automation_run_requests_20260715";--> statement-breakpoint -ALTER TABLE IF EXISTS "v2_automation_runs" - RENAME TO "v2_retired_automation_runs_20260715";--> statement-breakpoint -ALTER TABLE IF EXISTS "v2_automations" - RENAME TO "v2_retired_automations_20260715";--> statement-breakpoint - -REVOKE ALL ON TABLE - "v2_retired_automation_run_requests_20260715", - "v2_retired_automation_runs_20260715", - "v2_retired_automations_20260715" -FROM app_worker; diff --git a/packages/db/drizzle/0017_normalize_per_user_sandbox_limit.sql b/packages/db/drizzle/0017_normalize_per_user_sandbox_limit.sql deleted file mode 100644 index fec9964a..00000000 --- a/packages/db/drizzle/0017_normalize_per_user_sandbox_limit.sql +++ /dev/null @@ -1,4 +0,0 @@ -UPDATE "v2_entitlements" -SET "max_concurrent_sandboxes" = 1, - "updated_at" = now() -WHERE "max_concurrent_sandboxes" <> 1; diff --git a/packages/db/drizzle/0018_remove_token_cost_accounting.sql b/packages/db/drizzle/0018_remove_token_cost_accounting.sql deleted file mode 100644 index e919bf50..00000000 --- a/packages/db/drizzle/0018_remove_token_cost_accounting.sql +++ /dev/null @@ -1,3 +0,0 @@ --- The generated schema snapshot removes model-token accounting. Its destructive --- SQL runs in the post-deploy phase so token-free Workers are live first. See --- infra/supabase/migrations/post/0029_remove_token_cost_accounting.sql. diff --git a/packages/db/drizzle/0019_composio_connection_identity.sql b/packages/db/drizzle/0019_composio_connection_identity.sql deleted file mode 100644 index f0e93b45..00000000 --- a/packages/db/drizzle/0019_composio_connection_identity.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Snapshot marker only. Entitlement contractions are staged in raw migration --- 0030. Composio connection identity expands in 0031 before the new Workers --- deploy, then its primary-key/default-state contracts finish in 0032. diff --git a/packages/db/drizzle/0020_user_deletion_fence.sql b/packages/db/drizzle/0020_user_deletion_fence.sql deleted file mode 100644 index 5bf1575d..00000000 --- a/packages/db/drizzle/0020_user_deletion_fence.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "v2_users" ADD COLUMN "deletion_fence" text; \ No newline at end of file diff --git a/packages/db/drizzle/0021_clerk_deletion_tombstone.sql b/packages/db/drizzle/0021_clerk_deletion_tombstone.sql deleted file mode 100644 index e4643be1..00000000 --- a/packages/db/drizzle/0021_clerk_deletion_tombstone.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE "v2_deleted_clerk_identities" ( - "clerk_identity_hash" text PRIMARY KEY NOT NULL, - "deleted_at" timestamp with time zone DEFAULT now() NOT NULL, - CONSTRAINT "v2_deleted_clerk_identities_hash_check" CHECK ("v2_deleted_clerk_identities"."clerk_identity_hash" ~ '^[0-9a-f]{64}$') -); diff --git a/packages/db/drizzle/0022_agent_run_idempotency.sql b/packages/db/drizzle/0022_agent_run_idempotency.sql deleted file mode 100644 index 4d7f7409..00000000 --- a/packages/db/drizzle/0022_agent_run_idempotency.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE "v2_agent_runs" ADD COLUMN "idempotency_key_hash" text;--> statement-breakpoint -ALTER TABLE "v2_agent_runs" ADD COLUMN "request_body_hash" text;--> statement-breakpoint -CREATE UNIQUE INDEX "v2_agent_runs_user_idempotency_key_unique" ON "v2_agent_runs" USING btree ("user_id","idempotency_key_hash");--> statement-breakpoint -ALTER TABLE "v2_agent_runs" ADD CONSTRAINT "v2_agent_runs_idempotency_key_hash_check" CHECK ("v2_agent_runs"."idempotency_key_hash" is null or "v2_agent_runs"."idempotency_key_hash" ~ '^[0-9a-f]{64}$');--> statement-breakpoint -ALTER TABLE "v2_agent_runs" ADD CONSTRAINT "v2_agent_runs_request_body_hash_check" CHECK ("v2_agent_runs"."request_body_hash" is null or "v2_agent_runs"."request_body_hash" ~ '^[0-9a-f]{64}$'); \ No newline at end of file diff --git a/packages/db/drizzle/0023_project_cleanup_and_keyset_indexes.sql b/packages/db/drizzle/0023_project_cleanup_and_keyset_indexes.sql deleted file mode 100644 index 13c2a0a1..00000000 --- a/packages/db/drizzle/0023_project_cleanup_and_keyset_indexes.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE "v2_projects" ADD COLUMN "workspace_cleanup_requested_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "v2_projects" ADD COLUMN "workspace_cleanup_completed_at" timestamp with time zone;--> statement-breakpoint -CREATE INDEX "v2_messages_thread_page_idx" ON "v2_messages" USING btree ("user_id","thread_id","created_at","id");--> statement-breakpoint -CREATE INDEX "v2_projects_user_page_idx" ON "v2_projects" USING btree ("user_id","updated_at" DESC NULLS LAST,"id" DESC NULLS LAST) WHERE deleted_at is null;--> statement-breakpoint -CREATE INDEX "v2_threads_project_page_idx" ON "v2_threads" USING btree ("user_id","project_id","updated_at" DESC NULLS LAST,"id" DESC NULLS LAST) WHERE deleted_at is null;--> statement-breakpoint -CREATE INDEX "v2_threads_user_page_idx" ON "v2_threads" USING btree ("user_id","updated_at" DESC NULLS LAST,"id" DESC NULLS LAST) WHERE deleted_at is null; diff --git a/packages/db/drizzle/0024_deletion_pages_and_assistant_message_identity.sql b/packages/db/drizzle/0024_deletion_pages_and_assistant_message_identity.sql deleted file mode 100644 index 83138dc3..00000000 --- a/packages/db/drizzle/0024_deletion_pages_and_assistant_message_identity.sql +++ /dev/null @@ -1,3 +0,0 @@ -CREATE INDEX "v2_agent_runs_user_delete_page_idx" ON "v2_agent_runs" USING btree ("user_id","id");--> statement-breakpoint -CREATE UNIQUE INDEX "v2_messages_agent_run_assistant_uidx" ON "v2_messages" USING btree ("agent_run_id") WHERE "v2_messages"."agent_run_id" is not null and "v2_messages"."role" = 'assistant';--> statement-breakpoint -CREATE INDEX "v2_user_integrations_delete_page_idx" ON "v2_user_integrations" USING btree ("user_id","composio_connection_id"); \ No newline at end of file diff --git a/packages/db/drizzle/0025_generated_output_expiry_index.sql b/packages/db/drizzle/0025_generated_output_expiry_index.sql deleted file mode 100644 index 7602edc4..00000000 --- a/packages/db/drizzle/0025_generated_output_expiry_index.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX "v2_generated_outputs_expiry_idx" ON "v2_generated_outputs" USING btree ("expires_at","id") WHERE "v2_generated_outputs"."expires_at" is not null; diff --git a/packages/db/drizzle/0026_first_artifact_milestone.sql b/packages/db/drizzle/0026_first_artifact_milestone.sql deleted file mode 100644 index 6f0ae7af..00000000 --- a/packages/db/drizzle/0026_first_artifact_milestone.sql +++ /dev/null @@ -1,16 +0,0 @@ -ALTER TABLE "v2_users" ADD COLUMN "first_artifact_at" timestamp with time zone;--> statement-breakpoint -CREATE OR REPLACE FUNCTION public.v2_capture_first_artifact() RETURNS trigger -LANGUAGE plpgsql -SET search_path = '' -AS $$ -BEGIN - UPDATE public.v2_users - SET first_artifact_at = NEW.created_at - WHERE id = NEW.user_id - AND (first_artifact_at IS NULL OR first_artifact_at > NEW.created_at); - RETURN NEW; -END -$$;--> statement-breakpoint -CREATE TRIGGER v2_capture_first_artifact_trigger -AFTER INSERT ON public.v2_generated_outputs -FOR EACH ROW EXECUTE FUNCTION public.v2_capture_first_artifact(); diff --git a/packages/db/drizzle/0027_remove_project_backup_scaffolding.sql b/packages/db/drizzle/0027_remove_project_backup_scaffolding.sql deleted file mode 100644 index ff15e329..00000000 --- a/packages/db/drizzle/0027_remove_project_backup_scaffolding.sql +++ /dev/null @@ -1,3 +0,0 @@ --- The generated schema snapshot removes the obsolete project-backup column. --- Its destructive SQL is intentionally deferred until matching Workers are live; --- see infra/supabase/migrations/post/0036_remove_project_backup_scaffolding.sql. diff --git a/packages/db/drizzle/0028_finalize_generated_output_nullability.sql b/packages/db/drizzle/0028_finalize_generated_output_nullability.sql deleted file mode 100644 index 53c5745f..00000000 --- a/packages/db/drizzle/0028_finalize_generated_output_nullability.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Snapshot marker only. The pre-deploy integrity overlay rejects null output --- identities, and post-deploy migration 0035 makes both columns physically --- NOT NULL after matching Workers are live. diff --git a/packages/db/drizzle/0029_finalize_scoped_foreign_keys.sql b/packages/db/drizzle/0029_finalize_scoped_foreign_keys.sql deleted file mode 100644 index d87405d5..00000000 --- a/packages/db/drizzle/0029_finalize_scoped_foreign_keys.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Snapshot marker only. Pre-deploy migration 0028 installs tenant- and --- thread-scoped foreign keys; post-deploy migration 0035 removes the five --- superseded single-column constraints after matching Workers are live. diff --git a/packages/db/drizzle/0030_yielding_mindworm.sql b/packages/db/drizzle/0030_yielding_mindworm.sql deleted file mode 100644 index d08b04c7..00000000 --- a/packages/db/drizzle/0030_yielding_mindworm.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Schema snapshot marker only. The generated changes are contractions and run --- after the matching application deployment in raw migration 0040. diff --git a/packages/db/drizzle/0031_complete_raider.sql b/packages/db/drizzle/0031_complete_raider.sql deleted file mode 100644 index d08b04c7..00000000 --- a/packages/db/drizzle/0031_complete_raider.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Schema snapshot marker only. The generated changes are contractions and run --- after the matching application deployment in raw migration 0040. diff --git a/packages/db/drizzle/0032_finalize_agent_run_model_attribution.sql b/packages/db/drizzle/0032_finalize_agent_run_model_attribution.sql deleted file mode 100644 index 2da9418b..00000000 --- a/packages/db/drizzle/0032_finalize_agent_run_model_attribution.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Schema snapshot marker only. The model-attribution contraction runs after --- matching Workers are live in raw post-deploy migration 0041. diff --git a/packages/db/drizzle/0033_overrated_nova.sql b/packages/db/drizzle/0033_overrated_nova.sql deleted file mode 100644 index 7a022a64..00000000 --- a/packages/db/drizzle/0033_overrated_nova.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE "v2_provider_keys" ADD COLUMN "last_revalidated_at" timestamp with time zone;--> statement-breakpoint -CREATE INDEX "v2_provider_keys_revalidation_idx" ON "v2_provider_keys" USING btree ("last_revalidated_at" NULLS FIRST,"created_at","user_id","provider") WHERE "v2_provider_keys"."disabled_at" is null; - --- Raw post-deploy migrations 0043-0052 own the target-schema contractions, --- replacement indexes, canonical checks, and resource-deletion job DDL. This --- Drizzle migration intentionally contains only the additive provider-key DDL. diff --git a/packages/db/drizzle/0034_broken_nighthawk.sql b/packages/db/drizzle/0034_broken_nighthawk.sql deleted file mode 100644 index cf96d911..00000000 --- a/packages/db/drizzle/0034_broken_nighthawk.sql +++ /dev/null @@ -1,24 +0,0 @@ -ALTER TABLE "v2_messages" ADD COLUMN "agent_run_segment" integer DEFAULT 0 NOT NULL;--> statement-breakpoint -ALTER TABLE "v2_messages" ADD COLUMN "agent_run_segment_final" boolean DEFAULT true NOT NULL;--> statement-breakpoint -CREATE UNIQUE INDEX "v2_messages_agent_run_segment_assistant_uidx" ON "v2_messages" USING btree ("agent_run_id","agent_run_segment") WHERE "v2_messages"."agent_run_id" is not null and "v2_messages"."role" = 'assistant';--> statement-breakpoint -CREATE UNIQUE INDEX "v2_messages_agent_run_final_assistant_uidx" ON "v2_messages" USING btree ("agent_run_id") WHERE "v2_messages"."agent_run_id" is not null and "v2_messages"."role" = 'assistant' and "v2_messages"."agent_run_segment_final";--> statement-breakpoint -ALTER TABLE "v2_messages" ADD CONSTRAINT "v2_messages_agent_run_segment_check" CHECK ("v2_messages"."agent_run_segment" >= 0);--> statement-breakpoint -ALTER TABLE "v2_messages" ADD CONSTRAINT "v2_messages_agent_run_segment_scope_check" CHECK (("v2_messages"."agent_run_segment" = 0 and "v2_messages"."agent_run_segment_final") or ("v2_messages"."role" = 'assistant' and "v2_messages"."agent_run_id" is not null));--> statement-breakpoint -DO $$ -DECLARE - oversized_count bigint; -BEGIN - SELECT count(*) - INTO oversized_count - FROM public.v2_messages - WHERE octet_length(parts::text) > 196608; - - IF oversized_count > 0 THEN - RAISE EXCEPTION - 'assistant transcript segmentation preflight refused: % existing message rows exceed 196608 bytes', - oversized_count - USING HINT = 'Run the reviewed lossless closed-gate transcript segmentation backfill, then retry this migration.'; - END IF; -END -$$;--> statement-breakpoint -ALTER TABLE "v2_messages" ADD CONSTRAINT "v2_messages_parts_size_check" CHECK (octet_length("v2_messages"."parts"::text) <= 196608); diff --git a/packages/db/drizzle/0035_complete_purifiers.sql b/packages/db/drizzle/0035_complete_purifiers.sql deleted file mode 100644 index 2ac81816..00000000 --- a/packages/db/drizzle/0035_complete_purifiers.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX "v2_users_activation_created_idx" ON "v2_users" USING btree ("created_at","id") WHERE "v2_users"."deleted_at" is null; \ No newline at end of file diff --git a/packages/db/drizzle/0036_goofy_morph.sql b/packages/db/drizzle/0036_goofy_morph.sql deleted file mode 100644 index 7d0ef31d..00000000 --- a/packages/db/drizzle/0036_goofy_morph.sql +++ /dev/null @@ -1,6 +0,0 @@ --- Expand only: raw post-deploy migration 0054 removes the superseded index --- after every Worker uses lease-backed claims. -ALTER TABLE "v2_provider_keys" ADD COLUMN "revalidation_claimed_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "v2_provider_keys" ADD COLUMN "revalidation_lease_token" uuid;--> statement-breakpoint -CREATE INDEX "v2_provider_keys_revalidation_lease_idx" ON "v2_provider_keys" USING btree ("last_revalidated_at" NULLS FIRST,"revalidation_claimed_at" NULLS FIRST,"created_at","user_id","provider") WHERE "v2_provider_keys"."disabled_at" is null;--> statement-breakpoint -ALTER TABLE "v2_provider_keys" ADD CONSTRAINT "v2_provider_keys_revalidation_lease_pair_check" CHECK (("v2_provider_keys"."revalidation_claimed_at" is null and "v2_provider_keys"."revalidation_lease_token" is null) or ("v2_provider_keys"."revalidation_claimed_at" is not null and "v2_provider_keys"."revalidation_lease_token" is not null)); diff --git a/packages/db/drizzle/0037_glossy_chameleon.sql b/packages/db/drizzle/0037_glossy_chameleon.sql deleted file mode 100644 index 5654edef..00000000 --- a/packages/db/drizzle/0037_glossy_chameleon.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Historical raw migrations already create this index on existing targets. --- IF NOT EXISTS makes the Drizzle schema authoritative without rebuilding it. -CREATE INDEX IF NOT EXISTS "v2_agent_runs_user_started_idx" ON "v2_agent_runs" USING btree ("user_id","started_at" DESC NULLS FIRST); diff --git a/packages/db/drizzle/0038_pretty_nocturne.sql b/packages/db/drizzle/0038_pretty_nocturne.sql deleted file mode 100644 index 04c36c79..00000000 --- a/packages/db/drizzle/0038_pretty_nocturne.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "v2_messages" ADD CONSTRAINT "v2_messages_role_check" CHECK ("v2_messages"."role" in ('assistant', 'user')) NOT VALID; diff --git a/packages/db/drizzle/0039_lucky_the_watchers.sql b/packages/db/drizzle/0039_lucky_the_watchers.sql deleted file mode 100644 index df0554a5..00000000 --- a/packages/db/drizzle/0039_lucky_the_watchers.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Raw post-deploy migration 0057 owns the data repair, validated integrity --- constraints, scoped foreign-key action, replacement indexes, and redundant --- index removal. This Drizzle entry records the final authoritative schema --- without running blocking or destructive DDL before the writer gate closes. diff --git a/packages/db/drizzle/0040_tiresome_jack_murdock.sql b/packages/db/drizzle/0040_tiresome_jack_murdock.sql deleted file mode 100644 index 8555cee3..00000000 --- a/packages/db/drizzle/0040_tiresome_jack_murdock.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX "v2_users_deletion_due_idx" ON "v2_users" USING btree ("deleted_at","id") WHERE "v2_users"."deleted_at" is not null; \ No newline at end of file diff --git a/packages/db/drizzle/0041_great_adam_warlock.sql b/packages/db/drizzle/0041_great_adam_warlock.sql deleted file mode 100644 index 828615a7..00000000 --- a/packages/db/drizzle/0041_great_adam_warlock.sql +++ /dev/null @@ -1,27 +0,0 @@ -CREATE TABLE "v2_user_deletion_jobs" ( - "id" uuid PRIMARY KEY DEFAULT public.uuidv7() NOT NULL, - "user_id" uuid NOT NULL, - "generation" timestamp (3) with time zone NOT NULL, - "phase" text DEFAULT 'runs' NOT NULL, - "cursor" text, - "continuation" integer DEFAULT 0 NOT NULL, - "status" text DEFAULT 'queued' NOT NULL, - "lease_token" uuid, - "lease_expires_at" timestamp (3) with time zone, - "failure_count" integer DEFAULT 0 NOT NULL, - "next_attempt_at" timestamp (3) with time zone DEFAULT now() NOT NULL, - "last_error_code" text, - CONSTRAINT "v2_user_deletion_jobs_phase_check" CHECK ("v2_user_deletion_jobs"."phase" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')), - CONSTRAINT "v2_user_deletion_jobs_status_check" CHECK ("v2_user_deletion_jobs"."status" in ('queued', 'leased', 'quarantined')), - CONSTRAINT "v2_user_deletion_jobs_counter_check" CHECK ("v2_user_deletion_jobs"."continuation" >= 0 and "v2_user_deletion_jobs"."failure_count" >= 0), - CONSTRAINT "v2_user_deletion_jobs_lease_check" CHECK (( - ("v2_user_deletion_jobs"."status" = 'leased' and "v2_user_deletion_jobs"."lease_token" is not null and "v2_user_deletion_jobs"."lease_expires_at" is not null) - or - ("v2_user_deletion_jobs"."status" <> 'leased' and "v2_user_deletion_jobs"."lease_token" is null and "v2_user_deletion_jobs"."lease_expires_at" is null) - )) -); ---> statement-breakpoint -ALTER TABLE "v2_user_deletion_jobs" ADD CONSTRAINT "v2_user_deletion_jobs_user_id_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE UNIQUE INDEX "v2_user_deletion_jobs_generation_uidx" ON "v2_user_deletion_jobs" USING btree ("user_id","generation");--> statement-breakpoint -CREATE INDEX "v2_user_deletion_jobs_ready_idx" ON "v2_user_deletion_jobs" USING btree ("next_attempt_at","id") WHERE "v2_user_deletion_jobs"."status" = 'queued';--> statement-breakpoint -CREATE INDEX "v2_user_deletion_jobs_lease_idx" ON "v2_user_deletion_jobs" USING btree ("lease_expires_at","id") WHERE "v2_user_deletion_jobs"."status" = 'leased'; \ No newline at end of file diff --git a/packages/db/drizzle/0042_uneven_lady_bullseye.sql b/packages/db/drizzle/0042_uneven_lady_bullseye.sql deleted file mode 100644 index 4242683b..00000000 --- a/packages/db/drizzle/0042_uneven_lady_bullseye.sql +++ /dev/null @@ -1,76 +0,0 @@ -CREATE TABLE "v2_retention_jobs" ( - "day" date PRIMARY KEY NOT NULL, - "scheduled_at" timestamp (3) with time zone NOT NULL, - "phase" text DEFAULT 'activation' NOT NULL, - "activation_cursor_event" text, - "activation_cursor_user_id" uuid, - "output_cursor_expires_at" timestamp (3) with time zone, - "output_cursor_id" uuid, - "continuation" integer DEFAULT 0 NOT NULL, - "status" text DEFAULT 'queued' NOT NULL, - "release_version_id" uuid, - "lease_token" uuid, - "lease_expires_at" timestamp (3) with time zone, - "failure_count" integer DEFAULT 0 NOT NULL, - "next_attempt_at" timestamp (3) with time zone DEFAULT now() NOT NULL, - "last_error_code" text, - "completed_at" timestamp (3) with time zone, - CONSTRAINT "v2_retention_jobs_day_check" CHECK ("v2_retention_jobs"."day" = (("v2_retention_jobs"."scheduled_at" at time zone 'UTC')::date - 1)), - CONSTRAINT "v2_retention_jobs_phase_check" CHECK ("v2_retention_jobs"."phase" in ('activation', 'cleanup')), - CONSTRAINT "v2_retention_jobs_status_check" CHECK ("v2_retention_jobs"."status" in ('queued', 'leased', 'complete')), - CONSTRAINT "v2_retention_jobs_counter_check" CHECK ("v2_retention_jobs"."continuation" >= 0 and "v2_retention_jobs"."failure_count" >= 0), - CONSTRAINT "v2_retention_jobs_error_code_check" CHECK ("v2_retention_jobs"."last_error_code" is null or octet_length("v2_retention_jobs"."last_error_code") <= 128), - CONSTRAINT "v2_retention_jobs_activation_cursor_check" CHECK (( - ("v2_retention_jobs"."activation_cursor_event" is null and "v2_retention_jobs"."activation_cursor_user_id" is null) - or - ( - "v2_retention_jobs"."phase" = 'activation' - and "v2_retention_jobs"."activation_cursor_event" in ('retention_d7', 'retention_d28', 'first_week_mau') - and "v2_retention_jobs"."activation_cursor_user_id" is not null - ) - )), - CONSTRAINT "v2_retention_jobs_output_cursor_check" CHECK (( - ("v2_retention_jobs"."output_cursor_expires_at" is null and "v2_retention_jobs"."output_cursor_id" is null) - or - ( - "v2_retention_jobs"."phase" = 'cleanup' - and "v2_retention_jobs"."output_cursor_expires_at" is not null - and "v2_retention_jobs"."output_cursor_id" is not null - ) - )), - CONSTRAINT "v2_retention_jobs_phase_cursor_check" CHECK (( - ("v2_retention_jobs"."phase" = 'activation' and "v2_retention_jobs"."output_cursor_expires_at" is null and "v2_retention_jobs"."output_cursor_id" is null) - or - ("v2_retention_jobs"."phase" = 'cleanup' and "v2_retention_jobs"."activation_cursor_event" is null and "v2_retention_jobs"."activation_cursor_user_id" is null) - )), - CONSTRAINT "v2_retention_jobs_lease_check" CHECK (( - ( - "v2_retention_jobs"."status" = 'leased' - and "v2_retention_jobs"."release_version_id" is not null - and "v2_retention_jobs"."lease_token" is not null - and "v2_retention_jobs"."lease_expires_at" is not null - and "v2_retention_jobs"."completed_at" is null - ) - or - ( - "v2_retention_jobs"."status" = 'queued' - and "v2_retention_jobs"."release_version_id" is null - and "v2_retention_jobs"."lease_token" is null - and "v2_retention_jobs"."lease_expires_at" is null - and "v2_retention_jobs"."completed_at" is null - ) - or - ( - "v2_retention_jobs"."status" = 'complete' - and "v2_retention_jobs"."release_version_id" is null - and "v2_retention_jobs"."lease_token" is null - and "v2_retention_jobs"."lease_expires_at" is null - and "v2_retention_jobs"."completed_at" is not null - ) - )), - CONSTRAINT "v2_retention_jobs_terminal_phase_check" CHECK ("v2_retention_jobs"."status" <> 'complete' or "v2_retention_jobs"."phase" = 'cleanup') -); ---> statement-breakpoint -CREATE INDEX "v2_retention_jobs_ready_idx" ON "v2_retention_jobs" USING btree ("next_attempt_at","day") WHERE "v2_retention_jobs"."status" = 'queued';--> statement-breakpoint -CREATE INDEX "v2_retention_jobs_lease_idx" ON "v2_retention_jobs" USING btree ("lease_expires_at","day") WHERE "v2_retention_jobs"."status" = 'leased';--> statement-breakpoint -CREATE INDEX "v2_retention_jobs_completed_idx" ON "v2_retention_jobs" USING btree ("completed_at","day") WHERE "v2_retention_jobs"."status" = 'complete'; \ No newline at end of file diff --git a/packages/db/drizzle/0043_third_sleeper.sql b/packages/db/drizzle/0043_third_sleeper.sql deleted file mode 100644 index a05934c5..00000000 --- a/packages/db/drizzle/0043_third_sleeper.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE "v2_user_deletion_jobs" ALTER COLUMN "generation" SET DATA TYPE timestamp with time zone;--> statement-breakpoint -ALTER TABLE "v2_users" ADD COLUMN "clerk_updated_at_ms" bigint DEFAULT 0 NOT NULL;--> statement-breakpoint -ALTER TABLE "v2_users" ADD CONSTRAINT "v2_users_clerk_updated_at_ms_check" CHECK ("v2_users"."clerk_updated_at_ms" between 0 and 9007199254740991); diff --git a/packages/db/drizzle/0044_dusty_blazing_skull.sql b/packages/db/drizzle/0044_dusty_blazing_skull.sql deleted file mode 100644 index 8950c088..00000000 --- a/packages/db/drizzle/0044_dusty_blazing_skull.sql +++ /dev/null @@ -1,46 +0,0 @@ -CREATE TABLE "v2_artifact_upload_intents" ( - "id" uuid PRIMARY KEY NOT NULL, - "user_id" uuid NOT NULL, - "project_id" uuid NOT NULL, - "agent_run_id" uuid NOT NULL, - "r2_key" text NOT NULL, - "cleanup_not_before" timestamp (3) with time zone NOT NULL, - "quiesced_at" timestamp (3) with time zone, - CONSTRAINT "v2_artifact_upload_intents_r2_key_unique" UNIQUE("r2_key"), - CONSTRAINT "v2_artifact_upload_intents_r2_identity_check" CHECK ("v2_artifact_upload_intents"."r2_key" like "v2_artifact_upload_intents"."user_id"::text || '/' || "v2_artifact_upload_intents"."project_id"::text || '/' || "v2_artifact_upload_intents"."agent_run_id"::text || '/' || "v2_artifact_upload_intents"."id"::text || '-%' - and strpos(substr("v2_artifact_upload_intents"."r2_key", length("v2_artifact_upload_intents"."user_id"::text || '/' || "v2_artifact_upload_intents"."project_id"::text || '/' || "v2_artifact_upload_intents"."agent_run_id"::text || '/' || "v2_artifact_upload_intents"."id"::text || '-') + 1), '/') = 0 - and octet_length("v2_artifact_upload_intents"."r2_key") <= 512) -); ---> statement-breakpoint -CREATE TABLE "v2_user_deletion_refund_intents" ( - "job_id" uuid PRIMARY KEY NOT NULL, - "user_id" uuid NOT NULL, - "generation" timestamp with time zone NOT NULL, - "order_id" text NOT NULL, - "amount" integer NOT NULL, - "currency" text NOT NULL, - "idempotency_key" text NOT NULL, - "provider_refund_id" text, - "provider_status" text, - "created_at" timestamp (3) with time zone DEFAULT now() NOT NULL, - "reconciled_at" timestamp (3) with time zone, - CONSTRAINT "v2_user_deletion_refund_intents_amount_check" CHECK ("v2_user_deletion_refund_intents"."amount" > 0), - CONSTRAINT "v2_user_deletion_refund_intents_currency_check" CHECK ("v2_user_deletion_refund_intents"."currency" ~ '^[a-z]{3}$'), - CONSTRAINT "v2_user_deletion_refund_intents_order_check" CHECK (length(btrim("v2_user_deletion_refund_intents"."order_id")) > 0), - CONSTRAINT "v2_user_deletion_refund_intents_identity_check" CHECK ("v2_user_deletion_refund_intents"."idempotency_key" = 'cheatcode:user-deletion-refund:' || "v2_user_deletion_refund_intents"."job_id"::text), - CONSTRAINT "v2_user_deletion_refund_intents_provider_check" CHECK (( - ("v2_user_deletion_refund_intents"."provider_refund_id" is null and "v2_user_deletion_refund_intents"."provider_status" is null and "v2_user_deletion_refund_intents"."reconciled_at" is null) - or - ("v2_user_deletion_refund_intents"."provider_refund_id" is not null and length(btrim("v2_user_deletion_refund_intents"."provider_refund_id")) > 0 and "v2_user_deletion_refund_intents"."provider_status" is not null and "v2_user_deletion_refund_intents"."provider_status" in ('pending', 'succeeded', 'failed', 'canceled') and "v2_user_deletion_refund_intents"."reconciled_at" is not null) - )) -); ---> statement-breakpoint -ALTER TABLE "v2_user_deletion_jobs" ADD CONSTRAINT "v2_user_deletion_jobs_id_user_generation_key" UNIQUE("id","user_id","generation");--> statement-breakpoint -ALTER TABLE "v2_user_deletion_refund_intents" ADD CONSTRAINT "v2_user_deletion_refund_intents_job_identity_fk" FOREIGN KEY ("job_id","user_id","generation") REFERENCES "public"."v2_user_deletion_jobs"("id","user_id","generation") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "v2_artifact_upload_intents_cleanup_idx" ON "v2_artifact_upload_intents" USING btree ("cleanup_not_before","quiesced_at","id") WHERE "v2_artifact_upload_intents"."quiesced_at" is not null;--> statement-breakpoint -CREATE INDEX "v2_artifact_upload_intents_user_idx" ON "v2_artifact_upload_intents" USING btree ("user_id","id");--> statement-breakpoint -CREATE INDEX "v2_artifact_upload_intents_project_idx" ON "v2_artifact_upload_intents" USING btree ("user_id","project_id","id");--> statement-breakpoint -CREATE INDEX "v2_artifact_upload_intents_run_idx" ON "v2_artifact_upload_intents" USING btree ("user_id","agent_run_id","id");--> statement-breakpoint -CREATE UNIQUE INDEX "v2_user_deletion_refund_intents_idempotency_uidx" ON "v2_user_deletion_refund_intents" USING btree ("idempotency_key");--> statement-breakpoint -CREATE UNIQUE INDEX "v2_user_deletion_refund_intents_provider_uidx" ON "v2_user_deletion_refund_intents" USING btree ("provider_refund_id") WHERE "v2_user_deletion_refund_intents"."provider_refund_id" is not null;--> statement-breakpoint -CREATE INDEX "v2_user_deletion_refund_intents_unresolved_idx" ON "v2_user_deletion_refund_intents" USING btree ("user_id","job_id") WHERE "v2_user_deletion_refund_intents"."provider_status" is distinct from 'succeeded'; diff --git a/packages/db/drizzle/0045_ambiguous_rictor.sql b/packages/db/drizzle/0045_ambiguous_rictor.sql deleted file mode 100644 index 63f6ce39..00000000 --- a/packages/db/drizzle/0045_ambiguous_rictor.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Snapshot marker only. Raw post-deploy migration 0074 owns the output-retention, --- project-instruction, retention-cursor, and BYOK policy contractions after the --- matching Workers are live. diff --git a/packages/db/drizzle/0046_dry_jubilee.sql b/packages/db/drizzle/0046_dry_jubilee.sql deleted file mode 100644 index 9106c970..00000000 --- a/packages/db/drizzle/0046_dry_jubilee.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE "v2_threads" ADD COLUMN "latest_model_id" text;--> statement-breakpoint -ALTER TABLE "v2_threads" ADD CONSTRAINT "v2_threads_latest_model_id_check" CHECK ("v2_threads"."latest_model_id" is null or ( - char_length("v2_threads"."latest_model_id") <= 200 - and "v2_threads"."latest_model_id" - ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$' - )); diff --git a/packages/db/drizzle/0047_neat_cannonball.sql b/packages/db/drizzle/0047_neat_cannonball.sql deleted file mode 100644 index 55331fc7..00000000 --- a/packages/db/drizzle/0047_neat_cannonball.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE INDEX "v2_messages_agent_run_scope_idx" ON "v2_messages" USING btree ("agent_run_id","user_id","thread_id");--> statement-breakpoint -CREATE INDEX "v2_projects_user_delete_idx" ON "v2_projects" USING btree ("user_id","id"); \ No newline at end of file diff --git a/packages/db/drizzle/0048_massive_supreme_intelligence.sql b/packages/db/drizzle/0048_massive_supreme_intelligence.sql deleted file mode 100644 index 32e320b7..00000000 --- a/packages/db/drizzle/0048_massive_supreme_intelligence.sql +++ /dev/null @@ -1,4 +0,0 @@ --- The physical rename is a coordinated post-deploy cutover in raw migration 0080. --- Keeping this journal entry side-effect free lets a clean database replay all --- earlier security overlays before the final name becomes authoritative. -select 1; diff --git a/packages/db/drizzle/meta/0000_snapshot.json b/packages/db/drizzle/meta/0000_snapshot.json index ca714735..42a49569 100644 --- a/packages/db/drizzle/meta/0000_snapshot.json +++ b/packages/db/drizzle/meta/0000_snapshot.json @@ -1,5 +1,5 @@ { - "id": "f60043b3-b57f-4190-9ff8-e192aad1a0b8", + "id": "a2d73405-d481-4898-b7e4-82e6074913cd", "prevId": "00000000-0000-0000-0000-000000000000", "version": "7", "dialect": "postgresql", @@ -37,46 +37,17 @@ "name": "model_id", "type": "text", "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" + "notNull": true }, - "config": { - "name": "config", - "type": "jsonb", + "idempotency_key_hash": { + "name": "idempotency_key_hash", + "type": "text", "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" + "notNull": false }, - "error": { - "name": "error", - "type": "jsonb", + "request_body_hash": { + "name": "request_body_hash", + "type": "text", "primaryKey": false, "notNull": false }, @@ -94,239 +65,694 @@ "notNull": false } }, - "indexes": {}, + "indexes": { + "v2_agent_runs_user_idempotency_key_unique": { + "name": "v2_agent_runs_user_idempotency_key_unique", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "idempotency_key_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_agent_runs_user_started_idx": { + "name": "v2_agent_runs_user_started_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "started_at", + "isExpression": false, + "asc": false, + "nulls": "first" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_agent_runs_user_finished_idx": { + "name": "v2_agent_runs_user_finished_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "finished_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_agent_runs\".\"finished_at\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_agent_runs_user_delete_page_idx": { + "name": "v2_agent_runs_user_delete_page_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_agent_runs_thread_delete_page_idx": { + "name": "v2_agent_runs_thread_delete_page_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, "v2_agent_runs_user_id_v2_users_id_fk": { "name": "v2_agent_runs_user_id_v2_users_id_fk", "tableFrom": "v2_agent_runs", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, - "uniqueConstraints": {}, + "uniqueConstraints": { + "v2_agent_runs_id_user_id_key": { + "name": "v2_agent_runs_id_user_id_key", + "nullsNotDistinct": false, + "columns": [ + "id", + "user_id" + ] + } + }, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_agent_runs_idempotency_key_hash_check": { + "name": "v2_agent_runs_idempotency_key_hash_check", + "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" + }, + "v2_agent_runs_request_body_hash_check": { + "name": "v2_agent_runs_request_body_hash_check", + "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" + }, + "v2_agent_runs_model_id_canonical_check": { + "name": "v2_agent_runs_model_id_canonical_check", + "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" + }, + "v2_agent_runs_status_check": { + "name": "v2_agent_runs_status_check", + "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'completed', 'failed', 'canceled')" + }, + "v2_agent_runs_finished_order_check": { + "name": "v2_agent_runs_finished_order_check", + "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" + }, + "v2_agent_runs_terminal_timestamp_check": { + "name": "v2_agent_runs_terminal_timestamp_check", + "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" + } + }, "isRLSEnabled": false }, - "public.v2_billing_events": { - "name": "v2_billing_events", + "public.v2_artifact_upload_intents": { + "name": "v2_artifact_upload_intents", "schema": "", "columns": { "id": { "name": "id", "type": "uuid", "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" + "notNull": true }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, - "notNull": false + "notNull": true }, - "event_type": { - "name": "event_type", - "type": "text", + "project_id": { + "name": "project_id", + "type": "uuid", "primaryKey": false, "notNull": true }, - "polar_event_id": { - "name": "polar_event_id", + "agent_run_id": { + "name": "agent_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "r2_key": { + "name": "r2_key", "type": "text", "primaryKey": false, - "notNull": false + "notNull": true }, - "payload": { - "name": "payload", - "type": "jsonb", + "cleanup_not_before": { + "name": "cleanup_not_before", + "type": "timestamp (3) with time zone", "primaryKey": false, - "notNull": false + "notNull": true }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", + "quiesced_at": { + "name": "quiesced_at", + "type": "timestamp (3) with time zone", "primaryKey": false, - "notNull": false, - "default": "now()" + "notNull": false + } + }, + "indexes": { + "v2_artifact_upload_intents_cleanup_idx": { + "name": "v2_artifact_upload_intents_cleanup_idx", + "columns": [ + { + "expression": "cleanup_not_before", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "quiesced_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_artifact_upload_intents\".\"quiesced_at\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_artifact_upload_intents_user_idx": { + "name": "v2_artifact_upload_intents_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_artifact_upload_intents_project_idx": { + "name": "v2_artifact_upload_intents_project_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_artifact_upload_intents_run_idx": { + "name": "v2_artifact_upload_intents_run_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} } }, - "indexes": {}, "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", + "v2_artifact_upload_intents_project_user_fk": { + "name": "v2_artifact_upload_intents_project_user_fk", + "tableFrom": "v2_artifact_upload_intents", + "tableTo": "v2_projects", + "columnsFrom": [ + "project_id", + "user_id" + ], + "columnsTo": [ + "id", + "user_id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "v2_artifact_upload_intents_agent_run_user_fk": { + "name": "v2_artifact_upload_intents_agent_run_user_fk", + "tableFrom": "v2_artifact_upload_intents", + "tableTo": "v2_agent_runs", + "columnsFrom": [ + "agent_run_id", + "user_id" + ], + "columnsTo": [ + "id", + "user_id" + ], + "onDelete": "no action", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", + "v2_artifact_upload_intents_r2_key_unique": { + "name": "v2_artifact_upload_intents_r2_key_unique", "nullsNotDistinct": false, - "columns": ["polar_event_id"] + "columns": [ + "r2_key" + ] } }, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_artifact_upload_intents_r2_identity_check": { + "name": "v2_artifact_upload_intents_r2_identity_check", + "value": "\"v2_artifact_upload_intents\".\"r2_key\" like \"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-%'\n and strpos(substr(\"v2_artifact_upload_intents\".\"r2_key\", length(\"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-') + 1), '/') = 0\n and octet_length(\"v2_artifact_upload_intents\".\"r2_key\") <= 512" + } + }, "isRLSEnabled": false }, - "public.v2_entitlements": { - "name": "v2_entitlements", + "public.v2_daily_maintenance_jobs": { + "name": "v2_daily_maintenance_jobs", "schema": "", "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", + "day": { + "name": "day", + "type": "date", "primaryKey": true, "notNull": true }, - "tier": { - "name": "tier", + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp (3) with time zone", + "primaryKey": false, + "notNull": true + }, + "phase": { + "name": "phase", "type": "text", "primaryKey": false, "notNull": true, - "default": "'free'" + "default": "'activation'" }, - "polar_customer_id": { - "name": "polar_customer_id", + "activation_cursor_event": { + "name": "activation_cursor_event", "type": "text", "primaryKey": false, "notNull": false }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", + "activation_cursor_user_id": { + "name": "activation_cursor_user_id", + "type": "uuid", "primaryKey": false, "notNull": false }, - "subscription_status": { - "name": "subscription_status", - "type": "text", + "continuation": { + "name": "continuation", + "type": "integer", "primaryKey": false, "notNull": true, - "default": "'none'" + "default": 0 }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", + "status": { + "name": "status", + "type": "text", "primaryKey": false, "notNull": true, - "default": false + "default": "'queued'" }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", + "release_version_id": { + "name": "release_version_id", + "type": "uuid", "primaryKey": false, "notNull": false }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", + "lease_token": { + "name": "lease_token", + "type": "uuid", "primaryKey": false, "notNull": false }, - "max_projects": { - "name": "max_projects", - "type": "integer", + "lease_expires_at": { + "name": "lease_expires_at", + "type": "timestamp (3) with time zone", "primaryKey": false, - "notNull": true, - "default": 3 + "notNull": false }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", + "failure_count": { + "name": "failure_count", "type": "integer", "primaryKey": false, "notNull": true, - "default": 1 + "default": 0 }, - "max_seats": { - "name": "max_seats", - "type": "integer", + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp (3) with time zone", "primaryKey": false, "notNull": true, - "default": 1 + "default": "now()" }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", + "last_error_code": { + "name": "last_error_code", + "type": "text", "primaryKey": false, - "notNull": true, - "default": "'5'" + "notNull": false }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", + "completed_at": { + "name": "completed_at", + "type": "timestamp (3) with time zone", "primaryKey": false, - "notNull": true, - "default": 1000 + "notNull": false + } + }, + "indexes": { + "v2_daily_maintenance_jobs_ready_idx": { + "name": "v2_daily_maintenance_jobs_ready_idx", + "columns": [ + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_daily_maintenance_jobs\".\"status\" = 'queued'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_daily_maintenance_jobs_lease_idx": { + "name": "v2_daily_maintenance_jobs_lease_idx", + "columns": [ + { + "expression": "lease_expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_daily_maintenance_jobs\".\"status\" = 'leased'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_daily_maintenance_jobs_completed_idx": { + "name": "v2_daily_maintenance_jobs_completed_idx", + "columns": [ + { + "expression": "completed_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_daily_maintenance_jobs\".\"status\" = 'complete'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "v2_daily_maintenance_jobs_day_check": { + "name": "v2_daily_maintenance_jobs_day_check", + "value": "\"v2_daily_maintenance_jobs\".\"day\" = ((\"v2_daily_maintenance_jobs\".\"scheduled_at\" at time zone 'UTC')::date - 1)" }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", + "v2_daily_maintenance_jobs_phase_check": { + "name": "v2_daily_maintenance_jobs_phase_check", + "value": "\"v2_daily_maintenance_jobs\".\"phase\" in ('activation', 'orphan-upload-cleanup')" + }, + "v2_daily_maintenance_jobs_status_check": { + "name": "v2_daily_maintenance_jobs_status_check", + "value": "\"v2_daily_maintenance_jobs\".\"status\" in ('queued', 'leased', 'complete')" + }, + "v2_daily_maintenance_jobs_counter_check": { + "name": "v2_daily_maintenance_jobs_counter_check", + "value": "\"v2_daily_maintenance_jobs\".\"continuation\" >= 0 and \"v2_daily_maintenance_jobs\".\"failure_count\" >= 0" + }, + "v2_daily_maintenance_jobs_error_code_check": { + "name": "v2_daily_maintenance_jobs_error_code_check", + "value": "\"v2_daily_maintenance_jobs\".\"last_error_code\" is null or octet_length(\"v2_daily_maintenance_jobs\".\"last_error_code\") <= 128" + }, + "v2_daily_maintenance_jobs_activation_cursor_check": { + "name": "v2_daily_maintenance_jobs_activation_cursor_check", + "value": "(\n (\"v2_daily_maintenance_jobs\".\"activation_cursor_event\" is null and \"v2_daily_maintenance_jobs\".\"activation_cursor_user_id\" is null)\n or\n (\n \"v2_daily_maintenance_jobs\".\"phase\" = 'activation'\n and \"v2_daily_maintenance_jobs\".\"activation_cursor_event\" in ('retention_d7', 'retention_d28', 'first_week_mau')\n and \"v2_daily_maintenance_jobs\".\"activation_cursor_user_id\" is not null\n )\n )" + }, + "v2_daily_maintenance_jobs_phase_cursor_check": { + "name": "v2_daily_maintenance_jobs_phase_cursor_check", + "value": "(\n (\"v2_daily_maintenance_jobs\".\"phase\" = 'activation')\n or\n (\"v2_daily_maintenance_jobs\".\"phase\" = 'orphan-upload-cleanup' and \"v2_daily_maintenance_jobs\".\"activation_cursor_event\" is null and \"v2_daily_maintenance_jobs\".\"activation_cursor_user_id\" is null)\n )" + }, + "v2_daily_maintenance_jobs_lease_check": { + "name": "v2_daily_maintenance_jobs_lease_check", + "value": "(\n (\n \"v2_daily_maintenance_jobs\".\"status\" = 'leased'\n and \"v2_daily_maintenance_jobs\".\"release_version_id\" is not null\n and \"v2_daily_maintenance_jobs\".\"lease_token\" is not null\n and \"v2_daily_maintenance_jobs\".\"lease_expires_at\" is not null\n and \"v2_daily_maintenance_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_daily_maintenance_jobs\".\"status\" = 'queued'\n and \"v2_daily_maintenance_jobs\".\"release_version_id\" is null\n and \"v2_daily_maintenance_jobs\".\"lease_token\" is null\n and \"v2_daily_maintenance_jobs\".\"lease_expires_at\" is null\n and \"v2_daily_maintenance_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_daily_maintenance_jobs\".\"status\" = 'complete'\n and \"v2_daily_maintenance_jobs\".\"release_version_id\" is null\n and \"v2_daily_maintenance_jobs\".\"lease_token\" is null\n and \"v2_daily_maintenance_jobs\".\"lease_expires_at\" is null\n and \"v2_daily_maintenance_jobs\".\"completed_at\" is not null\n )\n )" + }, + "v2_daily_maintenance_jobs_terminal_phase_check": { + "name": "v2_daily_maintenance_jobs_terminal_phase_check", + "value": "\"v2_daily_maintenance_jobs\".\"status\" <> 'complete' or \"v2_daily_maintenance_jobs\".\"phase\" = 'orphan-upload-cleanup'" + } + }, + "isRLSEnabled": false + }, + "public.v2_deleted_clerk_identities": { + "name": "v2_deleted_clerk_identities", + "schema": "", + "columns": { + "clerk_identity_hash": { + "name": "clerk_identity_hash", + "type": "text", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "v2_deleted_clerk_identities_hash_check": { + "name": "v2_deleted_clerk_identities_hash_check", + "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" + } + }, + "isRLSEnabled": false + }, + "public.v2_entitlements": { + "name": "v2_entitlements", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "tier": { + "name": "tier", + "type": "text", "primaryKey": false, "notNull": true, - "default": 5 + "default": "'free'" }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", + "polar_subscription_id": { + "name": "polar_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subscription_status": { + "name": "subscription_status", + "type": "text", "primaryKey": false, "notNull": true, - "default": false + "default": "'none'" }, - "flag_sso": { - "name": "flag_sso", + "cancel_at_period_end": { + "name": "cancel_at_period_end", "type": "boolean", "primaryKey": false, "notNull": true, "default": false }, - "updated_at": { - "name": "updated_at", + "current_period_start": { + "name": "current_period_start", "type": "timestamp with time zone", "primaryKey": false, - "notNull": true, - "default": "now()" + "notNull": false }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", + "current_period_end": { + "name": "current_period_end", + "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, - "source": { - "name": "source", - "type": "text", + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", "primaryKey": false, - "notNull": false + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "v2_entitlements_polar_subscription_uidx": { + "name": "v2_entitlements_polar_subscription_uidx", + "columns": [ + { + "expression": "polar_subscription_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} } }, - "indexes": {}, "foreignKeys": { "v2_entitlements_user_id_v2_users_id_fk": { "name": "v2_entitlements_user_id_v2_users_id_fk", "tableFrom": "v2_entitlements", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" } @@ -337,7 +763,11 @@ "checkConstraints": { "v2_entitlements_tier_check": { "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','team','enterprise')" + "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" + }, + "v2_entitlements_period_order_check": { + "name": "v2_entitlements_period_order_check", + "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" } }, "isRLSEnabled": false @@ -359,22 +789,10 @@ "primaryKey": false, "notNull": true }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, "agent_run_id": { "name": "agent_run_id", "type": "uuid", "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, "notNull": true }, "filename": { @@ -383,13 +801,6 @@ "primaryKey": false, "notNull": true }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, "r2_key": { "name": "r2_key", "type": "text", @@ -402,73 +813,63 @@ "primaryKey": false, "notNull": true }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false } }, - "indexes": {}, + "indexes": { + "v2_generated_outputs_agent_run_idx": { + "name": "v2_generated_outputs_agent_run_idx", + "columns": [ + { + "expression": "agent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, "foreignKeys": { "v2_generated_outputs_user_id_v2_users_id_fk": { "name": "v2_generated_outputs_user_id_v2_users_id_fk", "tableFrom": "v2_generated_outputs", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" } }, "compositePrimaryKeys": {}, - "uniqueConstraints": {}, + "uniqueConstraints": { + "v2_generated_outputs_r2_key_unique": { + "name": "v2_generated_outputs_r2_key_unique", + "nullsNotDistinct": false, + "columns": [ + "r2_key" + ] + } + }, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_generated_outputs_r2_identity_check": { + "name": "v2_generated_outputs_r2_identity_check", + "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" + } + }, "isRLSEnabled": false }, "public.v2_messages": { @@ -512,6 +913,20 @@ "primaryKey": false, "notNull": false }, + "agent_run_segment": { + "name": "agent_run_segment", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "agent_run_segment_final": { + "name": "agent_run_segment_final", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, "created_at": { "name": "created_at", "type": "timestamp with time zone", @@ -520,23 +935,123 @@ "default": "now()" } }, - "indexes": {}, + "indexes": { + "v2_messages_thread_page_idx": { + "name": "v2_messages_thread_page_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_run_segment", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_messages_agent_run_scope_idx": { + "name": "v2_messages_agent_run_scope_idx", + "columns": [ + { + "expression": "agent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_messages_agent_run_segment_assistant_uidx": { + "name": "v2_messages_agent_run_segment_assistant_uidx", + "columns": [ + { + "expression": "agent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "agent_run_segment", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_messages_agent_run_final_assistant_uidx": { + "name": "v2_messages_agent_run_final_assistant_uidx", + "columns": [ + { + "expression": "agent_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", + "concurrently": false, + "method": "btree", + "with": {} + } + }, "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, "v2_messages_user_id_v2_users_id_fk": { "name": "v2_messages_user_id_v2_users_id_fk", "tableFrom": "v2_messages", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" } @@ -544,7 +1059,28 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_messages_agent_run_segment_check": { + "name": "v2_messages_agent_run_segment_check", + "value": "\"v2_messages\".\"agent_run_segment\" >= 0" + }, + "v2_messages_role_check": { + "name": "v2_messages_role_check", + "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" + }, + "v2_messages_agent_run_segment_scope_check": { + "name": "v2_messages_agent_run_segment_scope_check", + "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" + }, + "v2_messages_parts_array_check": { + "name": "v2_messages_parts_array_check", + "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" + }, + "v2_messages_parts_size_check": { + "name": "v2_messages_parts_size_check", + "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" + } + }, "isRLSEnabled": false }, "public.v2_projects": { @@ -576,23 +1112,11 @@ "primaryKey": false, "notNull": true }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", + "workspace_slug": { + "name": "workspace_slug", "type": "text", "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false + "notNull": true }, "settings": { "name": "settings", @@ -606,14 +1130,7 @@ "type": "boolean", "primaryKey": false, "notNull": true, - "default": "false" - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": "false" + "default": false }, "archive_after": { "name": "archive_after", @@ -637,40 +1154,139 @@ }, "deleted_at": { "name": "deleted_at", - "type": "timestamp with time zone", + "type": "timestamp (3) with time zone", "primaryKey": false, "notNull": false } }, - "indexes": {}, + "indexes": { + "v2_projects_user_page_idx": { + "name": "v2_projects_user_page_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "where": "deleted_at is null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_projects_user_delete_idx": { + "name": "v2_projects_user_delete_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_projects_deletion_queue_idx": { + "name": "v2_projects_deletion_queue_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "deleted_at is not null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, "foreignKeys": { "v2_projects_user_id_v2_users_id_fk": { "name": "v2_projects_user_id_v2_users_id_fk", "tableFrom": "v2_projects", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, - "uniqueConstraints": {}, + "uniqueConstraints": { + "v2_projects_id_user_id_key": { + "name": "v2_projects_id_user_id_key", + "nullsNotDistinct": false, + "columns": [ + "id", + "user_id" + ] + } + }, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_projects_mode_check": { + "name": "v2_projects_mode_check", + "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" + }, + "v2_projects_workspace_slug_canonical_check": { + "name": "v2_projects_workspace_slug_canonical_check", + "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" + }, + "v2_projects_quota_archive_pair_check": { + "name": "v2_projects_quota_archive_pair_check", + "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" + }, + "v2_projects_settings_object_check": { + "name": "v2_projects_settings_object_check", + "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" + }, + "v2_projects_settings_default_model_check": { + "name": "v2_projects_settings_default_model_check", + "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" + } + }, "isRLSEnabled": false }, "public.v2_provider_keys": { "name": "v2_provider_keys", "schema": "", "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, "user_id": { "name": "user_id", "type": "uuid", @@ -695,12 +1311,24 @@ "primaryKey": false, "notNull": true }, - "last_used_at": { - "name": "last_used_at", + "last_revalidated_at": { + "name": "last_revalidated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "revalidation_claimed_at": { + "name": "revalidation_claimed_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": false }, + "revalidation_lease_token": { + "name": "revalidation_lease_token", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, "disabled_at": { "name": "disabled_at", "type": "timestamp with time zone", @@ -711,55 +1339,781 @@ "name": "disabled_reason", "type": "text", "primaryKey": false, - "notNull": false + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "v2_provider_keys_revalidation_lease_idx": { + "name": "v2_provider_keys_revalidation_lease_idx", + "columns": [ + { + "expression": "last_revalidated_at", + "isExpression": false, + "asc": true, + "nulls": "first" + }, + { + "expression": "revalidation_claimed_at", + "isExpression": false, + "asc": true, + "nulls": "first" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "provider", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_provider_keys\".\"disabled_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_provider_keys_vault_secret_uidx": { + "name": "v2_provider_keys_vault_secret_uidx", + "columns": [ + { + "expression": "vault_secret_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "v2_provider_keys_user_id_v2_users_id_fk": { + "name": "v2_provider_keys_user_id_v2_users_id_fk", + "tableFrom": "v2_provider_keys", + "tableTo": "v2_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "v2_provider_keys_user_id_provider_pk": { + "name": "v2_provider_keys_user_id_provider_pk", + "columns": [ + "user_id", + "provider" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "v2_provider_keys_fingerprint_check": { + "name": "v2_provider_keys_fingerprint_check", + "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" + }, + "v2_provider_keys_disabled_pair_check": { + "name": "v2_provider_keys_disabled_pair_check", + "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" + }, + "v2_provider_keys_revalidation_lease_pair_check": { + "name": "v2_provider_keys_revalidation_lease_pair_check", + "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" + } + }, + "isRLSEnabled": false + }, + "public.v2_resource_deletion_jobs": { + "name": "v2_resource_deletion_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "public.uuidv7()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "generation": { + "name": "generation", + "type": "timestamp (3) with time zone", + "primaryKey": false, + "notNull": true + }, + "phase": { + "name": "phase", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'runs'" + }, + "cursor": { + "name": "cursor", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "continuation": { + "name": "continuation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "lease_token": { + "name": "lease_token", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lease_expires_at": { + "name": "lease_expires_at", + "type": "timestamp (3) with time zone", + "primaryKey": false, + "notNull": false + }, + "failure_count": { + "name": "failure_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp (3) with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "v2_resource_deletion_jobs_generation_uidx": { + "name": "v2_resource_deletion_jobs_generation_uidx", + "columns": [ + { + "expression": "kind", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "resource_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "generation", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_resource_deletion_jobs_user_idx": { + "name": "v2_resource_deletion_jobs_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_resource_deletion_jobs_ready_idx": { + "name": "v2_resource_deletion_jobs_ready_idx", + "columns": [ + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "status = 'queued'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_resource_deletion_jobs_lease_idx": { + "name": "v2_resource_deletion_jobs_lease_idx", + "columns": [ + { + "expression": "lease_expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "status = 'leased'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { + "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", + "tableFrom": "v2_resource_deletion_jobs", + "tableTo": "v2_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "v2_resource_deletion_jobs_kind_check": { + "name": "v2_resource_deletion_jobs_kind_check", + "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" + }, + "v2_resource_deletion_jobs_phase_check": { + "name": "v2_resource_deletion_jobs_phase_check", + "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" + }, + "v2_resource_deletion_jobs_status_check": { + "name": "v2_resource_deletion_jobs_status_check", + "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" + }, + "v2_resource_deletion_jobs_counter_check": { + "name": "v2_resource_deletion_jobs_counter_check", + "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" + }, + "v2_resource_deletion_jobs_lease_check": { + "name": "v2_resource_deletion_jobs_lease_check", + "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" + } + }, + "isRLSEnabled": false + }, + "public.v2_threads": { + "name": "v2_threads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "public.uuidv7()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "launch_intent": { + "name": "launch_intent", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "active_run_id": { + "name": "active_run_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "latest_model_id": { + "name": "latest_model_id", + "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()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp (3) with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "v2_threads_user_page_idx": { + "name": "v2_threads_user_page_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "where": "deleted_at is null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_threads_project_page_idx": { + "name": "v2_threads_project_page_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "updated_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "where": "deleted_at is null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_threads_project_delete_idx": { + "name": "v2_threads_project_delete_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_threads_active_run_idx": { + "name": "v2_threads_active_run_idx", + "columns": [ + { + "expression": "active_run_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_threads\".\"active_run_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_threads_deletion_queue_idx": { + "name": "v2_threads_deletion_queue_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "deleted_at is not null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "v2_threads_user_id_v2_users_id_fk": { + "name": "v2_threads_user_id_v2_users_id_fk", + "tableFrom": "v2_threads", + "tableTo": "v2_users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "v2_threads_project_launch_intent_check": { + "name": "v2_threads_project_launch_intent_check", + "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" + }, + "v2_threads_launch_intent_object_check": { + "name": "v2_threads_launch_intent_object_check", + "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" + }, + "v2_threads_launch_default_model_check": { + "name": "v2_threads_launch_default_model_check", + "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" + }, + "v2_threads_latest_model_id_check": { + "name": "v2_threads_latest_model_id_check", + "value": "\"v2_threads\".\"latest_model_id\" is null or (\n char_length(\"v2_threads\".\"latest_model_id\") <= 200\n and \"v2_threads\".\"latest_model_id\"\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" + } + }, + "isRLSEnabled": false + }, + "public.v2_user_deletion_jobs": { + "name": "v2_user_deletion_jobs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "public.uuidv7()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "generation": { + "name": "generation", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "phase": { + "name": "phase", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'runs'" + }, + "cursor": { + "name": "cursor", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "continuation": { + "name": "continuation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'queued'" + }, + "lease_token": { + "name": "lease_token", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "lease_expires_at": { + "name": "lease_expires_at", + "type": "timestamp (3) with time zone", + "primaryKey": false, + "notNull": false + }, + "failure_count": { + "name": "failure_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", + "next_attempt_at": { + "name": "next_attempt_at", + "type": "timestamp (3) with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", + "last_error_code": { + "name": "last_error_code", + "type": "text", "primaryKey": false, "notNull": false } }, - "indexes": {}, + "indexes": { + "v2_user_deletion_jobs_generation_uidx": { + "name": "v2_user_deletion_jobs_generation_uidx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "generation", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_user_deletion_jobs_ready_idx": { + "name": "v2_user_deletion_jobs_ready_idx", + "columns": [ + { + "expression": "next_attempt_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_user_deletion_jobs_lease_idx": { + "name": "v2_user_deletion_jobs_lease_idx", + "columns": [ + { + "expression": "lease_expires_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", + "v2_user_deletion_jobs_user_id_v2_users_id_fk": { + "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", + "tableFrom": "v2_user_deletion_jobs", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" } }, "compositePrimaryKeys": {}, - "uniqueConstraints": {}, + "uniqueConstraints": { + "v2_user_deletion_jobs_id_user_generation_key": { + "name": "v2_user_deletion_jobs_id_user_generation_key", + "nullsNotDistinct": false, + "columns": [ + "id", + "user_id", + "generation" + ] + } + }, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_user_deletion_jobs_phase_check": { + "name": "v2_user_deletion_jobs_phase_check", + "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" + }, + "v2_user_deletion_jobs_status_check": { + "name": "v2_user_deletion_jobs_status_check", + "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" + }, + "v2_user_deletion_jobs_counter_check": { + "name": "v2_user_deletion_jobs_counter_check", + "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" + }, + "v2_user_deletion_jobs_lease_check": { + "name": "v2_user_deletion_jobs_lease_check", + "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" + } + }, "isRLSEnabled": false }, - "public.v2_threads": { - "name": "v2_threads", + "public.v2_user_deletion_refund_intents": { + "name": "v2_user_deletion_refund_intents", "schema": "", "columns": { - "id": { - "name": "id", + "job_id": { + "name": "job_id", "type": "uuid", "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, "notNull": true }, "user_id": { @@ -768,56 +2122,132 @@ "primaryKey": false, "notNull": true }, - "title": { - "name": "title", + "generation": { + "name": "generation", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "order_id": { + "name": "order_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "idempotency_key": { + "name": "idempotency_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_refund_id": { + "name": "provider_refund_id", "type": "text", "primaryKey": false, "notNull": false }, - "active_run_id": { - "name": "active_run_id", - "type": "uuid", + "provider_status": { + "name": "provider_status", + "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", + "type": "timestamp (3) with time zone", "primaryKey": false, "notNull": true, "default": "now()" }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", + "reconciled_at": { + "name": "reconciled_at", + "type": "timestamp (3) with time zone", "primaryKey": false, "notNull": false } }, - "indexes": {}, + "indexes": { + "v2_user_deletion_refund_intents_idempotency_uidx": { + "name": "v2_user_deletion_refund_intents_idempotency_uidx", + "columns": [ + { + "expression": "idempotency_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_user_deletion_refund_intents_provider_uidx": { + "name": "v2_user_deletion_refund_intents_provider_uidx", + "columns": [ + { + "expression": "provider_refund_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_user_deletion_refund_intents_unresolved_idx": { + "name": "v2_user_deletion_refund_intents_unresolved_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "job_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_user_deletion_refund_intents\".\"provider_status\" is distinct from 'succeeded'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "v2_user_deletion_refund_intents_job_identity_fk": { + "name": "v2_user_deletion_refund_intents_job_identity_fk", + "tableFrom": "v2_user_deletion_refund_intents", + "tableTo": "v2_user_deletion_jobs", + "columnsFrom": [ + "job_id", + "user_id", + "generation" + ], + "columnsTo": [ + "id", + "user_id", + "generation" + ], "onDelete": "cascade", "onUpdate": "no action" } @@ -825,11 +2255,32 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_user_deletion_refund_intents_amount_check": { + "name": "v2_user_deletion_refund_intents_amount_check", + "value": "\"v2_user_deletion_refund_intents\".\"amount\" > 0" + }, + "v2_user_deletion_refund_intents_currency_check": { + "name": "v2_user_deletion_refund_intents_currency_check", + "value": "\"v2_user_deletion_refund_intents\".\"currency\" ~ '^[a-z]{3}$'" + }, + "v2_user_deletion_refund_intents_order_check": { + "name": "v2_user_deletion_refund_intents_order_check", + "value": "length(btrim(\"v2_user_deletion_refund_intents\".\"order_id\")) > 0" + }, + "v2_user_deletion_refund_intents_identity_check": { + "name": "v2_user_deletion_refund_intents_identity_check", + "value": "\"v2_user_deletion_refund_intents\".\"idempotency_key\" = 'cheatcode:user-deletion-refund:' || \"v2_user_deletion_refund_intents\".\"job_id\"::text" + }, + "v2_user_deletion_refund_intents_provider_check": { + "name": "v2_user_deletion_refund_intents_provider_check", + "value": "(\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is null and \"v2_user_deletion_refund_intents\".\"provider_status\" is null and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is null)\n or\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null and length(btrim(\"v2_user_deletion_refund_intents\".\"provider_refund_id\")) > 0 and \"v2_user_deletion_refund_intents\".\"provider_status\" is not null and \"v2_user_deletion_refund_intents\".\"provider_status\" in ('pending', 'succeeded', 'failed', 'canceled') and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is not null)\n )" + } + }, "isRLSEnabled": false }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", + "public.v2_user_integrations": { + "name": "v2_user_integrations", "schema": "", "columns": { "user_id": { @@ -838,142 +2289,190 @@ "primaryKey": false, "notNull": true }, - "day": { - "name": "day", - "type": "date", + "integration": { + "name": "integration", + "type": "text", "primaryKey": false, "notNull": true }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 + "composio_connection_id": { + "name": "composio_connection_id", + "type": "text", + "primaryKey": true, + "notNull": true }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", + "is_default": { + "name": "is_default", + "type": "boolean", "primaryKey": false, "notNull": true, - "default": 0 + "default": false }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", + "status": { + "name": "status", + "type": "text", "primaryKey": false, - "notNull": true, - "default": 0 + "notNull": true }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", + "connected_at": { + "name": "connected_at", + "type": "timestamp with time zone", "primaryKey": false, "notNull": true, - "default": "'0'" + "default": "now()" }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", "primaryKey": false, "notNull": true, - "default": 0 + "default": "now()" + } + }, + "indexes": { + "v2_user_integrations_one_default_idx": { + "name": "v2_user_integrations_one_default_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "integration", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"v2_user_integrations\".\"is_default\" = true", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_user_integrations_delete_page_idx": { + "name": "v2_user_integrations_delete_page_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "composio_connection_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_user_integrations_user_toolkit_idx": { + "name": "v2_user_integrations_user_toolkit_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "integration", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} } }, - "indexes": {}, "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", + "v2_user_integrations_user_id_v2_users_id_fk": { + "name": "v2_user_integrations_user_id_v2_users_id_fk", + "tableFrom": "v2_user_integrations", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" } }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, + "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_user_integrations_connection_id_check": { + "name": "v2_user_integrations_connection_id_check", + "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" + }, + "v2_user_integrations_default_active_check": { + "name": "v2_user_integrations_default_active_check", + "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" + }, + "v2_user_integrations_integration_check": { + "name": "v2_user_integrations_integration_check", + "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" + } + }, "isRLSEnabled": false }, - "public.v2_usage_events": { - "name": "v2_usage_events", + "public.v2_user_profiles": { + "name": "v2_user_profiles", "schema": "", "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, "user_id": { "name": "user_id", "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, + "primaryKey": true, "notNull": true }, - "provider": { - "name": "provider", + "agent_display_name": { + "name": "agent_display_name", "type": "text", "primaryKey": false, "notNull": false }, - "model": { - "name": "model", + "global_memory": { + "name": "global_memory", "type": "text", "primaryKey": false, "notNull": false }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", + "disabled_models": { + "name": "disabled_models", + "type": "jsonb", "primaryKey": false, "notNull": true, - "default": 0 + "default": "'[]'::jsonb" }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", + "onboarding_completed_at": { + "name": "onboarding_completed_at", + "type": "timestamp with time zone", "primaryKey": false, - "notNull": true, - "default": 0 + "notNull": false }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", + "onboarding_state": { + "name": "onboarding_state", + "type": "jsonb", "primaryKey": false, "notNull": true, - "default": "'0'" + "default": "'{}'::jsonb" }, - "created_at": { - "name": "created_at", + "updated_at": { + "name": "updated_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, @@ -982,12 +2481,16 @@ }, "indexes": {}, "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", + "v2_user_profiles_user_id_v2_users_id_fk": { + "name": "v2_user_profiles_user_id_v2_users_id_fk", + "tableFrom": "v2_user_profiles", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" } @@ -995,39 +2498,68 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_user_profiles_disabled_models_array_check": { + "name": "v2_user_profiles_disabled_models_array_check", + "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" + }, + "v2_user_profiles_onboarding_state_object_check": { + "name": "v2_user_profiles_onboarding_state_object_check", + "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" + } + }, "isRLSEnabled": false }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", + "public.v2_user_skills": { + "name": "v2_user_skills", "schema": "", "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "public.uuidv7()" + }, "user_id": { "name": "user_id", "type": "uuid", "primaryKey": false, "notNull": true }, - "integration": { - "name": "integration", + "name": { + "name": "name", "type": "text", "primaryKey": false, "notNull": true }, - "composio_connection_id": { - "name": "composio_connection_id", + "description": { + "name": "description", "type": "text", "primaryKey": false, "notNull": true }, - "status": { - "name": "status", + "category": { + "name": "category", "type": "text", "primaryKey": false, "notNull": true }, - "connected_at": { - "name": "connected_at", + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, @@ -1041,27 +2573,53 @@ "default": "now()" } }, - "indexes": {}, + "indexes": { + "v2_user_skills_user_name_idx": { + "name": "v2_user_skills_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": {} + } + }, "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", + "v2_user_skills_user_id_v2_users_id_fk": { + "name": "v2_user_skills_user_id_v2_users_id_fk", + "tableFrom": "v2_user_skills", "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], "onDelete": "cascade", "onUpdate": "no action" } }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, + "compositePrimaryKeys": {}, "uniqueConstraints": {}, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_user_skills_tags_array_check": { + "name": "v2_user_skills_tags_array_check", + "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" + } + }, "isRLSEnabled": false }, "public.v2_users": { @@ -1081,6 +2639,12 @@ "primaryKey": false, "notNull": true }, + "clerk_updated_at_ms": { + "name": "clerk_updated_at_ms", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, "email": { "name": "email", "type": "text", @@ -1105,15 +2669,14 @@ "primaryKey": false, "notNull": false }, - "created_at": { - "name": "created_at", + "first_artifact_at": { + "name": "first_artifact_at", "type": "timestamp with time zone", "primaryKey": false, - "notNull": true, - "default": "now()" + "notNull": false }, - "updated_at": { - "name": "updated_at", + "created_at": { + "name": "created_at", "type": "timestamp with time zone", "primaryKey": false, "notNull": true, @@ -1124,25 +2687,85 @@ "type": "timestamp with time zone", "primaryKey": false, "notNull": false + }, + "deletion_fence": { + "name": "deletion_fence", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "v2_users_activation_created_idx": { + "name": "v2_users_activation_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_users\".\"deleted_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + }, + "v2_users_deletion_due_idx": { + "name": "v2_users_deletion_due_idx", + "columns": [ + { + "expression": "deleted_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"v2_users\".\"deleted_at\" is not null", + "concurrently": false, + "method": "btree", + "with": {} } }, - "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": {}, "uniqueConstraints": { "v2_users_clerk_id_unique": { "name": "v2_users_clerk_id_unique", "nullsNotDistinct": false, - "columns": ["clerk_id"] + "columns": [ + "clerk_id" + ] }, "v2_users_polar_customer_id_unique": { "name": "v2_users_polar_customer_id_unique", "nullsNotDistinct": false, - "columns": ["polar_customer_id"] + "columns": [ + "polar_customer_id" + ] } }, "policies": {}, - "checkConstraints": {}, + "checkConstraints": { + "v2_users_clerk_updated_at_ms_check": { + "name": "v2_users_clerk_updated_at_ms_check", + "value": "\"v2_users\".\"clerk_updated_at_ms\" between 0 and 9007199254740991" + } + }, "isRLSEnabled": false } }, @@ -1157,4 +2780,4 @@ "schemas": {}, "tables": {} } -} +} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0001_snapshot.json b/packages/db/drizzle/meta/0001_snapshot.json deleted file mode 100644 index bb34f389..00000000 --- a/packages/db/drizzle/meta/0001_snapshot.json +++ /dev/null @@ -1,1160 +0,0 @@ -{ - "id": "a1d1442d-e90c-421e-8ecd-625904c04fb2", - "prevId": "f60043b3-b57f-4190-9ff8-e192aad1a0b8", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','team','enterprise')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0002_snapshot.json b/packages/db/drizzle/meta/0002_snapshot.json deleted file mode 100644 index 7768fc10..00000000 --- a/packages/db/drizzle/meta/0002_snapshot.json +++ /dev/null @@ -1,1259 +0,0 @@ -{ - "id": "54c33d81-6647-4956-b89e-5098fefa477f", - "prevId": "a1d1442d-e90c-421e-8ecd-625904c04fb2", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','team','enterprise')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0003_snapshot.json b/packages/db/drizzle/meta/0003_snapshot.json deleted file mode 100644 index 48bfe8d8..00000000 --- a/packages/db/drizzle/meta/0003_snapshot.json +++ /dev/null @@ -1,1259 +0,0 @@ -{ - "id": "4f8d8b71-c368-4b58-9eff-1cac51a97df8", - "prevId": "54c33d81-6647-4956-b89e-5098fefa477f", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0004_snapshot.json b/packages/db/drizzle/meta/0004_snapshot.json deleted file mode 100644 index 90652354..00000000 --- a/packages/db/drizzle/meta/0004_snapshot.json +++ /dev/null @@ -1,1266 +0,0 @@ -{ - "id": "95dbb96a-d391-4837-a06f-e17ad57fbb2d", - "prevId": "4f8d8b71-c368-4b58-9eff-1cac51a97df8", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0005_snapshot.json b/packages/db/drizzle/meta/0005_snapshot.json deleted file mode 100644 index 5b45b640..00000000 --- a/packages/db/drizzle/meta/0005_snapshot.json +++ /dev/null @@ -1,1764 +0,0 @@ -{ - "id": "09448d78-81e1-4a50-98cd-75958e50e58d", - "prevId": "95dbb96a-d391-4837-a06f-e17ad57fbb2d", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0006_snapshot.json b/packages/db/drizzle/meta/0006_snapshot.json deleted file mode 100644 index 1fa80048..00000000 --- a/packages/db/drizzle/meta/0006_snapshot.json +++ /dev/null @@ -1,1764 +0,0 @@ -{ - "id": "65666ae4-aa5c-4edc-b0ec-cf890ca8cbe2", - "prevId": "09448d78-81e1-4a50-98cd-75958e50e58d", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0007_snapshot.json b/packages/db/drizzle/meta/0007_snapshot.json deleted file mode 100644 index 2e187b73..00000000 --- a/packages/db/drizzle/meta/0007_snapshot.json +++ /dev/null @@ -1,1889 +0,0 @@ -{ - "id": "1e060aa1-7429-49cb-afb6-a49ffd9f439b", - "prevId": "65666ae4-aa5c-4edc-b0ec-cf890ca8cbe2", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0008_snapshot.json b/packages/db/drizzle/meta/0008_snapshot.json deleted file mode 100644 index afe37b61..00000000 --- a/packages/db/drizzle/meta/0008_snapshot.json +++ /dev/null @@ -1,1912 +0,0 @@ -{ - "id": "2e61842b-5402-4b3d-9c62-a2e3aefae9fc", - "prevId": "1e060aa1-7429-49cb-afb6-a49ffd9f439b", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0009_snapshot.json b/packages/db/drizzle/meta/0009_snapshot.json deleted file mode 100644 index b9964085..00000000 --- a/packages/db/drizzle/meta/0009_snapshot.json +++ /dev/null @@ -1,1918 +0,0 @@ -{ - "id": "3ec05dea-3b9a-4302-a3a9-8ab2bcbee9bd", - "prevId": "2e61842b-5402-4b3d-9c62-a2e3aefae9fc", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0010_snapshot.json b/packages/db/drizzle/meta/0010_snapshot.json deleted file mode 100644 index b440be01..00000000 --- a/packages/db/drizzle/meta/0010_snapshot.json +++ /dev/null @@ -1,1918 +0,0 @@ -{ - "id": "0d6b2f96-1d4a-4e10-8bde-70c9115a1499", - "prevId": "3ec05dea-3b9a-4302-a3a9-8ab2bcbee9bd", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0011_snapshot.json b/packages/db/drizzle/meta/0011_snapshot.json deleted file mode 100644 index 11c2ef6a..00000000 --- a/packages/db/drizzle/meta/0011_snapshot.json +++ /dev/null @@ -1,1924 +0,0 @@ -{ - "id": "e1a7ab0f-0621-4550-a558-c6f946789090", - "prevId": "0d6b2f96-1d4a-4e10-8bde-70c9115a1499", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0012_snapshot.json b/packages/db/drizzle/meta/0012_snapshot.json deleted file mode 100644 index 3bd9b7f3..00000000 --- a/packages/db/drizzle/meta/0012_snapshot.json +++ /dev/null @@ -1,1947 +0,0 @@ -{ - "id": "51204e96-a5ea-4ce9-ada5-4a1fcfff6ddc", - "prevId": "e1a7ab0f-0621-4550-a558-c6f946789090", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "workspace_slug is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0013_snapshot.json b/packages/db/drizzle/meta/0013_snapshot.json deleted file mode 100644 index 667e1e17..00000000 --- a/packages/db/drizzle/meta/0013_snapshot.json +++ /dev/null @@ -1,1946 +0,0 @@ -{ - "id": "bb79bd8b-b708-4843-b1ff-87b0192b5acd", - "prevId": "51204e96-a5ea-4ce9-ada5-4a1fcfff6ddc", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_model": { - "name": "appbuilder_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "general_default_model": { - "name": "general_default_model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "appbuilder_default_budget_usd": { - "name": "appbuilder_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "general_default_budget_usd": { - "name": "general_default_budget_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0014_snapshot.json b/packages/db/drizzle/meta/0014_snapshot.json deleted file mode 100644 index 3591dccc..00000000 --- a/packages/db/drizzle/meta/0014_snapshot.json +++ /dev/null @@ -1,1922 +0,0 @@ -{ - "id": "71e90379-5c50-4a71-bb7d-710b34bad96a", - "prevId": "bb79bd8b-b708-4843-b1ff-87b0192b5acd", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_integration_pk": { - "name": "v2_user_integrations_user_id_integration_pk", - "columns": ["user_id", "integration"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0015_snapshot.json b/packages/db/drizzle/meta/0015_snapshot.json deleted file mode 100644 index 74f9514a..00000000 --- a/packages/db/drizzle/meta/0015_snapshot.json +++ /dev/null @@ -1,1973 +0,0 @@ -{ - "id": "6889ddcc-5795-4842-ad0a-6f1d6aae18fc", - "prevId": "71e90379-5c50-4a71-bb7d-710b34bad96a", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tokens_in": { - "name": "tokens_in", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_out": { - "name": "tokens_out", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "tokens_cached": { - "name": "tokens_cached", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_run_requests": { - "name": "v2_automation_run_requests", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "dedupe_key": { - "name": "dedupe_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "scheduled_for": { - "name": "scheduled_for", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "claimed_at": { - "name": "claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "attempts": { - "name": "attempts", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "normalized": { - "name": "normalized", - "type": "jsonb", - "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": { - "v2_automation_run_requests_dedupe_idx": { - "name": "v2_automation_run_requests_dedupe_idx", - "columns": [ - { - "expression": "dedupe_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_status_idx": { - "name": "v2_automation_run_requests_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "claimed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_run_requests_automation_idx": { - "name": "v2_automation_run_requests_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_run_requests_automation_id_v2_automations_id_fk": { - "name": "v2_automation_run_requests_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_run_requests_user_id_v2_users_id_fk": { - "name": "v2_automation_run_requests_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_run_requests", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automation_runs": { - "name": "v2_automation_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "automation_id": { - "name": "automation_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "request_id": { - "name": "request_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "deliveries": { - "name": "deliveries", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automation_runs_automation_idx": { - "name": "v2_automation_runs_automation_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automation_runs_active_idx": { - "name": "v2_automation_runs_active_idx", - "columns": [ - { - "expression": "automation_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "status in ('running')", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automation_runs_automation_id_v2_automations_id_fk": { - "name": "v2_automation_runs_automation_id_v2_automations_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_automations", - "columnsFrom": ["automation_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automation_runs_user_id_v2_users_id_fk": { - "name": "v2_automation_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_automation_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_automations": { - "name": "v2_automations", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'running'" - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "schedule": { - "name": "schedule", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_toolkit": { - "name": "trigger_toolkit", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_slug": { - "name": "trigger_slug", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "trigger_id": { - "name": "trigger_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "prompt": { - "name": "prompt", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "delivery_channels": { - "name": "delivery_channels", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "next_run_at": { - "name": "next_run_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "last_run_at": { - "name": "last_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_automations_user_idx": { - "name": "v2_automations_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_due_idx": { - "name": "v2_automations_due_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "next_run_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_automations_trigger_idx": { - "name": "v2_automations_trigger_idx", - "columns": [ - { - "expression": "trigger_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_automations_user_id_v2_users_id_fk": { - "name": "v2_automations_user_id_v2_users_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_automations_project_id_v2_projects_id_fk": { - "name": "v2_automations_project_id_v2_projects_id_fk", - "tableFrom": "v2_automations", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "free_deepseek_tokens_used": { - "name": "free_deepseek_tokens_used", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_daily_totals": { - "name": "v2_usage_daily_totals", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "day": { - "name": "day", - "type": "date", - "primaryKey": false, - "notNull": true - }, - "total_input_tokens": { - "name": "total_input_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_output_tokens": { - "name": "total_output_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cached_tokens": { - "name": "total_cached_tokens", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_usd": { - "name": "total_cost_usd", - "type": "numeric(12, 4)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "agent_run_count": { - "name": "agent_run_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_daily_totals_user_id_v2_users_id_fk": { - "name": "v2_usage_daily_totals_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_daily_totals", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_usage_daily_totals_user_id_day_pk": { - "name": "v2_usage_daily_totals_user_id_day_pk", - "columns": ["user_id", "day"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_usage_events": { - "name": "v2_usage_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "model": { - "name": "model", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cached_tokens": { - "name": "cached_tokens", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(12, 6)", - "primaryKey": false, - "notNull": true, - "default": "'0'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_usage_events_user_id_v2_users_id_fk": { - "name": "v2_usage_events_user_id_v2_users_id_fk", - "tableFrom": "v2_usage_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_composio_connection_id_pk": { - "name": "v2_user_integrations_user_id_composio_connection_id_pk", - "columns": ["user_id", "composio_connection_id"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0016_snapshot.json b/packages/db/drizzle/meta/0016_snapshot.json deleted file mode 100644 index 0aa1a82b..00000000 --- a/packages/db/drizzle/meta/0016_snapshot.json +++ /dev/null @@ -1,1270 +0,0 @@ -{ - "id": "dda00571-94c0-4332-b980-3d1b067a3068", - "prevId": "6889ddcc-5795-4842-ad0a-6f1d6aae18fc", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "max_concurrent_sandboxes": { - "name": "max_concurrent_sandboxes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "max_seats": { - "name": "max_seats", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "quota_deployments": { - "name": "quota_deployments", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "flag_private_projects": { - "name": "flag_private_projects", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "flag_sso": { - "name": "flag_sso", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_user_integrations_user_id_composio_connection_id_pk": { - "name": "v2_user_integrations_user_id_composio_connection_id_pk", - "columns": ["user_id", "composio_connection_id"] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0019_snapshot.json b/packages/db/drizzle/meta/0019_snapshot.json deleted file mode 100644 index 85dae0dd..00000000 --- a/packages/db/drizzle/meta/0019_snapshot.json +++ /dev/null @@ -1,1243 +0,0 @@ -{ - "id": "1e2d8428-27ce-4471-ad12-710d1e1f86ba", - "prevId": "dda00571-94c0-4332-b980-3d1b067a3068", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0020_snapshot.json b/packages/db/drizzle/meta/0020_snapshot.json deleted file mode 100644 index 767d1e7f..00000000 --- a/packages/db/drizzle/meta/0020_snapshot.json +++ /dev/null @@ -1,1249 +0,0 @@ -{ - "id": "d8947a44-e6a2-42f0-82af-832378340f06", - "prevId": "1e2d8428-27ce-4471-ad12-710d1e1f86ba", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0021_snapshot.json b/packages/db/drizzle/meta/0021_snapshot.json deleted file mode 100644 index d1a52a7e..00000000 --- a/packages/db/drizzle/meta/0021_snapshot.json +++ /dev/null @@ -1,1280 +0,0 @@ -{ - "id": "72751ba3-c6f4-474c-9eea-8366ad96506c", - "prevId": "d8947a44-e6a2-42f0-82af-832378340f06", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0022_snapshot.json b/packages/db/drizzle/meta/0022_snapshot.json deleted file mode 100644 index e9a38f26..00000000 --- a/packages/db/drizzle/meta/0022_snapshot.json +++ /dev/null @@ -1,1323 +0,0 @@ -{ - "id": "ecdcc44a-6e8d-4e4d-9749-cf063bf28e4c", - "prevId": "72751ba3-c6f4-474c-9eea-8366ad96506c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_recent_idx": { - "name": "v2_threads_user_recent_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0023_snapshot.json b/packages/db/drizzle/meta/0023_snapshot.json deleted file mode 100644 index 1d8575d0..00000000 --- a/packages/db/drizzle/meta/0023_snapshot.json +++ /dev/null @@ -1,1437 +0,0 @@ -{ - "id": "d63a09ff-d695-4fda-b2a5-9a1bca39b515", - "prevId": "ecdcc44a-6e8d-4e4d-9749-cf063bf28e4c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0024_snapshot.json b/packages/db/drizzle/meta/0024_snapshot.json deleted file mode 100644 index ad662180..00000000 --- a/packages/db/drizzle/meta/0024_snapshot.json +++ /dev/null @@ -1,1495 +0,0 @@ -{ - "id": "1d970a24-e551-4e79-8de1-9f90db2041d4", - "prevId": "d63a09ff-d695-4fda-b2a5-9a1bca39b515", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0025_snapshot.json b/packages/db/drizzle/meta/0025_snapshot.json deleted file mode 100644 index 750f02d8..00000000 --- a/packages/db/drizzle/meta/0025_snapshot.json +++ /dev/null @@ -1,1518 +0,0 @@ -{ - "id": "deb34b0a-951c-4514-b345-b8c51e58be01", - "prevId": "1d970a24-e551-4e79-8de1-9f90db2041d4", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_generated_outputs\".\"expires_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0026_snapshot.json b/packages/db/drizzle/meta/0026_snapshot.json deleted file mode 100644 index 7195f202..00000000 --- a/packages/db/drizzle/meta/0026_snapshot.json +++ /dev/null @@ -1,1524 +0,0 @@ -{ - "id": "3355bd4d-c367-4a6e-b343-12c93cc1335d", - "prevId": "deb34b0a-951c-4514-b345-b8c51e58be01", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_generated_outputs\".\"expires_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "container_backup": { - "name": "container_backup", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0027_snapshot.json b/packages/db/drizzle/meta/0027_snapshot.json deleted file mode 100644 index 362b04c7..00000000 --- a/packages/db/drizzle/meta/0027_snapshot.json +++ /dev/null @@ -1,1518 +0,0 @@ -{ - "id": "8b9d2349-d7d9-48f5-bf9b-05e53766ebc8", - "prevId": "3355bd4d-c367-4a6e-b343-12c93cc1335d", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_event_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_generated_outputs\".\"expires_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": ["agent_run_id"], - "columnsTo": ["id"], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": ["thread_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": ["project_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": ["user_id"], - "columnsTo": ["id"], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": ["clerk_id"] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": ["polar_customer_id"] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0028_snapshot.json b/packages/db/drizzle/meta/0028_snapshot.json deleted file mode 100644 index 78cdba73..00000000 --- a/packages/db/drizzle/meta/0028_snapshot.json +++ /dev/null @@ -1,1588 +0,0 @@ -{ - "id": "f69ec01a-f864-485f-9f31-34f3f087696b", - "prevId": "8b9d2349-d7d9-48f5-bf9b-05e53766ebc8", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_thread_id_v2_threads_id_fk": { - "name": "v2_agent_runs_thread_id_v2_threads_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_threads", - "columnsFrom": [ - "thread_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_event_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_generated_outputs\".\"expires_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_project_id_v2_projects_id_fk": { - "name": "v2_generated_outputs_project_id_v2_projects_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_projects", - "columnsFrom": [ - "project_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk": { - "name": "v2_generated_outputs_agent_run_id_v2_agent_runs_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_agent_runs", - "columnsFrom": [ - "agent_run_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_thread_id_v2_threads_id_fk": { - "name": "v2_messages_thread_id_v2_threads_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_threads", - "columnsFrom": [ - "thread_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_project_id_v2_projects_id_fk": { - "name": "v2_threads_project_id_v2_projects_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_projects", - "columnsFrom": [ - "project_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0029_snapshot.json b/packages/db/drizzle/meta/0029_snapshot.json deleted file mode 100644 index 6f857f72..00000000 --- a/packages/db/drizzle/meta/0029_snapshot.json +++ /dev/null @@ -1,1523 +0,0 @@ -{ - "id": "e1d8fb85-57a7-44eb-9407-5be54eb8f37d", - "prevId": "f69ec01a-f864-485f-9f31-34f3f087696b", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "config": { - "name": "config", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_event_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_generated_outputs\".\"expires_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "sandbox_id": { - "name": "sandbox_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0030_snapshot.json b/packages/db/drizzle/meta/0030_snapshot.json deleted file mode 100644 index b71a6e2b..00000000 --- a/packages/db/drizzle/meta/0030_snapshot.json +++ /dev/null @@ -1,1515 +0,0 @@ -{ - "id": "ee8e6a9e-a78d-42f4-a274-9ef1ba48f01b", - "prevId": "e1d8fb85-57a7-44eb-9407-5be54eb8f37d", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_event_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "webhook_event_id": { - "name": "webhook_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "source": { - "name": "source", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_generated_outputs\".\"expires_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0031_snapshot.json b/packages/db/drizzle/meta/0031_snapshot.json deleted file mode 100644 index 89b78eb1..00000000 --- a/packages/db/drizzle/meta/0031_snapshot.json +++ /dev/null @@ -1,1497 +0,0 @@ -{ - "id": "e33f09eb-c6ba-489d-923a-56e5d323656b", - "prevId": "ee8e6a9e-a78d-42f4-a274-9ef1ba48f01b", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_event_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_generated_outputs\".\"expires_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0032_snapshot.json b/packages/db/drizzle/meta/0032_snapshot.json deleted file mode 100644 index 8adb6fe9..00000000 --- a/packages/db/drizzle/meta/0032_snapshot.json +++ /dev/null @@ -1,1501 +0,0 @@ -{ - "id": "d05deab8-c449-4693-aa05-735e37c8190c", - "prevId": "e33f09eb-c6ba-489d-923a-56e5d323656b", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "error": { - "name": "error", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_billing_events": { - "name": "v2_billing_events", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "event_type": { - "name": "event_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "polar_event_id": { - "name": "polar_event_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "payload": { - "name": "payload", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "processed_at": { - "name": "processed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_billing_events_user_id_v2_users_id_fk": { - "name": "v2_billing_events_user_id_v2_users_id_fk", - "tableFrom": "v2_billing_events", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_billing_events_polar_event_id_unique": { - "name": "v2_billing_events_polar_event_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_event_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "max_projects": { - "name": "max_projects", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 3 - }, - "quota_sandbox_hours": { - "name": "quota_sandbox_hours", - "type": "numeric", - "primaryKey": false, - "notNull": true, - "default": "'5'" - }, - "quota_composio_calls": { - "name": "quota_composio_calls", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1000 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_bucket": { - "name": "r2_bucket", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'cheatcode-outputs'" - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "sha256": { - "name": "sha256", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "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()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_generated_outputs\".\"expires_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archived_pending_action": { - "name": "archived_pending_action", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_requested_at": { - "name": "workspace_cleanup_requested_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "workspace_cleanup_completed_at": { - "name": "workspace_cleanup_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_used_at": { - "name": "last_used_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "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": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_skills_user_idx": { - "name": "v2_user_skills_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_user_name_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0033_snapshot.json b/packages/db/drizzle/meta/0033_snapshot.json deleted file mode 100644 index 4a2d1137..00000000 --- a/packages/db/drizzle/meta/0033_snapshot.json +++ /dev/null @@ -1,1695 +0,0 @@ -{ - "id": "f64e2ff8-7186-4328-9a53-4e7ad548b3e7", - "prevId": "d05deab8-c449-4693-aa05-735e37c8190c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_assistant_uidx": { - "name": "v2_messages_agent_run_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_idx": { - "name": "v2_provider_keys_revalidation_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0034_snapshot.json b/packages/db/drizzle/meta/0034_snapshot.json deleted file mode 100644 index 742c9327..00000000 --- a/packages/db/drizzle/meta/0034_snapshot.json +++ /dev/null @@ -1,1744 +0,0 @@ -{ - "id": "504f208e-a3c0-469a-b10d-d71b61f240ca", - "prevId": "f64e2ff8-7186-4328-9a53-4e7ad548b3e7", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_idx": { - "name": "v2_provider_keys_revalidation_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0035_snapshot.json b/packages/db/drizzle/meta/0035_snapshot.json deleted file mode 100644 index d26ceab6..00000000 --- a/packages/db/drizzle/meta/0035_snapshot.json +++ /dev/null @@ -1,1767 +0,0 @@ -{ - "id": "d7c241b2-a803-4134-a547-bbcb52dbe3fe", - "prevId": "504f208e-a3c0-469a-b10d-d71b61f240ca", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_idx": { - "name": "v2_provider_keys_revalidation_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0036_snapshot.json b/packages/db/drizzle/meta/0036_snapshot.json deleted file mode 100644 index e4456f1f..00000000 --- a/packages/db/drizzle/meta/0036_snapshot.json +++ /dev/null @@ -1,1790 +0,0 @@ -{ - "id": "0b2f0cae-4a31-4c1d-8be4-3ccf12421299", - "prevId": "d7c241b2-a803-4134-a547-bbcb52dbe3fe", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0037_snapshot.json b/packages/db/drizzle/meta/0037_snapshot.json deleted file mode 100644 index 2722aae0..00000000 --- a/packages/db/drizzle/meta/0037_snapshot.json +++ /dev/null @@ -1,1811 +0,0 @@ -{ - "id": "c0cd8667-4409-44e1-a825-c517ce654d4c", - "prevId": "0b2f0cae-4a31-4c1d-8be4-3ccf12421299", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} diff --git a/packages/db/drizzle/meta/0038_snapshot.json b/packages/db/drizzle/meta/0038_snapshot.json deleted file mode 100644 index 0aac1f86..00000000 --- a/packages/db/drizzle/meta/0038_snapshot.json +++ /dev/null @@ -1,1815 +0,0 @@ -{ - "id": "b3d00290-ee3d-4b0b-b621-f61a1f33620c", - "prevId": "c0cd8667-4409-44e1-a825-c517ce654d4c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_workspace_slug_uidx": { - "name": "v2_projects_user_workspace_slug_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "workspace_slug", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0039_snapshot.json b/packages/db/drizzle/meta/0039_snapshot.json deleted file mode 100644 index 28e6f35b..00000000 --- a/packages/db/drizzle/meta/0039_snapshot.json +++ /dev/null @@ -1,1931 +0,0 @@ -{ - "id": "ae500a9e-0a24-42c8-b176-1a34cb19e313", - "prevId": "b3d00290-ee3d-4b0b-b621-f61a1f33620c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'paused', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_active_run_project_check": { - "name": "v2_threads_active_run_project_check", - "value": "\"v2_threads\".\"active_run_id\" is null or \"v2_threads\".\"project_id\" is not null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0040_snapshot.json b/packages/db/drizzle/meta/0040_snapshot.json deleted file mode 100644 index 13581e13..00000000 --- a/packages/db/drizzle/meta/0040_snapshot.json +++ /dev/null @@ -1,1953 +0,0 @@ -{ - "id": "3c3457e3-bbe2-433f-835f-aac97dbd49a9", - "prevId": "ae500a9e-0a24-42c8-b176-1a34cb19e313", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'paused', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_active_run_project_check": { - "name": "v2_threads_active_run_project_check", - "value": "\"v2_threads\".\"active_run_id\" is null or \"v2_threads\".\"project_id\" is not null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0041_snapshot.json b/packages/db/drizzle/meta/0041_snapshot.json deleted file mode 100644 index e0f0bccc..00000000 --- a/packages/db/drizzle/meta/0041_snapshot.json +++ /dev/null @@ -1,2141 +0,0 @@ -{ - "id": "656d482a-64e9-4e5f-9ab5-abc41f82463b", - "prevId": "3c3457e3-bbe2-433f-835f-aac97dbd49a9", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'paused', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_active_run_project_check": { - "name": "v2_threads_active_run_project_check", - "value": "\"v2_threads\".\"active_run_id\" is null or \"v2_threads\".\"project_id\" is not null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_jobs": { - "name": "v2_user_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_jobs_generation_uidx": { - "name": "v2_user_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_ready_idx": { - "name": "v2_user_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_lease_idx": { - "name": "v2_user_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_user_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_jobs_phase_check": { - "name": "v2_user_deletion_jobs_phase_check", - "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" - }, - "v2_user_deletion_jobs_status_check": { - "name": "v2_user_deletion_jobs_status_check", - "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_user_deletion_jobs_counter_check": { - "name": "v2_user_deletion_jobs_counter_check", - "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_user_deletion_jobs_lease_check": { - "name": "v2_user_deletion_jobs_lease_check", - "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0042_snapshot.json b/packages/db/drizzle/meta/0042_snapshot.json deleted file mode 100644 index eae9c784..00000000 --- a/packages/db/drizzle/meta/0042_snapshot.json +++ /dev/null @@ -1,2363 +0,0 @@ -{ - "id": "7d863be3-06c5-4271-a639-4d41bb049bc3", - "prevId": "656d482a-64e9-4e5f-9ab5-abc41f82463b", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'paused', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_retention_jobs": { - "name": "v2_retention_jobs", - "schema": "", - "columns": { - "day": { - "name": "day", - "type": "date", - "primaryKey": true, - "notNull": true - }, - "scheduled_at": { - "name": "scheduled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'activation'" - }, - "activation_cursor_event": { - "name": "activation_cursor_event", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "activation_cursor_user_id": { - "name": "activation_cursor_user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "output_cursor_expires_at": { - "name": "output_cursor_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "output_cursor_id": { - "name": "output_cursor_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "release_version_id": { - "name": "release_version_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_retention_jobs_ready_idx": { - "name": "v2_retention_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_lease_idx": { - "name": "v2_retention_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_completed_idx": { - "name": "v2_retention_jobs_completed_idx", - "columns": [ - { - "expression": "completed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'complete'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_retention_jobs_day_check": { - "name": "v2_retention_jobs_day_check", - "value": "\"v2_retention_jobs\".\"day\" = ((\"v2_retention_jobs\".\"scheduled_at\" at time zone 'UTC')::date - 1)" - }, - "v2_retention_jobs_phase_check": { - "name": "v2_retention_jobs_phase_check", - "value": "\"v2_retention_jobs\".\"phase\" in ('activation', 'cleanup')" - }, - "v2_retention_jobs_status_check": { - "name": "v2_retention_jobs_status_check", - "value": "\"v2_retention_jobs\".\"status\" in ('queued', 'leased', 'complete')" - }, - "v2_retention_jobs_counter_check": { - "name": "v2_retention_jobs_counter_check", - "value": "\"v2_retention_jobs\".\"continuation\" >= 0 and \"v2_retention_jobs\".\"failure_count\" >= 0" - }, - "v2_retention_jobs_error_code_check": { - "name": "v2_retention_jobs_error_code_check", - "value": "\"v2_retention_jobs\".\"last_error_code\" is null or octet_length(\"v2_retention_jobs\".\"last_error_code\") <= 128" - }, - "v2_retention_jobs_activation_cursor_check": { - "name": "v2_retention_jobs_activation_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'activation'\n and \"v2_retention_jobs\".\"activation_cursor_event\" in ('retention_d7', 'retention_d28', 'first_week_mau')\n and \"v2_retention_jobs\".\"activation_cursor_user_id\" is not null\n )\n )" - }, - "v2_retention_jobs_output_cursor_check": { - "name": "v2_retention_jobs_output_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"output_cursor_expires_at\" is null and \"v2_retention_jobs\".\"output_cursor_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'cleanup'\n and \"v2_retention_jobs\".\"output_cursor_expires_at\" is not null\n and \"v2_retention_jobs\".\"output_cursor_id\" is not null\n )\n )" - }, - "v2_retention_jobs_phase_cursor_check": { - "name": "v2_retention_jobs_phase_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"phase\" = 'activation' and \"v2_retention_jobs\".\"output_cursor_expires_at\" is null and \"v2_retention_jobs\".\"output_cursor_id\" is null)\n or\n (\"v2_retention_jobs\".\"phase\" = 'cleanup' and \"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n )" - }, - "v2_retention_jobs_lease_check": { - "name": "v2_retention_jobs_lease_check", - "value": "(\n (\n \"v2_retention_jobs\".\"status\" = 'leased'\n and \"v2_retention_jobs\".\"release_version_id\" is not null\n and \"v2_retention_jobs\".\"lease_token\" is not null\n and \"v2_retention_jobs\".\"lease_expires_at\" is not null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'queued'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'complete'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is not null\n )\n )" - }, - "v2_retention_jobs_terminal_phase_check": { - "name": "v2_retention_jobs_terminal_phase_check", - "value": "\"v2_retention_jobs\".\"status\" <> 'complete' or \"v2_retention_jobs\".\"phase\" = 'cleanup'" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_active_run_project_check": { - "name": "v2_threads_active_run_project_check", - "value": "\"v2_threads\".\"active_run_id\" is null or \"v2_threads\".\"project_id\" is not null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_jobs": { - "name": "v2_user_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_jobs_generation_uidx": { - "name": "v2_user_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_ready_idx": { - "name": "v2_user_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_lease_idx": { - "name": "v2_user_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_user_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_jobs_phase_check": { - "name": "v2_user_deletion_jobs_phase_check", - "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" - }, - "v2_user_deletion_jobs_status_check": { - "name": "v2_user_deletion_jobs_status_check", - "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_user_deletion_jobs_counter_check": { - "name": "v2_user_deletion_jobs_counter_check", - "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_user_deletion_jobs_lease_check": { - "name": "v2_user_deletion_jobs_lease_check", - "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0043_snapshot.json b/packages/db/drizzle/meta/0043_snapshot.json deleted file mode 100644 index ae6a4be8..00000000 --- a/packages/db/drizzle/meta/0043_snapshot.json +++ /dev/null @@ -1,2374 +0,0 @@ -{ - "id": "3a41b9cd-d1f8-4ca2-883d-02a83d355764", - "prevId": "7d863be3-06c5-4271-a639-4d41bb049bc3", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'paused', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_retention_jobs": { - "name": "v2_retention_jobs", - "schema": "", - "columns": { - "day": { - "name": "day", - "type": "date", - "primaryKey": true, - "notNull": true - }, - "scheduled_at": { - "name": "scheduled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'activation'" - }, - "activation_cursor_event": { - "name": "activation_cursor_event", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "activation_cursor_user_id": { - "name": "activation_cursor_user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "output_cursor_expires_at": { - "name": "output_cursor_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "output_cursor_id": { - "name": "output_cursor_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "release_version_id": { - "name": "release_version_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_retention_jobs_ready_idx": { - "name": "v2_retention_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_lease_idx": { - "name": "v2_retention_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_completed_idx": { - "name": "v2_retention_jobs_completed_idx", - "columns": [ - { - "expression": "completed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'complete'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_retention_jobs_day_check": { - "name": "v2_retention_jobs_day_check", - "value": "\"v2_retention_jobs\".\"day\" = ((\"v2_retention_jobs\".\"scheduled_at\" at time zone 'UTC')::date - 1)" - }, - "v2_retention_jobs_phase_check": { - "name": "v2_retention_jobs_phase_check", - "value": "\"v2_retention_jobs\".\"phase\" in ('activation', 'cleanup')" - }, - "v2_retention_jobs_status_check": { - "name": "v2_retention_jobs_status_check", - "value": "\"v2_retention_jobs\".\"status\" in ('queued', 'leased', 'complete')" - }, - "v2_retention_jobs_counter_check": { - "name": "v2_retention_jobs_counter_check", - "value": "\"v2_retention_jobs\".\"continuation\" >= 0 and \"v2_retention_jobs\".\"failure_count\" >= 0" - }, - "v2_retention_jobs_error_code_check": { - "name": "v2_retention_jobs_error_code_check", - "value": "\"v2_retention_jobs\".\"last_error_code\" is null or octet_length(\"v2_retention_jobs\".\"last_error_code\") <= 128" - }, - "v2_retention_jobs_activation_cursor_check": { - "name": "v2_retention_jobs_activation_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'activation'\n and \"v2_retention_jobs\".\"activation_cursor_event\" in ('retention_d7', 'retention_d28', 'first_week_mau')\n and \"v2_retention_jobs\".\"activation_cursor_user_id\" is not null\n )\n )" - }, - "v2_retention_jobs_output_cursor_check": { - "name": "v2_retention_jobs_output_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"output_cursor_expires_at\" is null and \"v2_retention_jobs\".\"output_cursor_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'cleanup'\n and \"v2_retention_jobs\".\"output_cursor_expires_at\" is not null\n and \"v2_retention_jobs\".\"output_cursor_id\" is not null\n )\n )" - }, - "v2_retention_jobs_phase_cursor_check": { - "name": "v2_retention_jobs_phase_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"phase\" = 'activation' and \"v2_retention_jobs\".\"output_cursor_expires_at\" is null and \"v2_retention_jobs\".\"output_cursor_id\" is null)\n or\n (\"v2_retention_jobs\".\"phase\" = 'cleanup' and \"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n )" - }, - "v2_retention_jobs_lease_check": { - "name": "v2_retention_jobs_lease_check", - "value": "(\n (\n \"v2_retention_jobs\".\"status\" = 'leased'\n and \"v2_retention_jobs\".\"release_version_id\" is not null\n and \"v2_retention_jobs\".\"lease_token\" is not null\n and \"v2_retention_jobs\".\"lease_expires_at\" is not null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'queued'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'complete'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is not null\n )\n )" - }, - "v2_retention_jobs_terminal_phase_check": { - "name": "v2_retention_jobs_terminal_phase_check", - "value": "\"v2_retention_jobs\".\"status\" <> 'complete' or \"v2_retention_jobs\".\"phase\" = 'cleanup'" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_active_run_project_check": { - "name": "v2_threads_active_run_project_check", - "value": "\"v2_threads\".\"active_run_id\" is null or \"v2_threads\".\"project_id\" is not null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_jobs": { - "name": "v2_user_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_jobs_generation_uidx": { - "name": "v2_user_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_ready_idx": { - "name": "v2_user_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_lease_idx": { - "name": "v2_user_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_user_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_jobs_phase_check": { - "name": "v2_user_deletion_jobs_phase_check", - "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" - }, - "v2_user_deletion_jobs_status_check": { - "name": "v2_user_deletion_jobs_status_check", - "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_user_deletion_jobs_counter_check": { - "name": "v2_user_deletion_jobs_counter_check", - "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_user_deletion_jobs_lease_check": { - "name": "v2_user_deletion_jobs_lease_check", - "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "clerk_updated_at_ms": { - "name": "clerk_updated_at_ms", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_users_clerk_updated_at_ms_check": { - "name": "v2_users_clerk_updated_at_ms_check", - "value": "\"v2_users\".\"clerk_updated_at_ms\" between 0 and 9007199254740991" - } - }, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0044_snapshot.json b/packages/db/drizzle/meta/0044_snapshot.json deleted file mode 100644 index f31cbc13..00000000 --- a/packages/db/drizzle/meta/0044_snapshot.json +++ /dev/null @@ -1,2778 +0,0 @@ -{ - "id": "a42bdc41-d6f9-4d3b-87c8-d8152d9bc879", - "prevId": "3a41b9cd-d1f8-4ca2-883d-02a83d355764", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_agent_runs_id_user_id_key": { - "name": "v2_agent_runs_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'paused', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_artifact_upload_intents": { - "name": "v2_artifact_upload_intents", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "cleanup_not_before": { - "name": "cleanup_not_before", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "quiesced_at": { - "name": "quiesced_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_artifact_upload_intents_cleanup_idx": { - "name": "v2_artifact_upload_intents_cleanup_idx", - "columns": [ - { - "expression": "cleanup_not_before", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "quiesced_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_artifact_upload_intents\".\"quiesced_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_user_idx": { - "name": "v2_artifact_upload_intents_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_project_idx": { - "name": "v2_artifact_upload_intents_project_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_run_idx": { - "name": "v2_artifact_upload_intents_run_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_artifact_upload_intents_project_user_fk": { - "name": "v2_artifact_upload_intents_project_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_projects", - "columnsFrom": [ - "project_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "v2_artifact_upload_intents_agent_run_user_fk": { - "name": "v2_artifact_upload_intents_agent_run_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_agent_runs", - "columnsFrom": [ - "agent_run_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_artifact_upload_intents_r2_key_unique": { - "name": "v2_artifact_upload_intents_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_artifact_upload_intents_r2_identity_check": { - "name": "v2_artifact_upload_intents_r2_identity_check", - "value": "\"v2_artifact_upload_intents\".\"r2_key\" like \"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-%'\n and strpos(substr(\"v2_artifact_upload_intents\".\"r2_key\", length(\"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-') + 1), '/') = 0\n and octet_length(\"v2_artifact_upload_intents\".\"r2_key\") <= 512" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_generated_outputs_expiry_idx": { - "name": "v2_generated_outputs_expiry_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "master_instructions": { - "name": "master_instructions", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_projects_id_user_id_key": { - "name": "v2_projects_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_retention_jobs": { - "name": "v2_retention_jobs", - "schema": "", - "columns": { - "day": { - "name": "day", - "type": "date", - "primaryKey": true, - "notNull": true - }, - "scheduled_at": { - "name": "scheduled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'activation'" - }, - "activation_cursor_event": { - "name": "activation_cursor_event", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "activation_cursor_user_id": { - "name": "activation_cursor_user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "output_cursor_expires_at": { - "name": "output_cursor_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "output_cursor_id": { - "name": "output_cursor_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "release_version_id": { - "name": "release_version_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_retention_jobs_ready_idx": { - "name": "v2_retention_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_lease_idx": { - "name": "v2_retention_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_completed_idx": { - "name": "v2_retention_jobs_completed_idx", - "columns": [ - { - "expression": "completed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'complete'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_retention_jobs_day_check": { - "name": "v2_retention_jobs_day_check", - "value": "\"v2_retention_jobs\".\"day\" = ((\"v2_retention_jobs\".\"scheduled_at\" at time zone 'UTC')::date - 1)" - }, - "v2_retention_jobs_phase_check": { - "name": "v2_retention_jobs_phase_check", - "value": "\"v2_retention_jobs\".\"phase\" in ('activation', 'cleanup')" - }, - "v2_retention_jobs_status_check": { - "name": "v2_retention_jobs_status_check", - "value": "\"v2_retention_jobs\".\"status\" in ('queued', 'leased', 'complete')" - }, - "v2_retention_jobs_counter_check": { - "name": "v2_retention_jobs_counter_check", - "value": "\"v2_retention_jobs\".\"continuation\" >= 0 and \"v2_retention_jobs\".\"failure_count\" >= 0" - }, - "v2_retention_jobs_error_code_check": { - "name": "v2_retention_jobs_error_code_check", - "value": "\"v2_retention_jobs\".\"last_error_code\" is null or octet_length(\"v2_retention_jobs\".\"last_error_code\") <= 128" - }, - "v2_retention_jobs_activation_cursor_check": { - "name": "v2_retention_jobs_activation_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'activation'\n and \"v2_retention_jobs\".\"activation_cursor_event\" in ('retention_d7', 'retention_d28', 'first_week_mau')\n and \"v2_retention_jobs\".\"activation_cursor_user_id\" is not null\n )\n )" - }, - "v2_retention_jobs_output_cursor_check": { - "name": "v2_retention_jobs_output_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"output_cursor_expires_at\" is null and \"v2_retention_jobs\".\"output_cursor_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'cleanup'\n and \"v2_retention_jobs\".\"output_cursor_expires_at\" is not null\n and \"v2_retention_jobs\".\"output_cursor_id\" is not null\n )\n )" - }, - "v2_retention_jobs_phase_cursor_check": { - "name": "v2_retention_jobs_phase_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"phase\" = 'activation' and \"v2_retention_jobs\".\"output_cursor_expires_at\" is null and \"v2_retention_jobs\".\"output_cursor_id\" is null)\n or\n (\"v2_retention_jobs\".\"phase\" = 'cleanup' and \"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n )" - }, - "v2_retention_jobs_lease_check": { - "name": "v2_retention_jobs_lease_check", - "value": "(\n (\n \"v2_retention_jobs\".\"status\" = 'leased'\n and \"v2_retention_jobs\".\"release_version_id\" is not null\n and \"v2_retention_jobs\".\"lease_token\" is not null\n and \"v2_retention_jobs\".\"lease_expires_at\" is not null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'queued'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'complete'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is not null\n )\n )" - }, - "v2_retention_jobs_terminal_phase_check": { - "name": "v2_retention_jobs_terminal_phase_check", - "value": "\"v2_retention_jobs\".\"status\" <> 'complete' or \"v2_retention_jobs\".\"phase\" = 'cleanup'" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_active_run_project_check": { - "name": "v2_threads_active_run_project_check", - "value": "\"v2_threads\".\"active_run_id\" is null or \"v2_threads\".\"project_id\" is not null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_jobs": { - "name": "v2_user_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_jobs_generation_uidx": { - "name": "v2_user_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_ready_idx": { - "name": "v2_user_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_lease_idx": { - "name": "v2_user_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_user_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_user_deletion_jobs_id_user_generation_key": { - "name": "v2_user_deletion_jobs_id_user_generation_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id", - "generation" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_jobs_phase_check": { - "name": "v2_user_deletion_jobs_phase_check", - "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" - }, - "v2_user_deletion_jobs_status_check": { - "name": "v2_user_deletion_jobs_status_check", - "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_user_deletion_jobs_counter_check": { - "name": "v2_user_deletion_jobs_counter_check", - "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_user_deletion_jobs_lease_check": { - "name": "v2_user_deletion_jobs_lease_check", - "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_refund_intents": { - "name": "v2_user_deletion_refund_intents", - "schema": "", - "columns": { - "job_id": { - "name": "job_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "order_id": { - "name": "order_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_refund_id": { - "name": "provider_refund_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_status": { - "name": "provider_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "reconciled_at": { - "name": "reconciled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_refund_intents_idempotency_uidx": { - "name": "v2_user_deletion_refund_intents_idempotency_uidx", - "columns": [ - { - "expression": "idempotency_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_provider_uidx": { - "name": "v2_user_deletion_refund_intents_provider_uidx", - "columns": [ - { - "expression": "provider_refund_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_unresolved_idx": { - "name": "v2_user_deletion_refund_intents_unresolved_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "job_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_refund_intents\".\"provider_status\" is distinct from 'succeeded'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_refund_intents_job_identity_fk": { - "name": "v2_user_deletion_refund_intents_job_identity_fk", - "tableFrom": "v2_user_deletion_refund_intents", - "tableTo": "v2_user_deletion_jobs", - "columnsFrom": [ - "job_id", - "user_id", - "generation" - ], - "columnsTo": [ - "id", - "user_id", - "generation" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_refund_intents_amount_check": { - "name": "v2_user_deletion_refund_intents_amount_check", - "value": "\"v2_user_deletion_refund_intents\".\"amount\" > 0" - }, - "v2_user_deletion_refund_intents_currency_check": { - "name": "v2_user_deletion_refund_intents_currency_check", - "value": "\"v2_user_deletion_refund_intents\".\"currency\" ~ '^[a-z]{3}$'" - }, - "v2_user_deletion_refund_intents_order_check": { - "name": "v2_user_deletion_refund_intents_order_check", - "value": "length(btrim(\"v2_user_deletion_refund_intents\".\"order_id\")) > 0" - }, - "v2_user_deletion_refund_intents_identity_check": { - "name": "v2_user_deletion_refund_intents_identity_check", - "value": "\"v2_user_deletion_refund_intents\".\"idempotency_key\" = 'cheatcode:user-deletion-refund:' || \"v2_user_deletion_refund_intents\".\"job_id\"::text" - }, - "v2_user_deletion_refund_intents_provider_check": { - "name": "v2_user_deletion_refund_intents_provider_check", - "value": "(\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is null and \"v2_user_deletion_refund_intents\".\"provider_status\" is null and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is null)\n or\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null and length(btrim(\"v2_user_deletion_refund_intents\".\"provider_refund_id\")) > 0 and \"v2_user_deletion_refund_intents\".\"provider_status\" is not null and \"v2_user_deletion_refund_intents\".\"provider_status\" in ('pending', 'succeeded', 'failed', 'canceled') and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is not null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "clerk_updated_at_ms": { - "name": "clerk_updated_at_ms", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_users_clerk_updated_at_ms_check": { - "name": "v2_users_clerk_updated_at_ms_check", - "value": "\"v2_users\".\"clerk_updated_at_ms\" between 0 and 9007199254740991" - } - }, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0045_snapshot.json b/packages/db/drizzle/meta/0045_snapshot.json deleted file mode 100644 index 5e08a9f3..00000000 --- a/packages/db/drizzle/meta/0045_snapshot.json +++ /dev/null @@ -1,2725 +0,0 @@ -{ - "id": "91df6f01-d0d6-4f3c-b166-534bd75e87f4", - "prevId": "a42bdc41-d6f9-4d3b-87c8-d8152d9bc879", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_agent_runs_id_user_id_key": { - "name": "v2_agent_runs_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_artifact_upload_intents": { - "name": "v2_artifact_upload_intents", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "cleanup_not_before": { - "name": "cleanup_not_before", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "quiesced_at": { - "name": "quiesced_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_artifact_upload_intents_cleanup_idx": { - "name": "v2_artifact_upload_intents_cleanup_idx", - "columns": [ - { - "expression": "cleanup_not_before", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "quiesced_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_artifact_upload_intents\".\"quiesced_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_user_idx": { - "name": "v2_artifact_upload_intents_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_project_idx": { - "name": "v2_artifact_upload_intents_project_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_run_idx": { - "name": "v2_artifact_upload_intents_run_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_artifact_upload_intents_project_user_fk": { - "name": "v2_artifact_upload_intents_project_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_projects", - "columnsFrom": [ - "project_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "v2_artifact_upload_intents_agent_run_user_fk": { - "name": "v2_artifact_upload_intents_agent_run_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_agent_runs", - "columnsFrom": [ - "agent_run_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_artifact_upload_intents_r2_key_unique": { - "name": "v2_artifact_upload_intents_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_artifact_upload_intents_r2_identity_check": { - "name": "v2_artifact_upload_intents_r2_identity_check", - "value": "\"v2_artifact_upload_intents\".\"r2_key\" like \"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-%'\n and strpos(substr(\"v2_artifact_upload_intents\".\"r2_key\", length(\"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-') + 1), '/') = 0\n and octet_length(\"v2_artifact_upload_intents\".\"r2_key\") <= 512" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_projects_id_user_id_key": { - "name": "v2_projects_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_retention_jobs": { - "name": "v2_retention_jobs", - "schema": "", - "columns": { - "day": { - "name": "day", - "type": "date", - "primaryKey": true, - "notNull": true - }, - "scheduled_at": { - "name": "scheduled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'activation'" - }, - "activation_cursor_event": { - "name": "activation_cursor_event", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "activation_cursor_user_id": { - "name": "activation_cursor_user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "release_version_id": { - "name": "release_version_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_retention_jobs_ready_idx": { - "name": "v2_retention_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_lease_idx": { - "name": "v2_retention_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_completed_idx": { - "name": "v2_retention_jobs_completed_idx", - "columns": [ - { - "expression": "completed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'complete'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_retention_jobs_day_check": { - "name": "v2_retention_jobs_day_check", - "value": "\"v2_retention_jobs\".\"day\" = ((\"v2_retention_jobs\".\"scheduled_at\" at time zone 'UTC')::date - 1)" - }, - "v2_retention_jobs_phase_check": { - "name": "v2_retention_jobs_phase_check", - "value": "\"v2_retention_jobs\".\"phase\" in ('activation', 'cleanup')" - }, - "v2_retention_jobs_status_check": { - "name": "v2_retention_jobs_status_check", - "value": "\"v2_retention_jobs\".\"status\" in ('queued', 'leased', 'complete')" - }, - "v2_retention_jobs_counter_check": { - "name": "v2_retention_jobs_counter_check", - "value": "\"v2_retention_jobs\".\"continuation\" >= 0 and \"v2_retention_jobs\".\"failure_count\" >= 0" - }, - "v2_retention_jobs_error_code_check": { - "name": "v2_retention_jobs_error_code_check", - "value": "\"v2_retention_jobs\".\"last_error_code\" is null or octet_length(\"v2_retention_jobs\".\"last_error_code\") <= 128" - }, - "v2_retention_jobs_activation_cursor_check": { - "name": "v2_retention_jobs_activation_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'activation'\n and \"v2_retention_jobs\".\"activation_cursor_event\" in ('retention_d7', 'retention_d28', 'first_week_mau')\n and \"v2_retention_jobs\".\"activation_cursor_user_id\" is not null\n )\n )" - }, - "v2_retention_jobs_phase_cursor_check": { - "name": "v2_retention_jobs_phase_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"phase\" = 'activation')\n or\n (\"v2_retention_jobs\".\"phase\" = 'cleanup' and \"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n )" - }, - "v2_retention_jobs_lease_check": { - "name": "v2_retention_jobs_lease_check", - "value": "(\n (\n \"v2_retention_jobs\".\"status\" = 'leased'\n and \"v2_retention_jobs\".\"release_version_id\" is not null\n and \"v2_retention_jobs\".\"lease_token\" is not null\n and \"v2_retention_jobs\".\"lease_expires_at\" is not null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'queued'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'complete'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is not null\n )\n )" - }, - "v2_retention_jobs_terminal_phase_check": { - "name": "v2_retention_jobs_terminal_phase_check", - "value": "\"v2_retention_jobs\".\"status\" <> 'complete' or \"v2_retention_jobs\".\"phase\" = 'cleanup'" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_jobs": { - "name": "v2_user_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_jobs_generation_uidx": { - "name": "v2_user_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_ready_idx": { - "name": "v2_user_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_lease_idx": { - "name": "v2_user_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_user_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_user_deletion_jobs_id_user_generation_key": { - "name": "v2_user_deletion_jobs_id_user_generation_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id", - "generation" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_jobs_phase_check": { - "name": "v2_user_deletion_jobs_phase_check", - "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" - }, - "v2_user_deletion_jobs_status_check": { - "name": "v2_user_deletion_jobs_status_check", - "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_user_deletion_jobs_counter_check": { - "name": "v2_user_deletion_jobs_counter_check", - "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_user_deletion_jobs_lease_check": { - "name": "v2_user_deletion_jobs_lease_check", - "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_refund_intents": { - "name": "v2_user_deletion_refund_intents", - "schema": "", - "columns": { - "job_id": { - "name": "job_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "order_id": { - "name": "order_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_refund_id": { - "name": "provider_refund_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_status": { - "name": "provider_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "reconciled_at": { - "name": "reconciled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_refund_intents_idempotency_uidx": { - "name": "v2_user_deletion_refund_intents_idempotency_uidx", - "columns": [ - { - "expression": "idempotency_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_provider_uidx": { - "name": "v2_user_deletion_refund_intents_provider_uidx", - "columns": [ - { - "expression": "provider_refund_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_unresolved_idx": { - "name": "v2_user_deletion_refund_intents_unresolved_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "job_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_refund_intents\".\"provider_status\" is distinct from 'succeeded'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_refund_intents_job_identity_fk": { - "name": "v2_user_deletion_refund_intents_job_identity_fk", - "tableFrom": "v2_user_deletion_refund_intents", - "tableTo": "v2_user_deletion_jobs", - "columnsFrom": [ - "job_id", - "user_id", - "generation" - ], - "columnsTo": [ - "id", - "user_id", - "generation" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_refund_intents_amount_check": { - "name": "v2_user_deletion_refund_intents_amount_check", - "value": "\"v2_user_deletion_refund_intents\".\"amount\" > 0" - }, - "v2_user_deletion_refund_intents_currency_check": { - "name": "v2_user_deletion_refund_intents_currency_check", - "value": "\"v2_user_deletion_refund_intents\".\"currency\" ~ '^[a-z]{3}$'" - }, - "v2_user_deletion_refund_intents_order_check": { - "name": "v2_user_deletion_refund_intents_order_check", - "value": "length(btrim(\"v2_user_deletion_refund_intents\".\"order_id\")) > 0" - }, - "v2_user_deletion_refund_intents_identity_check": { - "name": "v2_user_deletion_refund_intents_identity_check", - "value": "\"v2_user_deletion_refund_intents\".\"idempotency_key\" = 'cheatcode:user-deletion-refund:' || \"v2_user_deletion_refund_intents\".\"job_id\"::text" - }, - "v2_user_deletion_refund_intents_provider_check": { - "name": "v2_user_deletion_refund_intents_provider_check", - "value": "(\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is null and \"v2_user_deletion_refund_intents\".\"provider_status\" is null and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is null)\n or\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null and length(btrim(\"v2_user_deletion_refund_intents\".\"provider_refund_id\")) > 0 and \"v2_user_deletion_refund_intents\".\"provider_status\" is not null and \"v2_user_deletion_refund_intents\".\"provider_status\" in ('pending', 'succeeded', 'failed', 'canceled') and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is not null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "clerk_updated_at_ms": { - "name": "clerk_updated_at_ms", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_users_clerk_updated_at_ms_check": { - "name": "v2_users_clerk_updated_at_ms_check", - "value": "\"v2_users\".\"clerk_updated_at_ms\" between 0 and 9007199254740991" - } - }, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0046_snapshot.json b/packages/db/drizzle/meta/0046_snapshot.json deleted file mode 100644 index 139556e7..00000000 --- a/packages/db/drizzle/meta/0046_snapshot.json +++ /dev/null @@ -1,2735 +0,0 @@ -{ - "id": "297e0e8b-a7de-479d-86a1-97f259ad7d23", - "prevId": "91df6f01-d0d6-4f3c-b166-534bd75e87f4", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_agent_runs_id_user_id_key": { - "name": "v2_agent_runs_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_artifact_upload_intents": { - "name": "v2_artifact_upload_intents", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "cleanup_not_before": { - "name": "cleanup_not_before", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "quiesced_at": { - "name": "quiesced_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_artifact_upload_intents_cleanup_idx": { - "name": "v2_artifact_upload_intents_cleanup_idx", - "columns": [ - { - "expression": "cleanup_not_before", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "quiesced_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_artifact_upload_intents\".\"quiesced_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_user_idx": { - "name": "v2_artifact_upload_intents_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_project_idx": { - "name": "v2_artifact_upload_intents_project_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_run_idx": { - "name": "v2_artifact_upload_intents_run_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_artifact_upload_intents_project_user_fk": { - "name": "v2_artifact_upload_intents_project_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_projects", - "columnsFrom": [ - "project_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "v2_artifact_upload_intents_agent_run_user_fk": { - "name": "v2_artifact_upload_intents_agent_run_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_agent_runs", - "columnsFrom": [ - "agent_run_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_artifact_upload_intents_r2_key_unique": { - "name": "v2_artifact_upload_intents_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_artifact_upload_intents_r2_identity_check": { - "name": "v2_artifact_upload_intents_r2_identity_check", - "value": "\"v2_artifact_upload_intents\".\"r2_key\" like \"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-%'\n and strpos(substr(\"v2_artifact_upload_intents\".\"r2_key\", length(\"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-') + 1), '/') = 0\n and octet_length(\"v2_artifact_upload_intents\".\"r2_key\") <= 512" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_projects_id_user_id_key": { - "name": "v2_projects_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_retention_jobs": { - "name": "v2_retention_jobs", - "schema": "", - "columns": { - "day": { - "name": "day", - "type": "date", - "primaryKey": true, - "notNull": true - }, - "scheduled_at": { - "name": "scheduled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'activation'" - }, - "activation_cursor_event": { - "name": "activation_cursor_event", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "activation_cursor_user_id": { - "name": "activation_cursor_user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "release_version_id": { - "name": "release_version_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_retention_jobs_ready_idx": { - "name": "v2_retention_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_lease_idx": { - "name": "v2_retention_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_completed_idx": { - "name": "v2_retention_jobs_completed_idx", - "columns": [ - { - "expression": "completed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'complete'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_retention_jobs_day_check": { - "name": "v2_retention_jobs_day_check", - "value": "\"v2_retention_jobs\".\"day\" = ((\"v2_retention_jobs\".\"scheduled_at\" at time zone 'UTC')::date - 1)" - }, - "v2_retention_jobs_phase_check": { - "name": "v2_retention_jobs_phase_check", - "value": "\"v2_retention_jobs\".\"phase\" in ('activation', 'cleanup')" - }, - "v2_retention_jobs_status_check": { - "name": "v2_retention_jobs_status_check", - "value": "\"v2_retention_jobs\".\"status\" in ('queued', 'leased', 'complete')" - }, - "v2_retention_jobs_counter_check": { - "name": "v2_retention_jobs_counter_check", - "value": "\"v2_retention_jobs\".\"continuation\" >= 0 and \"v2_retention_jobs\".\"failure_count\" >= 0" - }, - "v2_retention_jobs_error_code_check": { - "name": "v2_retention_jobs_error_code_check", - "value": "\"v2_retention_jobs\".\"last_error_code\" is null or octet_length(\"v2_retention_jobs\".\"last_error_code\") <= 128" - }, - "v2_retention_jobs_activation_cursor_check": { - "name": "v2_retention_jobs_activation_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'activation'\n and \"v2_retention_jobs\".\"activation_cursor_event\" in ('retention_d7', 'retention_d28', 'first_week_mau')\n and \"v2_retention_jobs\".\"activation_cursor_user_id\" is not null\n )\n )" - }, - "v2_retention_jobs_phase_cursor_check": { - "name": "v2_retention_jobs_phase_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"phase\" = 'activation')\n or\n (\"v2_retention_jobs\".\"phase\" = 'cleanup' and \"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n )" - }, - "v2_retention_jobs_lease_check": { - "name": "v2_retention_jobs_lease_check", - "value": "(\n (\n \"v2_retention_jobs\".\"status\" = 'leased'\n and \"v2_retention_jobs\".\"release_version_id\" is not null\n and \"v2_retention_jobs\".\"lease_token\" is not null\n and \"v2_retention_jobs\".\"lease_expires_at\" is not null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'queued'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'complete'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is not null\n )\n )" - }, - "v2_retention_jobs_terminal_phase_check": { - "name": "v2_retention_jobs_terminal_phase_check", - "value": "\"v2_retention_jobs\".\"status\" <> 'complete' or \"v2_retention_jobs\".\"phase\" = 'cleanup'" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "latest_model_id": { - "name": "latest_model_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - }, - "v2_threads_latest_model_id_check": { - "name": "v2_threads_latest_model_id_check", - "value": "\"v2_threads\".\"latest_model_id\" is null or (\n char_length(\"v2_threads\".\"latest_model_id\") <= 200\n and \"v2_threads\".\"latest_model_id\"\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_jobs": { - "name": "v2_user_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_jobs_generation_uidx": { - "name": "v2_user_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_ready_idx": { - "name": "v2_user_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_lease_idx": { - "name": "v2_user_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_user_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_user_deletion_jobs_id_user_generation_key": { - "name": "v2_user_deletion_jobs_id_user_generation_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id", - "generation" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_jobs_phase_check": { - "name": "v2_user_deletion_jobs_phase_check", - "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" - }, - "v2_user_deletion_jobs_status_check": { - "name": "v2_user_deletion_jobs_status_check", - "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_user_deletion_jobs_counter_check": { - "name": "v2_user_deletion_jobs_counter_check", - "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_user_deletion_jobs_lease_check": { - "name": "v2_user_deletion_jobs_lease_check", - "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_refund_intents": { - "name": "v2_user_deletion_refund_intents", - "schema": "", - "columns": { - "job_id": { - "name": "job_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "order_id": { - "name": "order_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_refund_id": { - "name": "provider_refund_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_status": { - "name": "provider_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "reconciled_at": { - "name": "reconciled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_refund_intents_idempotency_uidx": { - "name": "v2_user_deletion_refund_intents_idempotency_uidx", - "columns": [ - { - "expression": "idempotency_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_provider_uidx": { - "name": "v2_user_deletion_refund_intents_provider_uidx", - "columns": [ - { - "expression": "provider_refund_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_unresolved_idx": { - "name": "v2_user_deletion_refund_intents_unresolved_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "job_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_refund_intents\".\"provider_status\" is distinct from 'succeeded'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_refund_intents_job_identity_fk": { - "name": "v2_user_deletion_refund_intents_job_identity_fk", - "tableFrom": "v2_user_deletion_refund_intents", - "tableTo": "v2_user_deletion_jobs", - "columnsFrom": [ - "job_id", - "user_id", - "generation" - ], - "columnsTo": [ - "id", - "user_id", - "generation" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_refund_intents_amount_check": { - "name": "v2_user_deletion_refund_intents_amount_check", - "value": "\"v2_user_deletion_refund_intents\".\"amount\" > 0" - }, - "v2_user_deletion_refund_intents_currency_check": { - "name": "v2_user_deletion_refund_intents_currency_check", - "value": "\"v2_user_deletion_refund_intents\".\"currency\" ~ '^[a-z]{3}$'" - }, - "v2_user_deletion_refund_intents_order_check": { - "name": "v2_user_deletion_refund_intents_order_check", - "value": "length(btrim(\"v2_user_deletion_refund_intents\".\"order_id\")) > 0" - }, - "v2_user_deletion_refund_intents_identity_check": { - "name": "v2_user_deletion_refund_intents_identity_check", - "value": "\"v2_user_deletion_refund_intents\".\"idempotency_key\" = 'cheatcode:user-deletion-refund:' || \"v2_user_deletion_refund_intents\".\"job_id\"::text" - }, - "v2_user_deletion_refund_intents_provider_check": { - "name": "v2_user_deletion_refund_intents_provider_check", - "value": "(\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is null and \"v2_user_deletion_refund_intents\".\"provider_status\" is null and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is null)\n or\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null and length(btrim(\"v2_user_deletion_refund_intents\".\"provider_refund_id\")) > 0 and \"v2_user_deletion_refund_intents\".\"provider_status\" is not null and \"v2_user_deletion_refund_intents\".\"provider_status\" in ('pending', 'succeeded', 'failed', 'canceled') and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is not null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "clerk_updated_at_ms": { - "name": "clerk_updated_at_ms", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_users_clerk_updated_at_ms_check": { - "name": "v2_users_clerk_updated_at_ms_check", - "value": "\"v2_users\".\"clerk_updated_at_ms\" between 0 and 9007199254740991" - } - }, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0047_snapshot.json b/packages/db/drizzle/meta/0047_snapshot.json deleted file mode 100644 index 83c98254..00000000 --- a/packages/db/drizzle/meta/0047_snapshot.json +++ /dev/null @@ -1,2783 +0,0 @@ -{ - "id": "bb6aeaa8-7c0d-444f-b992-08dd3c958668", - "prevId": "297e0e8b-a7de-479d-86a1-97f259ad7d23", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_agent_runs_id_user_id_key": { - "name": "v2_agent_runs_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_artifact_upload_intents": { - "name": "v2_artifact_upload_intents", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "cleanup_not_before": { - "name": "cleanup_not_before", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "quiesced_at": { - "name": "quiesced_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_artifact_upload_intents_cleanup_idx": { - "name": "v2_artifact_upload_intents_cleanup_idx", - "columns": [ - { - "expression": "cleanup_not_before", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "quiesced_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_artifact_upload_intents\".\"quiesced_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_user_idx": { - "name": "v2_artifact_upload_intents_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_project_idx": { - "name": "v2_artifact_upload_intents_project_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_run_idx": { - "name": "v2_artifact_upload_intents_run_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_artifact_upload_intents_project_user_fk": { - "name": "v2_artifact_upload_intents_project_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_projects", - "columnsFrom": [ - "project_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "v2_artifact_upload_intents_agent_run_user_fk": { - "name": "v2_artifact_upload_intents_agent_run_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_agent_runs", - "columnsFrom": [ - "agent_run_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_artifact_upload_intents_r2_key_unique": { - "name": "v2_artifact_upload_intents_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_artifact_upload_intents_r2_identity_check": { - "name": "v2_artifact_upload_intents_r2_identity_check", - "value": "\"v2_artifact_upload_intents\".\"r2_key\" like \"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-%'\n and strpos(substr(\"v2_artifact_upload_intents\".\"r2_key\", length(\"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-') + 1), '/') = 0\n and octet_length(\"v2_artifact_upload_intents\".\"r2_key\") <= 512" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_scope_idx": { - "name": "v2_messages_agent_run_scope_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_delete_idx": { - "name": "v2_projects_user_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_projects_id_user_id_key": { - "name": "v2_projects_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_retention_jobs": { - "name": "v2_retention_jobs", - "schema": "", - "columns": { - "day": { - "name": "day", - "type": "date", - "primaryKey": true, - "notNull": true - }, - "scheduled_at": { - "name": "scheduled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'activation'" - }, - "activation_cursor_event": { - "name": "activation_cursor_event", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "activation_cursor_user_id": { - "name": "activation_cursor_user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "release_version_id": { - "name": "release_version_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_retention_jobs_ready_idx": { - "name": "v2_retention_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_lease_idx": { - "name": "v2_retention_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_retention_jobs_completed_idx": { - "name": "v2_retention_jobs_completed_idx", - "columns": [ - { - "expression": "completed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_retention_jobs\".\"status\" = 'complete'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_retention_jobs_day_check": { - "name": "v2_retention_jobs_day_check", - "value": "\"v2_retention_jobs\".\"day\" = ((\"v2_retention_jobs\".\"scheduled_at\" at time zone 'UTC')::date - 1)" - }, - "v2_retention_jobs_phase_check": { - "name": "v2_retention_jobs_phase_check", - "value": "\"v2_retention_jobs\".\"phase\" in ('activation', 'cleanup')" - }, - "v2_retention_jobs_status_check": { - "name": "v2_retention_jobs_status_check", - "value": "\"v2_retention_jobs\".\"status\" in ('queued', 'leased', 'complete')" - }, - "v2_retention_jobs_counter_check": { - "name": "v2_retention_jobs_counter_check", - "value": "\"v2_retention_jobs\".\"continuation\" >= 0 and \"v2_retention_jobs\".\"failure_count\" >= 0" - }, - "v2_retention_jobs_error_code_check": { - "name": "v2_retention_jobs_error_code_check", - "value": "\"v2_retention_jobs\".\"last_error_code\" is null or octet_length(\"v2_retention_jobs\".\"last_error_code\") <= 128" - }, - "v2_retention_jobs_activation_cursor_check": { - "name": "v2_retention_jobs_activation_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n or\n (\n \"v2_retention_jobs\".\"phase\" = 'activation'\n and \"v2_retention_jobs\".\"activation_cursor_event\" in ('retention_d7', 'retention_d28', 'first_week_mau')\n and \"v2_retention_jobs\".\"activation_cursor_user_id\" is not null\n )\n )" - }, - "v2_retention_jobs_phase_cursor_check": { - "name": "v2_retention_jobs_phase_cursor_check", - "value": "(\n (\"v2_retention_jobs\".\"phase\" = 'activation')\n or\n (\"v2_retention_jobs\".\"phase\" = 'cleanup' and \"v2_retention_jobs\".\"activation_cursor_event\" is null and \"v2_retention_jobs\".\"activation_cursor_user_id\" is null)\n )" - }, - "v2_retention_jobs_lease_check": { - "name": "v2_retention_jobs_lease_check", - "value": "(\n (\n \"v2_retention_jobs\".\"status\" = 'leased'\n and \"v2_retention_jobs\".\"release_version_id\" is not null\n and \"v2_retention_jobs\".\"lease_token\" is not null\n and \"v2_retention_jobs\".\"lease_expires_at\" is not null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'queued'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_retention_jobs\".\"status\" = 'complete'\n and \"v2_retention_jobs\".\"release_version_id\" is null\n and \"v2_retention_jobs\".\"lease_token\" is null\n and \"v2_retention_jobs\".\"lease_expires_at\" is null\n and \"v2_retention_jobs\".\"completed_at\" is not null\n )\n )" - }, - "v2_retention_jobs_terminal_phase_check": { - "name": "v2_retention_jobs_terminal_phase_check", - "value": "\"v2_retention_jobs\".\"status\" <> 'complete' or \"v2_retention_jobs\".\"phase\" = 'cleanup'" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "latest_model_id": { - "name": "latest_model_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - }, - "v2_threads_latest_model_id_check": { - "name": "v2_threads_latest_model_id_check", - "value": "\"v2_threads\".\"latest_model_id\" is null or (\n char_length(\"v2_threads\".\"latest_model_id\") <= 200\n and \"v2_threads\".\"latest_model_id\"\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_jobs": { - "name": "v2_user_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_jobs_generation_uidx": { - "name": "v2_user_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_ready_idx": { - "name": "v2_user_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_lease_idx": { - "name": "v2_user_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_user_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_user_deletion_jobs_id_user_generation_key": { - "name": "v2_user_deletion_jobs_id_user_generation_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id", - "generation" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_jobs_phase_check": { - "name": "v2_user_deletion_jobs_phase_check", - "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" - }, - "v2_user_deletion_jobs_status_check": { - "name": "v2_user_deletion_jobs_status_check", - "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_user_deletion_jobs_counter_check": { - "name": "v2_user_deletion_jobs_counter_check", - "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_user_deletion_jobs_lease_check": { - "name": "v2_user_deletion_jobs_lease_check", - "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_refund_intents": { - "name": "v2_user_deletion_refund_intents", - "schema": "", - "columns": { - "job_id": { - "name": "job_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "order_id": { - "name": "order_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_refund_id": { - "name": "provider_refund_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_status": { - "name": "provider_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "reconciled_at": { - "name": "reconciled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_refund_intents_idempotency_uidx": { - "name": "v2_user_deletion_refund_intents_idempotency_uidx", - "columns": [ - { - "expression": "idempotency_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_provider_uidx": { - "name": "v2_user_deletion_refund_intents_provider_uidx", - "columns": [ - { - "expression": "provider_refund_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_unresolved_idx": { - "name": "v2_user_deletion_refund_intents_unresolved_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "job_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_refund_intents\".\"provider_status\" is distinct from 'succeeded'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_refund_intents_job_identity_fk": { - "name": "v2_user_deletion_refund_intents_job_identity_fk", - "tableFrom": "v2_user_deletion_refund_intents", - "tableTo": "v2_user_deletion_jobs", - "columnsFrom": [ - "job_id", - "user_id", - "generation" - ], - "columnsTo": [ - "id", - "user_id", - "generation" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_refund_intents_amount_check": { - "name": "v2_user_deletion_refund_intents_amount_check", - "value": "\"v2_user_deletion_refund_intents\".\"amount\" > 0" - }, - "v2_user_deletion_refund_intents_currency_check": { - "name": "v2_user_deletion_refund_intents_currency_check", - "value": "\"v2_user_deletion_refund_intents\".\"currency\" ~ '^[a-z]{3}$'" - }, - "v2_user_deletion_refund_intents_order_check": { - "name": "v2_user_deletion_refund_intents_order_check", - "value": "length(btrim(\"v2_user_deletion_refund_intents\".\"order_id\")) > 0" - }, - "v2_user_deletion_refund_intents_identity_check": { - "name": "v2_user_deletion_refund_intents_identity_check", - "value": "\"v2_user_deletion_refund_intents\".\"idempotency_key\" = 'cheatcode:user-deletion-refund:' || \"v2_user_deletion_refund_intents\".\"job_id\"::text" - }, - "v2_user_deletion_refund_intents_provider_check": { - "name": "v2_user_deletion_refund_intents_provider_check", - "value": "(\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is null and \"v2_user_deletion_refund_intents\".\"provider_status\" is null and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is null)\n or\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null and length(btrim(\"v2_user_deletion_refund_intents\".\"provider_refund_id\")) > 0 and \"v2_user_deletion_refund_intents\".\"provider_status\" is not null and \"v2_user_deletion_refund_intents\".\"provider_status\" in ('pending', 'succeeded', 'failed', 'canceled') and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is not null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "clerk_updated_at_ms": { - "name": "clerk_updated_at_ms", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_users_clerk_updated_at_ms_check": { - "name": "v2_users_clerk_updated_at_ms_check", - "value": "\"v2_users\".\"clerk_updated_at_ms\" between 0 and 9007199254740991" - } - }, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/packages/db/drizzle/meta/0048_snapshot.json b/packages/db/drizzle/meta/0048_snapshot.json deleted file mode 100644 index 984d449e..00000000 --- a/packages/db/drizzle/meta/0048_snapshot.json +++ /dev/null @@ -1,2783 +0,0 @@ -{ - "id": "fc4346d7-9233-43cf-bca9-d21578de8226", - "prevId": "bb6aeaa8-7c0d-444f-b992-08dd3c958668", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.v2_agent_runs": { - "name": "v2_agent_runs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "model_id": { - "name": "model_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key_hash": { - "name": "idempotency_key_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "request_body_hash": { - "name": "request_body_hash", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "finished_at": { - "name": "finished_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_agent_runs_user_idempotency_key_unique": { - "name": "v2_agent_runs_user_idempotency_key_unique", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "idempotency_key_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_started_idx": { - "name": "v2_agent_runs_user_started_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "started_at", - "isExpression": false, - "asc": false, - "nulls": "first" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_finished_idx": { - "name": "v2_agent_runs_user_finished_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "finished_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_agent_runs\".\"finished_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_user_delete_page_idx": { - "name": "v2_agent_runs_user_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_agent_runs_thread_delete_page_idx": { - "name": "v2_agent_runs_thread_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_agent_runs_user_id_v2_users_id_fk": { - "name": "v2_agent_runs_user_id_v2_users_id_fk", - "tableFrom": "v2_agent_runs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_agent_runs_id_user_id_key": { - "name": "v2_agent_runs_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_agent_runs_idempotency_key_hash_check": { - "name": "v2_agent_runs_idempotency_key_hash_check", - "value": "\"v2_agent_runs\".\"idempotency_key_hash\" is null or \"v2_agent_runs\".\"idempotency_key_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_request_body_hash_check": { - "name": "v2_agent_runs_request_body_hash_check", - "value": "\"v2_agent_runs\".\"request_body_hash\" is null or \"v2_agent_runs\".\"request_body_hash\" ~ '^[0-9a-f]{64}$'" - }, - "v2_agent_runs_model_id_canonical_check": { - "name": "v2_agent_runs_model_id_canonical_check", - "value": "char_length(\"v2_agent_runs\".\"model_id\") <= 200 and \"v2_agent_runs\".\"model_id\" ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'" - }, - "v2_agent_runs_status_check": { - "name": "v2_agent_runs_status_check", - "value": "\"v2_agent_runs\".\"status\" in ('pending', 'running', 'completed', 'failed', 'canceled')" - }, - "v2_agent_runs_finished_order_check": { - "name": "v2_agent_runs_finished_order_check", - "value": "\"v2_agent_runs\".\"finished_at\" is null or \"v2_agent_runs\".\"finished_at\" >= \"v2_agent_runs\".\"started_at\"" - }, - "v2_agent_runs_terminal_timestamp_check": { - "name": "v2_agent_runs_terminal_timestamp_check", - "value": "(\"v2_agent_runs\".\"status\" in ('completed', 'failed', 'canceled')) = (\"v2_agent_runs\".\"finished_at\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_artifact_upload_intents": { - "name": "v2_artifact_upload_intents", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "cleanup_not_before": { - "name": "cleanup_not_before", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "quiesced_at": { - "name": "quiesced_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_artifact_upload_intents_cleanup_idx": { - "name": "v2_artifact_upload_intents_cleanup_idx", - "columns": [ - { - "expression": "cleanup_not_before", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "quiesced_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_artifact_upload_intents\".\"quiesced_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_user_idx": { - "name": "v2_artifact_upload_intents_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_project_idx": { - "name": "v2_artifact_upload_intents_project_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_artifact_upload_intents_run_idx": { - "name": "v2_artifact_upload_intents_run_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_artifact_upload_intents_project_user_fk": { - "name": "v2_artifact_upload_intents_project_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_projects", - "columnsFrom": [ - "project_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - }, - "v2_artifact_upload_intents_agent_run_user_fk": { - "name": "v2_artifact_upload_intents_agent_run_user_fk", - "tableFrom": "v2_artifact_upload_intents", - "tableTo": "v2_agent_runs", - "columnsFrom": [ - "agent_run_id", - "user_id" - ], - "columnsTo": [ - "id", - "user_id" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_artifact_upload_intents_r2_key_unique": { - "name": "v2_artifact_upload_intents_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_artifact_upload_intents_r2_identity_check": { - "name": "v2_artifact_upload_intents_r2_identity_check", - "value": "\"v2_artifact_upload_intents\".\"r2_key\" like \"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-%'\n and strpos(substr(\"v2_artifact_upload_intents\".\"r2_key\", length(\"v2_artifact_upload_intents\".\"user_id\"::text || '/' || \"v2_artifact_upload_intents\".\"project_id\"::text || '/' || \"v2_artifact_upload_intents\".\"agent_run_id\"::text || '/' || \"v2_artifact_upload_intents\".\"id\"::text || '-') + 1), '/') = 0\n and octet_length(\"v2_artifact_upload_intents\".\"r2_key\") <= 512" - } - }, - "isRLSEnabled": false - }, - "public.v2_daily_maintenance_jobs": { - "name": "v2_daily_maintenance_jobs", - "schema": "", - "columns": { - "day": { - "name": "day", - "type": "date", - "primaryKey": true, - "notNull": true - }, - "scheduled_at": { - "name": "scheduled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'activation'" - }, - "activation_cursor_event": { - "name": "activation_cursor_event", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "activation_cursor_user_id": { - "name": "activation_cursor_user_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "release_version_id": { - "name": "release_version_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_daily_maintenance_jobs_ready_idx": { - "name": "v2_daily_maintenance_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_daily_maintenance_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_daily_maintenance_jobs_lease_idx": { - "name": "v2_daily_maintenance_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_daily_maintenance_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_daily_maintenance_jobs_completed_idx": { - "name": "v2_daily_maintenance_jobs_completed_idx", - "columns": [ - { - "expression": "completed_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "day", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_daily_maintenance_jobs\".\"status\" = 'complete'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_daily_maintenance_jobs_day_check": { - "name": "v2_daily_maintenance_jobs_day_check", - "value": "\"v2_daily_maintenance_jobs\".\"day\" = ((\"v2_daily_maintenance_jobs\".\"scheduled_at\" at time zone 'UTC')::date - 1)" - }, - "v2_daily_maintenance_jobs_phase_check": { - "name": "v2_daily_maintenance_jobs_phase_check", - "value": "\"v2_daily_maintenance_jobs\".\"phase\" in ('activation', 'orphan-upload-cleanup')" - }, - "v2_daily_maintenance_jobs_status_check": { - "name": "v2_daily_maintenance_jobs_status_check", - "value": "\"v2_daily_maintenance_jobs\".\"status\" in ('queued', 'leased', 'complete')" - }, - "v2_daily_maintenance_jobs_counter_check": { - "name": "v2_daily_maintenance_jobs_counter_check", - "value": "\"v2_daily_maintenance_jobs\".\"continuation\" >= 0 and \"v2_daily_maintenance_jobs\".\"failure_count\" >= 0" - }, - "v2_daily_maintenance_jobs_error_code_check": { - "name": "v2_daily_maintenance_jobs_error_code_check", - "value": "\"v2_daily_maintenance_jobs\".\"last_error_code\" is null or octet_length(\"v2_daily_maintenance_jobs\".\"last_error_code\") <= 128" - }, - "v2_daily_maintenance_jobs_activation_cursor_check": { - "name": "v2_daily_maintenance_jobs_activation_cursor_check", - "value": "(\n (\"v2_daily_maintenance_jobs\".\"activation_cursor_event\" is null and \"v2_daily_maintenance_jobs\".\"activation_cursor_user_id\" is null)\n or\n (\n \"v2_daily_maintenance_jobs\".\"phase\" = 'activation'\n and \"v2_daily_maintenance_jobs\".\"activation_cursor_event\" in ('retention_d7', 'retention_d28', 'first_week_mau')\n and \"v2_daily_maintenance_jobs\".\"activation_cursor_user_id\" is not null\n )\n )" - }, - "v2_daily_maintenance_jobs_phase_cursor_check": { - "name": "v2_daily_maintenance_jobs_phase_cursor_check", - "value": "(\n (\"v2_daily_maintenance_jobs\".\"phase\" = 'activation')\n or\n (\"v2_daily_maintenance_jobs\".\"phase\" = 'orphan-upload-cleanup' and \"v2_daily_maintenance_jobs\".\"activation_cursor_event\" is null and \"v2_daily_maintenance_jobs\".\"activation_cursor_user_id\" is null)\n )" - }, - "v2_daily_maintenance_jobs_lease_check": { - "name": "v2_daily_maintenance_jobs_lease_check", - "value": "(\n (\n \"v2_daily_maintenance_jobs\".\"status\" = 'leased'\n and \"v2_daily_maintenance_jobs\".\"release_version_id\" is not null\n and \"v2_daily_maintenance_jobs\".\"lease_token\" is not null\n and \"v2_daily_maintenance_jobs\".\"lease_expires_at\" is not null\n and \"v2_daily_maintenance_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_daily_maintenance_jobs\".\"status\" = 'queued'\n and \"v2_daily_maintenance_jobs\".\"release_version_id\" is null\n and \"v2_daily_maintenance_jobs\".\"lease_token\" is null\n and \"v2_daily_maintenance_jobs\".\"lease_expires_at\" is null\n and \"v2_daily_maintenance_jobs\".\"completed_at\" is null\n )\n or\n (\n \"v2_daily_maintenance_jobs\".\"status\" = 'complete'\n and \"v2_daily_maintenance_jobs\".\"release_version_id\" is null\n and \"v2_daily_maintenance_jobs\".\"lease_token\" is null\n and \"v2_daily_maintenance_jobs\".\"lease_expires_at\" is null\n and \"v2_daily_maintenance_jobs\".\"completed_at\" is not null\n )\n )" - }, - "v2_daily_maintenance_jobs_terminal_phase_check": { - "name": "v2_daily_maintenance_jobs_terminal_phase_check", - "value": "\"v2_daily_maintenance_jobs\".\"status\" <> 'complete' or \"v2_daily_maintenance_jobs\".\"phase\" = 'orphan-upload-cleanup'" - } - }, - "isRLSEnabled": false - }, - "public.v2_deleted_clerk_identities": { - "name": "v2_deleted_clerk_identities", - "schema": "", - "columns": { - "clerk_identity_hash": { - "name": "clerk_identity_hash", - "type": "text", - "primaryKey": true, - "notNull": true - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_deleted_clerk_identities_hash_check": { - "name": "v2_deleted_clerk_identities_hash_check", - "value": "\"v2_deleted_clerk_identities\".\"clerk_identity_hash\" ~ '^[0-9a-f]{64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_entitlements": { - "name": "v2_entitlements", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "tier": { - "name": "tier", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'free'" - }, - "polar_subscription_id": { - "name": "polar_subscription_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "subscription_status": { - "name": "subscription_status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "cancel_at_period_end": { - "name": "cancel_at_period_end", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "current_period_start": { - "name": "current_period_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "current_period_end": { - "name": "current_period_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_entitlements_polar_subscription_uidx": { - "name": "v2_entitlements_polar_subscription_uidx", - "columns": [ - { - "expression": "polar_subscription_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_entitlements\".\"polar_subscription_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_entitlements_user_id_v2_users_id_fk": { - "name": "v2_entitlements_user_id_v2_users_id_fk", - "tableFrom": "v2_entitlements", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_entitlements_tier_check": { - "name": "v2_entitlements_tier_check", - "value": "\"v2_entitlements\".\"tier\" in ('free','pro','premium','ultra','max')" - }, - "v2_entitlements_period_order_check": { - "name": "v2_entitlements_period_order_check", - "value": "\"v2_entitlements\".\"current_period_start\" is null or \"v2_entitlements\".\"current_period_end\" is null or \"v2_entitlements\".\"current_period_start\" <= \"v2_entitlements\".\"current_period_end\"" - } - }, - "isRLSEnabled": false - }, - "public.v2_generated_outputs": { - "name": "v2_generated_outputs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "filename": { - "name": "filename", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "r2_key": { - "name": "r2_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mime_type": { - "name": "mime_type", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_generated_outputs_agent_run_idx": { - "name": "v2_generated_outputs_agent_run_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_generated_outputs_user_id_v2_users_id_fk": { - "name": "v2_generated_outputs_user_id_v2_users_id_fk", - "tableFrom": "v2_generated_outputs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_generated_outputs_r2_key_unique": { - "name": "v2_generated_outputs_r2_key_unique", - "nullsNotDistinct": false, - "columns": [ - "r2_key" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_generated_outputs_r2_identity_check": { - "name": "v2_generated_outputs_r2_identity_check", - "value": "\"v2_generated_outputs\".\"r2_key\" = \"v2_generated_outputs\".\"user_id\"::text || '/' || split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) || '/' || \"v2_generated_outputs\".\"agent_run_id\"::text || '/' || \"v2_generated_outputs\".\"id\"::text || '-' || \"v2_generated_outputs\".\"filename\"\n and split_part(\"v2_generated_outputs\".\"r2_key\", '/', 2) ~ '^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'\n and strpos(\"v2_generated_outputs\".\"filename\", '/') = 0" - } - }, - "isRLSEnabled": false - }, - "public.v2_messages": { - "name": "v2_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "thread_id": { - "name": "thread_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 - }, - "parts": { - "name": "parts", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "agent_run_id": { - "name": "agent_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "agent_run_segment": { - "name": "agent_run_segment", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "agent_run_segment_final": { - "name": "agent_run_segment_final", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_messages_thread_page_idx": { - "name": "v2_messages_thread_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_scope_idx": { - "name": "v2_messages_agent_run_scope_idx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "thread_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_segment_assistant_uidx": { - "name": "v2_messages_agent_run_segment_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "agent_run_segment", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_messages_agent_run_final_assistant_uidx": { - "name": "v2_messages_agent_run_final_assistant_uidx", - "columns": [ - { - "expression": "agent_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_messages\".\"agent_run_id\" is not null and \"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_segment_final\"", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_messages_user_id_v2_users_id_fk": { - "name": "v2_messages_user_id_v2_users_id_fk", - "tableFrom": "v2_messages", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_messages_agent_run_segment_check": { - "name": "v2_messages_agent_run_segment_check", - "value": "\"v2_messages\".\"agent_run_segment\" >= 0" - }, - "v2_messages_role_check": { - "name": "v2_messages_role_check", - "value": "\"v2_messages\".\"role\" in ('assistant', 'user')" - }, - "v2_messages_agent_run_segment_scope_check": { - "name": "v2_messages_agent_run_segment_scope_check", - "value": "(\"v2_messages\".\"agent_run_segment\" = 0 and \"v2_messages\".\"agent_run_segment_final\") or (\"v2_messages\".\"role\" = 'assistant' and \"v2_messages\".\"agent_run_id\" is not null)" - }, - "v2_messages_parts_array_check": { - "name": "v2_messages_parts_array_check", - "value": "jsonb_typeof(\"v2_messages\".\"parts\") = 'array'" - }, - "v2_messages_parts_size_check": { - "name": "v2_messages_parts_size_check", - "value": "octet_length(\"v2_messages\".\"parts\"::text) <= 196608" - } - }, - "isRLSEnabled": false - }, - "public.v2_projects": { - "name": "v2_projects", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "mode": { - "name": "mode", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "workspace_slug": { - "name": "workspace_slug", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "settings": { - "name": "settings", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "over_quota": { - "name": "over_quota", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "archive_after": { - "name": "archive_after", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_projects_user_page_idx": { - "name": "v2_projects_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_user_delete_idx": { - "name": "v2_projects_user_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_projects_deletion_queue_idx": { - "name": "v2_projects_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_projects_user_id_v2_users_id_fk": { - "name": "v2_projects_user_id_v2_users_id_fk", - "tableFrom": "v2_projects", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_projects_id_user_id_key": { - "name": "v2_projects_id_user_id_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_projects_mode_check": { - "name": "v2_projects_mode_check", - "value": "\"v2_projects\".\"mode\" in ('app-builder', 'app-builder-mobile', 'general')" - }, - "v2_projects_workspace_slug_canonical_check": { - "name": "v2_projects_workspace_slug_canonical_check", - "value": "octet_length(\"v2_projects\".\"workspace_slug\") between 38 and 64\n and right(\"v2_projects\".\"workspace_slug\", 37) = '-' || \"v2_projects\".\"id\"::text\n and left(\"v2_projects\".\"workspace_slug\", length(\"v2_projects\".\"workspace_slug\") - 37)\n ~ '^[a-z0-9]+(-[a-z0-9]+)*$'" - }, - "v2_projects_quota_archive_pair_check": { - "name": "v2_projects_quota_archive_pair_check", - "value": "\"v2_projects\".\"over_quota\" = (\"v2_projects\".\"archive_after\" is not null)" - }, - "v2_projects_settings_object_check": { - "name": "v2_projects_settings_object_check", - "value": "jsonb_typeof(\"v2_projects\".\"settings\") = 'object'" - }, - "v2_projects_settings_default_model_check": { - "name": "v2_projects_settings_default_model_check", - "value": "not (\"v2_projects\".\"settings\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_projects\".\"settings\" -> 'defaultModel') = 'string'\n and char_length(\"v2_projects\".\"settings\" ->> 'defaultModel') <= 200\n and \"v2_projects\".\"settings\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_provider_keys": { - "name": "v2_provider_keys", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "vault_secret_id": { - "name": "vault_secret_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "fingerprint": { - "name": "fingerprint", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "last_revalidated_at": { - "name": "last_revalidated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_claimed_at": { - "name": "revalidation_claimed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "revalidation_lease_token": { - "name": "revalidation_lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "disabled_at": { - "name": "disabled_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "disabled_reason": { - "name": "disabled_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "v2_provider_keys_revalidation_lease_idx": { - "name": "v2_provider_keys_revalidation_lease_idx", - "columns": [ - { - "expression": "last_revalidated_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "revalidation_claimed_at", - "isExpression": false, - "asc": true, - "nulls": "first" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_provider_keys\".\"disabled_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_provider_keys_vault_secret_uidx": { - "name": "v2_provider_keys_vault_secret_uidx", - "columns": [ - { - "expression": "vault_secret_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_provider_keys_user_id_v2_users_id_fk": { - "name": "v2_provider_keys_user_id_v2_users_id_fk", - "tableFrom": "v2_provider_keys", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "v2_provider_keys_user_id_provider_pk": { - "name": "v2_provider_keys_user_id_provider_pk", - "columns": [ - "user_id", - "provider" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_provider_keys_fingerprint_check": { - "name": "v2_provider_keys_fingerprint_check", - "value": "\"v2_provider_keys\".\"fingerprint\" ~ '^[0-9a-f]{12}$'" - }, - "v2_provider_keys_disabled_pair_check": { - "name": "v2_provider_keys_disabled_pair_check", - "value": "(\"v2_provider_keys\".\"disabled_at\" is null and \"v2_provider_keys\".\"disabled_reason\" is null) or (\"v2_provider_keys\".\"disabled_at\" is not null and \"v2_provider_keys\".\"disabled_reason\" is not null)" - }, - "v2_provider_keys_revalidation_lease_pair_check": { - "name": "v2_provider_keys_revalidation_lease_pair_check", - "value": "(\"v2_provider_keys\".\"revalidation_claimed_at\" is null and \"v2_provider_keys\".\"revalidation_lease_token\" is null) or (\"v2_provider_keys\".\"revalidation_claimed_at\" is not null and \"v2_provider_keys\".\"revalidation_lease_token\" is not null)" - } - }, - "isRLSEnabled": false - }, - "public.v2_resource_deletion_jobs": { - "name": "v2_resource_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "kind": { - "name": "kind", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "resource_id": { - "name": "resource_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_resource_deletion_jobs_generation_uidx": { - "name": "v2_resource_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "kind", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "resource_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_user_idx": { - "name": "v2_resource_deletion_jobs_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_ready_idx": { - "name": "v2_resource_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_resource_deletion_jobs_lease_idx": { - "name": "v2_resource_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "status = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_resource_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_resource_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_resource_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_resource_deletion_jobs_kind_check": { - "name": "v2_resource_deletion_jobs_kind_check", - "value": "\"v2_resource_deletion_jobs\".\"kind\" in ('project-deletion', 'thread-deletion')" - }, - "v2_resource_deletion_jobs_phase_check": { - "name": "v2_resource_deletion_jobs_phase_check", - "value": "\"v2_resource_deletion_jobs\".\"phase\" in ('runs', 'run-objects', 'workspace', 'outputs', 'prefix', 'pointer', 'finalize')" - }, - "v2_resource_deletion_jobs_status_check": { - "name": "v2_resource_deletion_jobs_status_check", - "value": "\"v2_resource_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_resource_deletion_jobs_counter_check": { - "name": "v2_resource_deletion_jobs_counter_check", - "value": "\"v2_resource_deletion_jobs\".\"continuation\" >= 0 and \"v2_resource_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_resource_deletion_jobs_lease_check": { - "name": "v2_resource_deletion_jobs_lease_check", - "value": "(\n (\"v2_resource_deletion_jobs\".\"status\" = 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is not null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_resource_deletion_jobs\".\"status\" <> 'leased' and \"v2_resource_deletion_jobs\".\"lease_token\" is null and \"v2_resource_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_threads": { - "name": "v2_threads", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "project_id": { - "name": "project_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "launch_intent": { - "name": "launch_intent", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "active_run_id": { - "name": "active_run_id", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "latest_model_id": { - "name": "latest_model_id", - "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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_threads_user_page_idx": { - "name": "v2_threads_user_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_page_idx": { - "name": "v2_threads_project_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "updated_at", - "isExpression": false, - "asc": false, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_project_delete_idx": { - "name": "v2_threads_project_delete_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "project_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_active_run_idx": { - "name": "v2_threads_active_run_idx", - "columns": [ - { - "expression": "active_run_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_threads\".\"active_run_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_threads_deletion_queue_idx": { - "name": "v2_threads_deletion_queue_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "deleted_at is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_threads_user_id_v2_users_id_fk": { - "name": "v2_threads_user_id_v2_users_id_fk", - "tableFrom": "v2_threads", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_threads_project_launch_intent_check": { - "name": "v2_threads_project_launch_intent_check", - "value": "\"v2_threads\".\"project_id\" is null or \"v2_threads\".\"launch_intent\" is null" - }, - "v2_threads_launch_intent_object_check": { - "name": "v2_threads_launch_intent_object_check", - "value": "\"v2_threads\".\"launch_intent\" is null or jsonb_typeof(\"v2_threads\".\"launch_intent\") = 'object'" - }, - "v2_threads_launch_default_model_check": { - "name": "v2_threads_launch_default_model_check", - "value": "\"v2_threads\".\"launch_intent\" is null or not (\"v2_threads\".\"launch_intent\" ? 'defaultModel') or (\n jsonb_typeof(\"v2_threads\".\"launch_intent\" -> 'defaultModel') = 'string'\n and char_length(\"v2_threads\".\"launch_intent\" ->> 'defaultModel') <= 200\n and \"v2_threads\".\"launch_intent\" ->> 'defaultModel'\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - }, - "v2_threads_latest_model_id_check": { - "name": "v2_threads_latest_model_id_check", - "value": "\"v2_threads\".\"latest_model_id\" is null or (\n char_length(\"v2_threads\".\"latest_model_id\") <= 200\n and \"v2_threads\".\"latest_model_id\"\n ~ '^(anthropic|deepseek|google|openai|openrouter)/[^[:space:]]+$'\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_jobs": { - "name": "v2_user_deletion_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'runs'" - }, - "cursor": { - "name": "cursor", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "continuation": { - "name": "continuation", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "lease_token": { - "name": "lease_token", - "type": "uuid", - "primaryKey": false, - "notNull": false - }, - "lease_expires_at": { - "name": "lease_expires_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - }, - "failure_count": { - "name": "failure_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "next_attempt_at": { - "name": "next_attempt_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "last_error_code": { - "name": "last_error_code", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_jobs_generation_uidx": { - "name": "v2_user_deletion_jobs_generation_uidx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "generation", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_ready_idx": { - "name": "v2_user_deletion_jobs_ready_idx", - "columns": [ - { - "expression": "next_attempt_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'queued'", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_jobs_lease_idx": { - "name": "v2_user_deletion_jobs_lease_idx", - "columns": [ - { - "expression": "lease_expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_jobs\".\"status\" = 'leased'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_jobs_user_id_v2_users_id_fk": { - "name": "v2_user_deletion_jobs_user_id_v2_users_id_fk", - "tableFrom": "v2_user_deletion_jobs", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_user_deletion_jobs_id_user_generation_key": { - "name": "v2_user_deletion_jobs_id_user_generation_key", - "nullsNotDistinct": false, - "columns": [ - "id", - "user_id", - "generation" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_jobs_phase_check": { - "name": "v2_user_deletion_jobs_phase_check", - "value": "\"v2_user_deletion_jobs\".\"phase\" in ('runs', 'sandbox', 'billing', 'quota', 'integrations', 'objects', 'archive', 'finalize')" - }, - "v2_user_deletion_jobs_status_check": { - "name": "v2_user_deletion_jobs_status_check", - "value": "\"v2_user_deletion_jobs\".\"status\" in ('queued', 'leased', 'quarantined')" - }, - "v2_user_deletion_jobs_counter_check": { - "name": "v2_user_deletion_jobs_counter_check", - "value": "\"v2_user_deletion_jobs\".\"continuation\" >= 0 and \"v2_user_deletion_jobs\".\"failure_count\" >= 0" - }, - "v2_user_deletion_jobs_lease_check": { - "name": "v2_user_deletion_jobs_lease_check", - "value": "(\n (\"v2_user_deletion_jobs\".\"status\" = 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is not null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is not null)\n or\n (\"v2_user_deletion_jobs\".\"status\" <> 'leased' and \"v2_user_deletion_jobs\".\"lease_token\" is null and \"v2_user_deletion_jobs\".\"lease_expires_at\" is null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_deletion_refund_intents": { - "name": "v2_user_deletion_refund_intents", - "schema": "", - "columns": { - "job_id": { - "name": "job_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "generation": { - "name": "generation", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "order_id": { - "name": "order_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "amount": { - "name": "amount", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "currency": { - "name": "currency", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "idempotency_key": { - "name": "idempotency_key", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "provider_refund_id": { - "name": "provider_refund_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "provider_status": { - "name": "provider_status", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - }, - "reconciled_at": { - "name": "reconciled_at", - "type": "timestamp (3) with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_user_deletion_refund_intents_idempotency_uidx": { - "name": "v2_user_deletion_refund_intents_idempotency_uidx", - "columns": [ - { - "expression": "idempotency_key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_provider_uidx": { - "name": "v2_user_deletion_refund_intents_provider_uidx", - "columns": [ - { - "expression": "provider_refund_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_deletion_refund_intents_unresolved_idx": { - "name": "v2_user_deletion_refund_intents_unresolved_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "job_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_user_deletion_refund_intents\".\"provider_status\" is distinct from 'succeeded'", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_deletion_refund_intents_job_identity_fk": { - "name": "v2_user_deletion_refund_intents_job_identity_fk", - "tableFrom": "v2_user_deletion_refund_intents", - "tableTo": "v2_user_deletion_jobs", - "columnsFrom": [ - "job_id", - "user_id", - "generation" - ], - "columnsTo": [ - "id", - "user_id", - "generation" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_deletion_refund_intents_amount_check": { - "name": "v2_user_deletion_refund_intents_amount_check", - "value": "\"v2_user_deletion_refund_intents\".\"amount\" > 0" - }, - "v2_user_deletion_refund_intents_currency_check": { - "name": "v2_user_deletion_refund_intents_currency_check", - "value": "\"v2_user_deletion_refund_intents\".\"currency\" ~ '^[a-z]{3}$'" - }, - "v2_user_deletion_refund_intents_order_check": { - "name": "v2_user_deletion_refund_intents_order_check", - "value": "length(btrim(\"v2_user_deletion_refund_intents\".\"order_id\")) > 0" - }, - "v2_user_deletion_refund_intents_identity_check": { - "name": "v2_user_deletion_refund_intents_identity_check", - "value": "\"v2_user_deletion_refund_intents\".\"idempotency_key\" = 'cheatcode:user-deletion-refund:' || \"v2_user_deletion_refund_intents\".\"job_id\"::text" - }, - "v2_user_deletion_refund_intents_provider_check": { - "name": "v2_user_deletion_refund_intents_provider_check", - "value": "(\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is null and \"v2_user_deletion_refund_intents\".\"provider_status\" is null and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is null)\n or\n (\"v2_user_deletion_refund_intents\".\"provider_refund_id\" is not null and length(btrim(\"v2_user_deletion_refund_intents\".\"provider_refund_id\")) > 0 and \"v2_user_deletion_refund_intents\".\"provider_status\" is not null and \"v2_user_deletion_refund_intents\".\"provider_status\" in ('pending', 'succeeded', 'failed', 'canceled') and \"v2_user_deletion_refund_intents\".\"reconciled_at\" is not null)\n )" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_integrations": { - "name": "v2_user_integrations", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "integration": { - "name": "integration", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "composio_connection_id": { - "name": "composio_connection_id", - "type": "text", - "primaryKey": true, - "notNull": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "status": { - "name": "status", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "connected_at": { - "name": "connected_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": { - "v2_user_integrations_one_default_idx": { - "name": "v2_user_integrations_one_default_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "where": "\"v2_user_integrations\".\"is_default\" = true", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_delete_page_idx": { - "name": "v2_user_integrations_delete_page_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "composio_connection_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_user_integrations_user_toolkit_idx": { - "name": "v2_user_integrations_user_toolkit_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "integration", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "v2_user_integrations_user_id_v2_users_id_fk": { - "name": "v2_user_integrations_user_id_v2_users_id_fk", - "tableFrom": "v2_user_integrations", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_integrations_connection_id_check": { - "name": "v2_user_integrations_connection_id_check", - "value": "\"v2_user_integrations\".\"composio_connection_id\" = btrim(\"v2_user_integrations\".\"composio_connection_id\") and length(\"v2_user_integrations\".\"composio_connection_id\") between 1 and 256" - }, - "v2_user_integrations_default_active_check": { - "name": "v2_user_integrations_default_active_check", - "value": "not \"v2_user_integrations\".\"is_default\" or lower(\"v2_user_integrations\".\"status\") in ('active', 'authorized', 'connected', 'enabled')" - }, - "v2_user_integrations_integration_check": { - "name": "v2_user_integrations_integration_check", - "value": "\"v2_user_integrations\".\"integration\" ~ '^[a-z0-9_]{1,64}$'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_profiles": { - "name": "v2_user_profiles", - "schema": "", - "columns": { - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": true, - "notNull": true - }, - "agent_display_name": { - "name": "agent_display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "global_memory": { - "name": "global_memory", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "disabled_models": { - "name": "disabled_models", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "onboarding_completed_at": { - "name": "onboarding_completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "onboarding_state": { - "name": "onboarding_state", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": { - "v2_user_profiles_user_id_v2_users_id_fk": { - "name": "v2_user_profiles_user_id_v2_users_id_fk", - "tableFrom": "v2_user_profiles", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_profiles_disabled_models_array_check": { - "name": "v2_user_profiles_disabled_models_array_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"disabled_models\") = 'array'" - }, - "v2_user_profiles_onboarding_state_object_check": { - "name": "v2_user_profiles_onboarding_state_object_check", - "value": "jsonb_typeof(\"v2_user_profiles\".\"onboarding_state\") = 'object'" - } - }, - "isRLSEnabled": false - }, - "public.v2_user_skills": { - "name": "v2_user_skills", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "user_id": { - "name": "user_id", - "type": "uuid", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tags": { - "name": "tags", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'[]'::jsonb" - }, - "body": { - "name": "body", - "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": { - "v2_user_skills_user_name_idx": { - "name": "v2_user_skills_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": {} - } - }, - "foreignKeys": { - "v2_user_skills_user_id_v2_users_id_fk": { - "name": "v2_user_skills_user_id_v2_users_id_fk", - "tableFrom": "v2_user_skills", - "tableTo": "v2_users", - "columnsFrom": [ - "user_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": { - "v2_user_skills_tags_array_check": { - "name": "v2_user_skills_tags_array_check", - "value": "jsonb_typeof(\"v2_user_skills\".\"tags\") = 'array'" - } - }, - "isRLSEnabled": false - }, - "public.v2_users": { - "name": "v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "uuid", - "primaryKey": true, - "notNull": true, - "default": "public.uuidv7()" - }, - "clerk_id": { - "name": "clerk_id", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "clerk_updated_at_ms": { - "name": "clerk_updated_at_ms", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "display_name": { - "name": "display_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "avatar_url": { - "name": "avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "polar_customer_id": { - "name": "polar_customer_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "first_artifact_at": { - "name": "first_artifact_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()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "deletion_fence": { - "name": "deletion_fence", - "type": "text", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "v2_users_activation_created_idx": { - "name": "v2_users_activation_created_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is null", - "concurrently": false, - "method": "btree", - "with": {} - }, - "v2_users_deletion_due_idx": { - "name": "v2_users_deletion_due_idx", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"v2_users\".\"deleted_at\" is not null", - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "v2_users_clerk_id_unique": { - "name": "v2_users_clerk_id_unique", - "nullsNotDistinct": false, - "columns": [ - "clerk_id" - ] - }, - "v2_users_polar_customer_id_unique": { - "name": "v2_users_polar_customer_id_unique", - "nullsNotDistinct": false, - "columns": [ - "polar_customer_id" - ] - } - }, - "policies": {}, - "checkConstraints": { - "v2_users_clerk_updated_at_ms_check": { - "name": "v2_users_clerk_updated_at_ms_check", - "value": "\"v2_users\".\"clerk_updated_at_ms\" between 0 and 9007199254740991" - } - }, - "isRLSEnabled": false - } - }, - "enums": {}, - "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 ac9e1cf1..f70a23cf 100644 --- a/packages/db/drizzle/meta/_journal.json +++ b/packages/db/drizzle/meta/_journal.json @@ -5,344 +5,8 @@ { "idx": 0, "version": "7", - "when": 1779774787703, - "tag": "0000_yielding_wallflower", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1779937896645, - "tag": "0001_lonely_captain_universe", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1781349062819, - "tag": "0002_amazing_puck", - "breakpoints": true - }, - { - "idx": 3, - "version": "7", - "when": 1781353364655, - "tag": "0003_v2_billing_tier_premium_ultra_max", - "breakpoints": true - }, - { - "idx": 4, - "version": "7", - "when": 1782027070753, - "tag": "0004_amused_steve_rogers", - "breakpoints": true - }, - { - "idx": 5, - "version": "7", - "when": 1782718822595, - "tag": "0005_absent_sir_ram", - "breakpoints": true - }, - { - "idx": 6, - "version": "7", - "when": 1782728652925, - "tag": "0006_dashing_magneto", - "breakpoints": true - }, - { - "idx": 7, - "version": "7", - "when": 1782736991161, - "tag": "0007_ambiguous_thunderball", - "breakpoints": true - }, - { - "idx": 8, - "version": "7", - "when": 1782759325849, - "tag": "0008_fixed_maggott", - "breakpoints": true - }, - { - "idx": 9, - "version": "7", - "when": 1782824355026, - "tag": "0009_vengeful_mother_askani", - "breakpoints": true - }, - { - "idx": 10, - "version": "7", - "when": 1783406964249, - "tag": "0010_drop_obsolete_share_table", - "breakpoints": true - }, - { - "idx": 11, - "version": "7", - "when": 1783602597389, - "tag": "0011_per_user_sandbox_workspace_slug", - "breakpoints": true - }, - { - "idx": 12, - "version": "7", - "when": 1783676983716, - "tag": "0012_marvelous_vertigo", - "breakpoints": true - }, - { - "idx": 13, - "version": "7", - "when": 1783687424075, - "tag": "0013_special_lorna_dane", - "breakpoints": true - }, - { - "idx": 14, - "version": "7", - "when": 1783805723966, - "tag": "0014_strange_jackal", - "breakpoints": true - }, - { - "idx": 15, - "version": "7", - "when": 1783859198141, - "tag": "0015_dazzling_captain_marvel", - "breakpoints": true - }, - { - "idx": 16, - "version": "7", - "when": 1783879975579, - "tag": "0016_early_cargill", - "breakpoints": true - }, - { - "idx": 17, - "version": "7", - "when": 1784015993000, - "tag": "0017_normalize_per_user_sandbox_limit", - "breakpoints": true - }, - { - "idx": 18, - "version": "7", - "when": 1784056440247, - "tag": "0018_remove_token_cost_accounting", - "breakpoints": true - }, - { - "idx": 19, - "version": "7", - "when": 1784070336185, - "tag": "0019_composio_connection_identity", - "breakpoints": true - }, - { - "idx": 20, - "version": "7", - "when": 1784078256336, - "tag": "0020_user_deletion_fence", - "breakpoints": true - }, - { - "idx": 21, - "version": "7", - "when": 1784079139230, - "tag": "0021_clerk_deletion_tombstone", - "breakpoints": true - }, - { - "idx": 22, - "version": "7", - "when": 1784080055843, - "tag": "0022_agent_run_idempotency", - "breakpoints": true - }, - { - "idx": 23, - "version": "7", - "when": 1784080839435, - "tag": "0023_project_cleanup_and_keyset_indexes", - "breakpoints": true - }, - { - "idx": 24, - "version": "7", - "when": 1784081560567, - "tag": "0024_deletion_pages_and_assistant_message_identity", - "breakpoints": true - }, - { - "idx": 25, - "version": "7", - "when": 1784085786318, - "tag": "0025_generated_output_expiry_index", - "breakpoints": true - }, - { - "idx": 26, - "version": "7", - "when": 1784086126687, - "tag": "0026_first_artifact_milestone", - "breakpoints": true - }, - { - "idx": 27, - "version": "7", - "when": 1784086945441, - "tag": "0027_remove_project_backup_scaffolding", - "breakpoints": true - }, - { - "idx": 28, - "version": "7", - "when": 1784097779051, - "tag": "0028_finalize_generated_output_nullability", - "breakpoints": true - }, - { - "idx": 29, - "version": "7", - "when": 1784097934178, - "tag": "0029_finalize_scoped_foreign_keys", - "breakpoints": true - }, - { - "idx": 30, - "version": "7", - "when": 1784103556755, - "tag": "0030_yielding_mindworm", - "breakpoints": true - }, - { - "idx": 31, - "version": "7", - "when": 1784103714534, - "tag": "0031_complete_raider", - "breakpoints": true - }, - { - "idx": 32, - "version": "7", - "when": 1784106057194, - "tag": "0032_finalize_agent_run_model_attribution", - "breakpoints": true - }, - { - "idx": 33, - "version": "7", - "when": 1784127355621, - "tag": "0033_overrated_nova", - "breakpoints": true - }, - { - "idx": 34, - "version": "7", - "when": 1784146648031, - "tag": "0034_broken_nighthawk", - "breakpoints": true - }, - { - "idx": 35, - "version": "7", - "when": 1784149223925, - "tag": "0035_complete_purifiers", - "breakpoints": true - }, - { - "idx": 36, - "version": "7", - "when": 1784149662022, - "tag": "0036_goofy_morph", - "breakpoints": true - }, - { - "idx": 37, - "version": "7", - "when": 1784150275220, - "tag": "0037_glossy_chameleon", - "breakpoints": true - }, - { - "idx": 38, - "version": "7", - "when": 1784157745697, - "tag": "0038_pretty_nocturne", - "breakpoints": true - }, - { - "idx": 39, - "version": "7", - "when": 1784161727603, - "tag": "0039_lucky_the_watchers", - "breakpoints": true - }, - { - "idx": 40, - "version": "7", - "when": 1784165900028, - "tag": "0040_tiresome_jack_murdock", - "breakpoints": true - }, - { - "idx": 41, - "version": "7", - "when": 1784197958811, - "tag": "0041_great_adam_warlock", - "breakpoints": true - }, - { - "idx": 42, - "version": "7", - "when": 1784200446279, - "tag": "0042_uneven_lady_bullseye", - "breakpoints": true - }, - { - "idx": 43, - "version": "7", - "when": 1784200890448, - "tag": "0043_third_sleeper", - "breakpoints": true - }, - { - "idx": 44, - "version": "7", - "when": 1784208911426, - "tag": "0044_dusty_blazing_skull", - "breakpoints": true - }, - { - "idx": 45, - "version": "7", - "when": 1784311428092, - "tag": "0045_ambiguous_rictor", - "breakpoints": true - }, - { - "idx": 46, - "version": "7", - "when": 1784362537524, - "tag": "0046_dry_jubilee", - "breakpoints": true - }, - { - "idx": 47, - "version": "7", - "when": 1784626173708, - "tag": "0047_neat_cannonball", - "breakpoints": true - }, - { - "idx": 48, - "version": "7", - "when": 1784713840270, - "tag": "0048_massive_supreme_intelligence", + "when": 1784981026716, + "tag": "0000_current_schema", "breakpoints": true } ] diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 26d88d66..cda6dbbd 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -276,13 +276,3 @@ export { syncClerkUser, UserDeletionBlockedError, } from "./users"; -export type { - WorkspaceTransitionOwner, - WorkspaceTransitionOwnerIdPage, -} from "./workspace-transitions"; -export { - applyCanonicalWorkspaceTransition, - listWorkspaceTransitionOwnerIdPage, - loadWorkspaceTransitionOwner, - WorkspaceTransitionInvariantError, -} from "./workspace-transitions"; diff --git a/packages/db/src/resource-limits.ts b/packages/db/src/resource-limits.ts index bebc4122..e60a1587 100644 --- a/packages/db/src/resource-limits.ts +++ b/packages/db/src/resource-limits.ts @@ -20,7 +20,7 @@ export async function applyEntitlementResourceLimits( }); } -/** Uses the Vault RPC lock identity to serialize provider writes, slot reconciliation, and revalidation. */ +/** Uses the Vault RPC lock identity to serialize provider-key writes and revalidation. */ export async function lockUserProviderKeyMutations(db: Database, userId: UserId): Promise { const identity = `cheatcode:provider-keys:${userId}`; await db.execute(sql`select pg_advisory_xact_lock(hashtextextended(${identity}, 0))`); diff --git a/packages/db/src/supabase-target-contracts.ts b/packages/db/src/supabase-target-contracts.ts index 4347135d..82149caa 100644 --- a/packages/db/src/supabase-target-contracts.ts +++ b/packages/db/src/supabase-target-contracts.ts @@ -63,14 +63,6 @@ export const TABLE_CONTRACTS: readonly TableContract[] = [ column("dropped_at", "timestamp with time zone", true, 6), ], }, - { - tableName: "_raw_migrations", - columns: [ - column("filename", "text"), - column("sha256", "text"), - column("applied_at", "timestamp with time zone", false, 6), - ], - }, { tableName: "v2_users", columns: [ @@ -469,19 +461,6 @@ export const REQUIRED_INTEGRITY_INDEXES = [ "v2_daily_maintenance_jobs_completed_idx", ] as const; -export const FORBIDDEN_SUPERSEDED_INDEXES = [ - "v2_messages_thread_created_idx", - "v2_messages_user_created_idx", - "v2_projects_user_created_idx", - "v2_threads_project_created_idx", - "v2_threads_user_project_created_idx", - "v2_threads_user_recent_idx", - "v2_user_skills_user_idx", - "v2_messages_agent_run_assistant_uidx", - "v2_provider_keys_revalidation_idx", - "v2_projects_user_workspace_slug_uidx", -] as const; - export interface ExactIntegrityConstraint { definition: string; deleteAction?: "a" | "c" | "n" | "r"; diff --git a/packages/db/src/supabase-target-ledger.ts b/packages/db/src/supabase-target-ledger.ts index 7712e449..64b15d46 100644 --- a/packages/db/src/supabase-target-ledger.ts +++ b/packages/db/src/supabase-target-ledger.ts @@ -1,4 +1,4 @@ -import type { PgClient, SupabaseTargetMode } from "./supabase-target"; +import type { PgClient } from "./supabase-target"; const ARCHIVE_MANIFEST_COLUMNS = [ "partition_name", @@ -15,57 +15,7 @@ const ARCHIVE_MANIFEST_COLUMNS = [ "dropped_at", ] as const; -export async function validateMigrationLedger( - client: PgClient, - mode: SupabaseTargetMode, -): Promise { - if (mode !== "prod-ready") { - return []; - } - const shape = await client.query( - `select - to_regclass('public._raw_migrations') is not null as table_exists, - exists ( - select 1 from information_schema.columns - where table_schema = 'public' - and table_name = '_raw_migrations' - and column_name = 'sha256' - and data_type = 'text' - and is_nullable = 'NO' - ) as checksum_valid_shape, - exists ( - select 1 - from pg_constraint - where conrelid = to_regclass('public._raw_migrations') - and conname = '_raw_migrations_sha256_check' - and convalidated - ) as checksum_constraint_validated`, - ); - const row = shape.rows[0]; - if ( - row?.["table_exists"] !== true || - row["checksum_valid_shape"] !== true || - row["checksum_constraint_validated"] !== true - ) { - return ["Raw migration ledger must have a required, validated SHA-256 identity column."]; - } - const result = await client.query( - `select count(*)::text as missing_count - from public._raw_migrations - where sha256 is null or sha256 !~ '^[0-9a-f]{64}$'`, - ); - return result.rows[0]?.["missing_count"] === "0" - ? [] - : ["Every applied raw migration must have a valid SHA-256 checksum."]; -} - -export async function validateAuditArchiveManifest( - client: PgClient, - mode: SupabaseTargetMode, -): Promise { - if (mode !== "prod-ready") { - return []; - } +export async function validateAuditArchiveManifest(client: PgClient): Promise { const result = await client.query( `select column_name from information_schema.columns diff --git a/packages/db/src/supabase-target-security.ts b/packages/db/src/supabase-target-security.ts index e799776d..028a7d67 100644 --- a/packages/db/src/supabase-target-security.ts +++ b/packages/db/src/supabase-target-security.ts @@ -383,13 +383,7 @@ async function loadProviderIndexes(client: TargetQueryClient): Promise [stringField(row, "relname") ?? "", row as IndexRow] as const), @@ -423,9 +417,6 @@ function validateProviderIndexes(indexes: ReadonlyMap): string "Provider revalidation requires a valid lease-aware due-order index for enabled keys.", ); } - if (indexes.has("v2_provider_keys_revalidation_idx")) { - issues.push("The superseded provider-key revalidation index must be removed."); - } return issues; } diff --git a/packages/db/src/supabase-target.ts b/packages/db/src/supabase-target.ts index 868d8b7c..1424c13b 100644 --- a/packages/db/src/supabase-target.ts +++ b/packages/db/src/supabase-target.ts @@ -3,13 +3,12 @@ import { CANONICAL_PROVIDER_KEY_CONSTRAINT, EXACT_INTEGRITY_CONSTRAINTS, type ExpectedColumn, - FORBIDDEN_SUPERSEDED_INDEXES, REQUIRED_INTEGRITY_CONSTRAINTS, REQUIRED_INTEGRITY_INDEXES, TABLE_CONTRACTS, type TableContract, } from "./supabase-target-contracts"; -import { validateAuditArchiveManifest, validateMigrationLedger } from "./supabase-target-ledger"; +import { validateAuditArchiveManifest } from "./supabase-target-ledger"; import { validateProductionSecurityTarget } from "./supabase-target-security"; interface QueryResult { @@ -20,124 +19,44 @@ export interface PgClient { end(): Promise; query(text: string, values?: unknown[]): Promise; } -export type SupabaseTargetMode = "pre-migration" | "prod-ready"; interface ColumnInfo { dataType: string; datetimePrecision?: number; nullable: boolean; } -// These tables are created together by the first Drizzle migration and remain -// permanent schema anchors. Later migrations may add tables, so folding those -// additions into this atomic set would make every older valid deployment fail -// preflight before it can migrate forward. -const V2_FOUNDATION_DRIZZLE_TABLES = [ - "v2_users", - "v2_projects", - "v2_threads", - "v2_messages", - "v2_agent_runs", - "v2_provider_keys", - "v2_user_integrations", - "v2_generated_outputs", - "v2_entitlements", -] as const; -const FORBIDDEN_TOKEN_ACCOUNTING_TABLES = ["v2_usage_daily_totals", "v2_usage_events"] as const; -const FORBIDDEN_TOKEN_ACCOUNTING_COLUMNS = [ - { - columns: ["cost_usd", "tokens_cached", "tokens_in", "tokens_out"], - tableName: "v2_agent_runs", - }, - { - columns: ["free_deepseek_tokens_used"], - tableName: "v2_entitlements", - }, -] as const; -const FORBIDDEN_ENTITLEMENT_SCAFFOLDING_COLUMNS = [ - "flag_private_projects", - "flag_sso", - "max_concurrent_sandboxes", - "max_seats", - "quota_deployments", -] as const; -const FORBIDDEN_PROJECT_BACKUP_COLUMNS = ["container_backup"] as const; -const FORBIDDEN_OBSOLETE_TABLES = [ - "v2_automation_run_requests", - "v2_automation_runs", - "v2_automations", - "v2_replay_shares", - "v2_retired_automation_run_requests_20260715", - "v2_retired_automation_runs_20260715", - "v2_retired_automations_20260715", -] as const; class SupabaseTargetError extends Error { public readonly issues: readonly string[]; - public constructor(mode: SupabaseTargetMode, issues: readonly string[]) { - super( - `Supabase target validation failed (${mode}):\n${issues.map((issue) => `- ${issue}`).join("\n")}`, - ); + public constructor(issues: readonly string[]) { + super(`Supabase target validation failed:\n${issues.map((issue) => `- ${issue}`).join("\n")}`); this.name = "SupabaseTargetError"; this.issues = issues; } } -export async function assertSupabaseTarget( - client: PgClient, - mode: SupabaseTargetMode, -): Promise { - const issues = await validateSupabaseTarget(client, mode); +export async function assertSupabaseTarget(client: PgClient): Promise { + const issues = await validateSupabaseTarget(client); if (issues.length > 0) { - throw new SupabaseTargetError(mode, issues); + throw new SupabaseTargetError(issues); } } -async function validateSupabaseTarget( - client: PgClient, - mode: SupabaseTargetMode, -): Promise { +async function validateSupabaseTarget(client: PgClient): Promise { const tables = await loadPublicColumns(client); const publicTableNames = await loadPublicTableNames(client); return [ - ...validateMigrationPresence(mode, publicTableNames), - ...validateColumns(mode, tables), - ...validateRemovedTokenAccounting(mode, publicTableNames, tables), - ...validateRemovedObsoleteTables(mode, publicTableNames), - ...validateRemovedEntitlementScaffolding(mode, tables), - ...validateRemovedProjectBackup(mode, tables), - ...(mode === "prod-ready" ? await validateProductionSecurityTarget(client) : []), - ...(await validateIntegrityConstraints(client, mode)), - ...(await validateCanonicalProjectWorkspaces(client, mode)), - ...(await validateIntegrityIndexes(client, mode)), - ...(await validateMigrationLedger(client, mode)), - ...(await validateAuditArchiveManifest(client, mode)), - ...(await validateFirstArtifactMilestone(client, mode)), + ...validateColumns(tables), + ...validateTableSet(publicTableNames), + ...(await validateProductionSecurityTarget(client)), + ...(await validateIntegrityConstraints(client)), + ...(await validateCanonicalProjectWorkspaces(client)), + ...(await validateIntegrityIndexes(client)), + ...(await validateAuditArchiveManifest(client)), + ...(await validateFirstArtifactMilestone(client)), ]; } -function validateRemovedObsoleteTables( - mode: SupabaseTargetMode, - publicTableNames: Set, -): string[] { - if (mode !== "prod-ready") { - return []; - } - return FORBIDDEN_OBSOLETE_TABLES.filter((tableName) => publicTableNames.has(tableName)).map( - (tableName) => `Obsolete table public.${tableName} must be removed.`, - ); -} - -async function validateFirstArtifactMilestone( - client: PgClient, - mode: SupabaseTargetMode, -): Promise { - if (mode !== "prod-ready") { - return []; - } +async function validateFirstArtifactMilestone(client: PgClient): Promise { const result = await client.query( `select - exists ( - select 1 from pg_trigger - where tgname = 'v2_capture_first_artifact_trigger' - and not tgisinternal - ) as bridge_exists, count(*)::text as invalid_count from public.v2_users users join ( @@ -149,63 +68,19 @@ async function validateFirstArtifactMilestone( or users.first_artifact_at > first_output.created_at`, ); const row = result.rows[0]; - const issues: string[] = []; - if (row?.["bridge_exists"] === true) { - issues.push("The temporary first-artifact insertion bridge must be removed."); - } - if (row?.["invalid_count"] !== "0") { - issues.push("Every user with generated outputs must retain the true first-artifact milestone."); - } - return issues; -} - -function validateRemovedProjectBackup( - mode: SupabaseTargetMode, - tables: Map>, -): string[] { - if (mode !== "prod-ready") { - return []; - } - const columns = tables.get("v2_projects"); - return FORBIDDEN_PROJECT_BACKUP_COLUMNS.filter((column) => columns?.has(column)).map( - (column) => `Obsolete project-backup column public.v2_projects.${column} must be removed.`, - ); + return row?.["invalid_count"] === "0" + ? [] + : ["Every user with generated outputs must retain the true first-artifact milestone."]; } -function validateRemovedEntitlementScaffolding( - mode: SupabaseTargetMode, - tables: Map>, -): string[] { - if (mode !== "prod-ready") { - return []; - } - const columns = tables.get("v2_entitlements"); - return FORBIDDEN_ENTITLEMENT_SCAFFOLDING_COLUMNS.filter((column) => columns?.has(column)).map( - (column) => `Obsolete entitlement column public.v2_entitlements.${column} must be removed.`, - ); -} - -function validateRemovedTokenAccounting( - mode: SupabaseTargetMode, - publicTableNames: Set, - tables: Map>, -): string[] { - if (mode !== "prod-ready") { - return []; - } - const tableIssues = FORBIDDEN_TOKEN_ACCOUNTING_TABLES.filter((tableName) => - publicTableNames.has(tableName), - ).map((tableName) => `Obsolete token-accounting table public.${tableName} must be removed.`); - const columnIssues = FORBIDDEN_TOKEN_ACCOUNTING_COLUMNS.flatMap(({ columns, tableName }) => { - const actualColumns = tables.get(tableName); - return columns - .filter((columnName) => actualColumns?.has(columnName)) - .map( - (columnName) => - `Obsolete token-accounting column public.${tableName}.${columnName} must be removed.`, - ); - }); - return [...tableIssues, ...columnIssues]; +function validateTableSet(publicTableNames: ReadonlySet): string[] { + const expected = new Set(TABLE_CONTRACTS.map(({ tableName }) => tableName)); + return [...publicTableNames] + .filter( + (tableName) => + !expected.has(tableName) && !/^v2_audit_log_\d{4}_(0[1-9]|1[0-2])$/u.test(tableName), + ) + .map((tableName) => `Unexpected table public.${tableName} must be removed.`); } async function loadPublicTableNames(client: PgClient): Promise> { @@ -263,62 +138,31 @@ function numberField(row: Record, key: string): number | undefi return typeof value === "number" && Number.isInteger(value) ? value : undefined; } -function validateColumns( - mode: SupabaseTargetMode, - tables: Map>, -): string[] { +function validateColumns(tables: Map>): string[] { return TABLE_CONTRACTS.flatMap((contract) => { const columns = tables.get(contract.tableName); if (!columns) { - return mode === "prod-ready" ? [`public.${contract.tableName} is missing.`] : []; + return [`public.${contract.tableName} is missing.`]; } const expectedNames = new Set(contract.columns.map(({ name }) => name)); - const unexpected = - mode === "prod-ready" - ? [...columns.keys()] - .filter((name) => !expectedNames.has(name)) - .map( - (name) => `Unexpected column public.${contract.tableName}.${name} must be removed.`, - ) - : []; + const unexpected = [...columns.keys()] + .filter((name) => !expectedNames.has(name)) + .map((name) => `Unexpected column public.${contract.tableName}.${name} must be removed.`); return [ - ...contract.columns.flatMap((expected) => validateColumn(mode, contract, expected, columns)), + ...contract.columns.flatMap((expected) => validateColumn(contract, expected, columns)), ...unexpected, ]; }); } -function validateMigrationPresence( - mode: SupabaseTargetMode, - publicTableNames: Set, -): string[] { - if (mode !== "pre-migration") { - return []; - } - - const expectedTableNames = V2_FOUNDATION_DRIZZLE_TABLES; - const existing = expectedTableNames.filter((tableName) => publicTableNames.has(tableName)); - if (existing.length === 0 || existing.length === expectedTableNames.length) { - return []; - } - - const missing = expectedTableNames.filter((tableName) => !publicTableNames.has(tableName)); - return [ - `Pre-migration target has partial V2 Cheatcode tables (${existing.map((tableName) => `public.${tableName}`).join(", ")}) but is missing ${missing.map((tableName) => `public.${tableName}`).join(", ")}. Finish or roll back the V2 migration before retrying.`, - ]; -} - function validateColumn( - mode: SupabaseTargetMode, contract: TableContract, expected: ExpectedColumn, columns: Map, ): string[] { const actual = columns.get(expected.name); if (!actual) { - return mode === "prod-ready" - ? [`public.${contract.tableName}.${expected.name} is missing.`] - : []; + return [`public.${contract.tableName}.${expected.name} is missing.`]; } if (expected.dataType && actual.dataType !== expected.dataType) { return [ @@ -326,7 +170,6 @@ function validateColumn( ]; } if ( - mode === "prod-ready" && expected.datetimePrecision !== undefined && actual.datetimePrecision !== expected.datetimePrecision ) { @@ -334,7 +177,7 @@ function validateColumn( `public.${contract.tableName}.${expected.name} must use timestamp precision ${expected.datetimePrecision}.`, ]; } - if (mode === "prod-ready" && actual.nullable !== expected.nullable) { + if (actual.nullable !== expected.nullable) { return [ `public.${contract.tableName}.${expected.name} must be ${expected.nullable ? "nullable" : "NOT NULL"}.`, ]; @@ -342,13 +185,7 @@ function validateColumn( return []; } -async function validateIntegrityConstraints( - client: PgClient, - mode: SupabaseTargetMode, -): Promise { - if (mode !== "prod-ready") { - return []; - } +async function validateIntegrityConstraints(client: PgClient): Promise { const result = await client.query( `select relation.relname as table_name, @@ -431,13 +268,7 @@ function normalizedSqlDefinition(value: unknown): string { return typeof value === "string" ? value.replaceAll(/\s+/g, " ").trim() : ""; } -async function validateCanonicalProjectWorkspaces( - client: PgClient, - mode: SupabaseTargetMode, -): Promise { - if (mode !== "prod-ready") { - return []; - } +async function validateCanonicalProjectWorkspaces(client: PgClient): Promise { const result = await client.query( `select count(*)::text as invalid_count from public.v2_projects @@ -453,14 +284,7 @@ async function validateCanonicalProjectWorkspaces( : ["Every project workspace slug must be a safe bounded base owned by its UUID suffix."]; } -async function validateIntegrityIndexes( - client: PgClient, - mode: SupabaseTargetMode, -): Promise { - if (mode !== "prod-ready") { - return []; - } - const names = [...REQUIRED_INTEGRITY_INDEXES, ...FORBIDDEN_SUPERSEDED_INDEXES]; +async function validateIntegrityIndexes(client: PgClient): Promise { const result = await client.query( `select index_relation.relname as index_name, @@ -476,12 +300,7 @@ async function validateIntegrityIndexes( join pg_namespace namespace on namespace.oid = index_relation.relnamespace where namespace.nspname = 'public' and index_relation.relname = any($1::text[])`, - [names], - ); - const present = new Set( - result.rows - .map((row) => stringField(row, "index_name")) - .filter((name): name is string => name !== undefined), + [REQUIRED_INTEGRITY_INDEXES], ); const valid = new Set( result.rows @@ -492,10 +311,7 @@ async function validateIntegrityIndexes( const missing = REQUIRED_INTEGRITY_INDEXES.filter((name) => !valid.has(name)).map( (name) => `Required production index public.${name} is missing, invalid, or not ready.`, ); - const superseded = FORBIDDEN_SUPERSEDED_INDEXES.filter((name) => present.has(name)).map( - (name) => `Superseded production index public.${name} must be removed.`, - ); - return [...missing, ...superseded, ...validateRequiredIndexShapes(result.rows)]; + return [...missing, ...validateRequiredIndexShapes(result.rows)]; } function validateRequiredIndexShapes(rows: readonly Record[]): string[] { diff --git a/packages/db/src/workspace-transitions.ts b/packages/db/src/workspace-transitions.ts deleted file mode 100644 index 98eddc3d..00000000 --- a/packages/db/src/workspace-transitions.ts +++ /dev/null @@ -1,187 +0,0 @@ -import { - CanonicalProjectWorkspaceSlugSchema, - ProjectId, - UserId, - type WorkspaceTransitionProject, -} from "@cheatcode/types"; -import { and, asc, eq, gt, isNull, sql } from "drizzle-orm"; -import type { Database } from "./client"; -import { canonicalWorkspaceSlugForProject, lockUserProjectMutations } from "./projects"; -import { projects, users } from "./schema"; - -const DATABASE_MAINTENANCE_LOCK = "cheatcode:database-maintenance:v1"; - -export interface WorkspaceTransitionOwner { - projects: WorkspaceTransitionProject[]; - userId: UserId; -} - -export interface WorkspaceTransitionOwnerIdPage { - nextCursor: UserId | null; - ownerIds: UserId[]; -} - -export class WorkspaceTransitionInvariantError extends Error { - public readonly retriable = false; -} - -export async function listWorkspaceTransitionOwnerIdPage( - db: Database, - input: { cursor?: UserId; limit: number }, -): Promise { - const limit = Math.max(1, Math.min(100, Math.trunc(input.limit))); - const ownerRows = await db - .select({ userId: users.id }) - .from(users) - .where(and(isNull(users.deletedAt), input.cursor ? gt(users.id, input.cursor) : undefined)) - .orderBy(asc(users.id)) - .limit(limit + 1); - const selectedOwners = ownerRows.slice(0, limit); - const lastSelectedOwner = selectedOwners.at(-1); - return { - nextCursor: - ownerRows.length > limit && lastSelectedOwner ? UserId(lastSelectedOwner.userId) : null, - ownerIds: selectedOwners.map((owner) => UserId(owner.userId)), - }; -} - -export async function loadWorkspaceTransitionOwner( - db: Database, - userId: UserId, -): Promise { - const owner = await db.query.users.findFirst({ - columns: { id: true }, - where: and(eq(users.id, userId), isNull(users.deletedAt)), - }); - if (!owner) { - return null; - } - const rows = await db - .select({ id: projects.id, name: projects.name, workspaceSlug: projects.workspaceSlug }) - .from(projects) - .where(and(eq(projects.userId, userId), isNull(projects.deletedAt))) - .orderBy(asc(projects.id)); - return { projects: rows.map(workspaceTransitionProject), userId }; -} - -export async function applyCanonicalWorkspaceTransition( - db: Database, - input: { projects: WorkspaceTransitionProject[]; userId: UserId }, -): Promise<{ updated: number }> { - return db.transaction(async (transaction) => { - await transaction.execute(sql`select set_config('app.user_id', ${input.userId}, true)`); - await acquireMaintenanceFence(transaction); - await lockUserProjectMutations(transaction as Database, input.userId); - const current = await lockedActiveProjects(transaction as Database, input.userId); - assertTransitionMatchesProjects(current, input.projects); - let updated = 0; - for (const project of input.projects) { - if (project.currentWorkspaceSlug === project.canonicalWorkspaceSlug) { - continue; - } - const rows = await transaction - .update(projects) - .set({ workspaceSlug: project.canonicalWorkspaceSlug }) - .where( - and( - eq(projects.id, project.projectId), - eq(projects.userId, input.userId), - eq(projects.workspaceSlug, project.currentWorkspaceSlug), - isNull(projects.deletedAt), - ), - ) - .returning({ id: projects.id }); - if (rows.length > 1) { - throw new WorkspaceTransitionInvariantError("Workspace transition updated multiple rows."); - } - updated += rows.length; - } - const finalized = await lockedActiveProjects(transaction as Database, input.userId); - assertCanonicalTransitionApplied(finalized, input.projects); - return { updated }; - }); -} - -async function acquireMaintenanceFence(db: Database): Promise { - const result = await db.execute(sql` - select pg_try_advisory_xact_lock( - hashtextextended(${DATABASE_MAINTENANCE_LOCK}, 0) - ) as locked - `); - if (result.rows[0]?.["locked"] !== true) { - throw new WorkspaceTransitionInvariantError( - "Another database maintenance operation owns the workspace transition fence.", - ); - } -} - -async function lockedActiveProjects(db: Database, userId: UserId) { - return db - .select({ id: projects.id, name: projects.name, workspaceSlug: projects.workspaceSlug }) - .from(projects) - .where(and(eq(projects.userId, userId), isNull(projects.deletedAt))) - .orderBy(asc(projects.id)) - .for("update"); -} - -function assertTransitionMatchesProjects( - current: Awaited>, - requested: WorkspaceTransitionProject[], -): void { - if (current.length !== requested.length) { - throw new WorkspaceTransitionInvariantError( - "Active project inventory changed during transition.", - ); - } - const requestedById = new Map(requested.map((project) => [project.projectId, project])); - for (const project of current) { - const request = requestedById.get(project.id); - const canonical = transitionCanonicalSlug(project); - if ( - !request || - request.canonicalWorkspaceSlug !== canonical || - (project.workspaceSlug !== request.currentWorkspaceSlug && - project.workspaceSlug !== canonical) - ) { - throw new WorkspaceTransitionInvariantError( - "Active project workspace identity changed during transition.", - ); - } - } -} - -function assertCanonicalTransitionApplied( - current: Awaited>, - requested: WorkspaceTransitionProject[], -): void { - const canonicalById = new Map( - requested.map((project) => [project.projectId, project.canonicalWorkspaceSlug]), - ); - if ( - current.length !== requested.length || - current.some((project) => canonicalById.get(project.id) !== project.workspaceSlug) - ) { - throw new WorkspaceTransitionInvariantError("Canonical workspace update did not converge."); - } -} - -function workspaceTransitionProject(row: { - id: string; - name: string; - workspaceSlug: string; -}): WorkspaceTransitionProject { - const projectId = ProjectId(row.id); - return { - canonicalWorkspaceSlug: transitionCanonicalSlug(row), - currentWorkspaceSlug: row.workspaceSlug, - projectId, - }; -} - -function transitionCanonicalSlug(row: { id: string; name: string; workspaceSlug: string }): string { - const projectId = ProjectId(row.id); - const parsed = CanonicalProjectWorkspaceSlugSchema.safeParse(row.workspaceSlug); - return parsed.success && parsed.data.endsWith(`-${projectId}`) - ? parsed.data - : canonicalWorkspaceSlugForProject(row.name, projectId); -} diff --git a/packages/durable-storage/README.md b/packages/durable-storage/README.md index 8c5db5a8..e79ad55a 100644 --- a/packages/durable-storage/README.md +++ b/packages/durable-storage/README.md @@ -1,14 +1,12 @@ # @cheatcode/durable-storage -Exact SQLite schema attestation shared by the Cloudflare Durable Objects. It -canonicalizes `sqlite_schema`, binds a reconciliation request to the closed -release and concrete object identity, and emits validated evidence only after -the owning object has reconciled or verified its current schema. - -The package does not own an application's tables or data migrations. Each -Durable Object declares and rebuilds its own exact current schema so dormant -objects cannot retain stale tables, indexes, views, triggers, columns, or -constraints. Attestation inspects every non-internal `sqlite_schema` object. +Exact SQLite schema validation shared by the Cloudflare Durable Objects. It +canonicalizes `sqlite_schema` and rejects any object whose persisted schema +differs from the current application contract. + +The package does not own application tables or data migrations. Each Durable +Object initializes its exact current schema once and validates existing storage +before use. Validation inspects every non-internal `sqlite_schema` object. Its SQL tokenizer ignores comments and whitespace, folds unquoted ASCII identifier/keyword case, and ignores `IF NOT EXISTS` on `CREATE` statements. String literals and quoted identifiers remain byte-for-byte significant so @@ -23,11 +21,7 @@ support `PRAGMA user_version`. Attestation excludes only Workerd's exact ## Public exports - `assertExactSqliteSchema` -- `assertSqliteRowCountPreserved` -- `reconcileExactSqliteStorage` - `setCurrentSqliteStorageVersion` -- `assertStorageReconciliationRequest` -- `storageSchemaEvidence` - `ExpectedSqliteObject` - `SqliteSchemaMismatchError` - `SqliteSchemaObjectType` @@ -42,4 +36,4 @@ pnpm --filter @cheatcode/durable-storage build ## Env -None. Callers supply their release gate and release SHA bindings. +None. diff --git a/packages/durable-storage/package.json b/packages/durable-storage/package.json index 0f9d2889..446d6a61 100644 --- a/packages/durable-storage/package.json +++ b/packages/durable-storage/package.json @@ -16,9 +16,6 @@ "lint": "biome check .", "typecheck": "tsc -p tsconfig.json --noEmit" }, - "dependencies": { - "@cheatcode/types": "workspace:*" - }, "devDependencies": { "@cheatcode/tsconfig": "workspace:*", "@cloudflare/workers-types": "catalog:", diff --git a/packages/durable-storage/src/index.ts b/packages/durable-storage/src/index.ts index 8d63c0e0..b9aff668 100644 --- a/packages/durable-storage/src/index.ts +++ b/packages/durable-storage/src/index.ts @@ -1,12 +1,3 @@ -import { - DURABLE_OBJECT_STORAGE_SCHEMA_VERSIONS, - type DurableObjectStorageClass, - type InternalDurableObjectStorageRequest, - InternalDurableObjectStorageRequestSchema, - type InternalDurableObjectStorageResponse, - InternalDurableObjectStorageResponseSchema, -} from "@cheatcode/types"; - export const CURRENT_SQLITE_STORAGE_VERSION = 1; const STORAGE_METADATA_TABLE = "__cheatcode_storage_metadata"; @@ -48,41 +39,6 @@ interface CanonicalSqliteObject { type: SqliteSchemaObjectType; } -interface ReleaseBoundDurableObjectEnv { - CHEATCODE_RELEASE_GATE: "closed" | "draining" | "open"; - CHEATCODE_RELEASE_SHA?: string; -} - -export function assertStorageReconciliationRequest( - ctx: DurableObjectState, - env: ReleaseBoundDurableObjectEnv, - value: InternalDurableObjectStorageRequest, - className: DurableObjectStorageClass, -): InternalDurableObjectStorageRequest { - const input = InternalDurableObjectStorageRequestSchema.parse(value); - if ( - env.CHEATCODE_RELEASE_GATE !== "closed" || - env.CHEATCODE_RELEASE_SHA !== input.releaseSha || - input.className !== className || - input.objectId !== ctx.id.toString() - ) { - throw new Error(`${className} storage reconciliation authority mismatch.`); - } - return input; -} - -export function storageSchemaEvidence( - input: InternalDurableObjectStorageRequest, -): InternalDurableObjectStorageResponse { - return InternalDurableObjectStorageResponseSchema.parse({ - className: input.className, - objectId: input.objectId, - releaseSha: input.releaseSha, - schemaVersion: DURABLE_OBJECT_STORAGE_SCHEMA_VERSIONS[input.className], - verified: true, - }); -} - export function setCurrentSqliteStorageVersion(ctx: DurableObjectState): void { // Durable Object SQL does not support PRAGMA user_version, so the marker is application-owned. ctx.storage.sql.exec(`DROP TABLE IF EXISTS ${STORAGE_METADATA_TABLE}`); @@ -93,49 +49,6 @@ export function setCurrentSqliteStorageVersion(ctx: DurableObjectState): void { ); } -/** Rebuild once, then make retries and signed-request replays verification-only. */ -export function reconcileExactSqliteStorage( - mode: InternalDurableObjectStorageRequest["mode"], - assertCurrent: () => void, - reconcile: () => void, -): void { - if (mode === "verify") { - assertCurrent(); - return; - } - try { - assertCurrent(); - } catch (error) { - if (!(error instanceof SqliteSchemaMismatchError)) throw error; - reconcile(); - } -} - -/** Proves a copy step did not filter or replace rows before the source table is dropped. */ -export function assertSqliteRowCountPreserved( - ctx: DurableObjectState, - sourceTable: string, - targetTable: string, -): void { - if (!isSafeSqlIdentifier(sourceTable) || !isSafeSqlIdentifier(targetTable)) { - throw new TypeError("SQLite preservation evidence requires safe table identifiers."); - } - const [row] = ctx.storage.sql - .exec( - `SELECT (SELECT count(*) FROM ${sourceTable}) AS source_count, - (SELECT count(*) FROM ${targetTable}) AS target_count`, - ) - .toArray(); - if ( - !isRecord(row) || - typeof row["source_count"] !== "number" || - typeof row["target_count"] !== "number" || - row["source_count"] !== row["target_count"] - ) { - throw new Error("Durable Object reconciliation did not preserve every source row."); - } -} - export function assertExactSqliteSchema( ctx: DurableObjectState, expected: readonly ExpectedSqliteObject[], @@ -379,10 +292,6 @@ function isSqlWhitespace(value: string): boolean { return value === " " || value === "\t" || value === "\n" || value === "\r" || value === "\f"; } -function isSafeSqlIdentifier(value: string): boolean { - return /^[a-z][a-z0-9_]*$/u.test(value); -} - function isSqlWordStart(value: string): boolean { return /[A-Z_a-z\u0080-\u{10ffff}]/u.test(value); } diff --git a/packages/env/README.md b/packages/env/README.md index 4e1c1e93..485fdc9e 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -9,8 +9,8 @@ read raw `process.env` values only to pass them into the pure `./web-config` val - `./web-config`: pure Vercel target and public web build validators used by both `next.config.ts` and `./web` - `./worker`: Cloudflare Worker binding schemas and Secrets Store resolution helpers -- `./migrate`: admin database identity pins, optional one-time migration - attestations, plus the Cloudflare account pin used by the audit archive operation +- `./migrate`: administrative database identity pins plus the Cloudflare account + pin used by the audit archive operation ## Code Checks @@ -25,9 +25,6 @@ use the production Supabase session pooler with the three least-privilege runtim roles. Administrative migration values live separately in git-ignored `.env.migrate` (template: `.env.migrate.example`) or protected automation environment variables and are never loaded by the app or copied into a Worker. -`CHEATCODE_MIGRATION_ATTESTATIONS` is an optional protected JSON envelope consumed -only while a specifically attested contraction is pending; an unset or empty value -is valid after that migration is recorded. Gateway, preview-hostname, release-SHA, deployment-target, and Clerk publishable-key validation has one canonical implementation in `./web-config`. The framework config diff --git a/packages/env/src/migrate.ts b/packages/env/src/migrate.ts index 59ee47f7..8e5c8681 100644 --- a/packages/env/src/migrate.ts +++ b/packages/env/src/migrate.ts @@ -3,14 +3,8 @@ import { dirname, parse, resolve } from "node:path"; import { z } from "zod"; const DEFAULT_ENV_FILES = [".env.migrate"] as const; -const OptionalMigrationAttestationsSchema = z.preprocess( - (value) => (typeof value === "string" && !value.trim() ? undefined : value), - z.string().trim().min(2).max(65_536).optional(), -); - const MigrationEnvSchema = z .object({ - CHEATCODE_MIGRATION_ATTESTATIONS: OptionalMigrationAttestationsSchema, SUPABASE_MIGRATION_EXPECTED_DATABASE: z.string().trim().min(1).optional(), SUPABASE_MIGRATION_EXPECTED_HOST: z.string().trim().min(1).optional(), SUPABASE_MIGRATION_EXPECTED_ROLE: z.string().trim().min(1).optional(), @@ -25,16 +19,12 @@ export interface MigrationEnv { expectedHost?: string; expectedRole?: string; expectedSystemIdentifier?: string; - migrationAttestations?: string; } function parseMigrationEnv(env: unknown): MigrationEnv { const parsed = MigrationEnvSchema.parse(env); return { databaseUrl: parsed.SUPABASE_MIGRATION_URL, - ...(parsed.CHEATCODE_MIGRATION_ATTESTATIONS - ? { migrationAttestations: parsed.CHEATCODE_MIGRATION_ATTESTATIONS } - : {}), ...(parsed.SUPABASE_MIGRATION_EXPECTED_DATABASE ? { expectedDatabase: parsed.SUPABASE_MIGRATION_EXPECTED_DATABASE } : {}), diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 9311d438..a3068f98 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -164,52 +164,35 @@ export { export type { ClerkInstanceIdentity, DaytonaVolumeIdentity, - DurableObjectStorageClass, GatewayDatabaseReadinessAggregateResponse, InternalAgentStateDeleteBody, InternalDatabaseReadinessRequest, InternalDatabaseReadinessResponse, - InternalDurableObjectStorageRequest, - InternalDurableObjectStorageResponse, InternalResourceDeletionRequest, InternalStateDeleteResponse, - InternalWorkspaceReconciliationBody, - InternalWorkspaceReconciliationResponse, ProductionClerkInstanceIdentity, ResourceDeletionWorkflowPayload, - SandboxSnapshotReconciliation, - WorkspaceTransitionProject, } from "./internal-maintenance"; export { AgentDatabaseReadinessResponseSchema, CanonicalProjectWorkspaceSlugSchema, ClerkInstanceIdentitySchema, - canonicalWorkspaceDigest, DaytonaVolumeIdentitySchema, - DURABLE_OBJECT_STORAGE_SCHEMA_VERSIONS, - DurableObjectStorageClassSchema, GatewayDatabaseReadinessAggregateResponseSchema, GatewayDatabaseReadinessResponseSchema, INTERNAL_DATABASE_READINESS_PATH, - INTERNAL_DURABLE_OBJECT_STORAGE_PATH, INTERNAL_RESOURCE_DELETION_PATH, InternalAgentStateDeleteBodySchema, InternalDatabaseReadinessRequestSchema, InternalDatabaseReadinessResponseSchema, - InternalDurableObjectStorageRequestSchema, - InternalDurableObjectStorageResponseSchema, InternalProjectDeletionRequestSchema, InternalResourceDeletionRequestSchema, InternalStateDeleteResponseSchema, InternalThreadDeletionRequestSchema, - InternalWorkspaceReconciliationBodySchema, - InternalWorkspaceReconciliationResponseSchema, internalUserStateDeletePath, - internalUserWorkspaceReconciliationPath, ProductionClerkInstanceIdentitySchema, ResourceDeletionWorkflowPayloadSchema, WebhooksDatabaseReadinessResponseSchema, - WorkspaceTransitionProjectSchema, } from "./internal-maintenance"; export type { CatalogModelId, LogicalModelId } from "./models"; export { diff --git a/packages/types/src/internal-maintenance.ts b/packages/types/src/internal-maintenance.ts index 6bd10994..0fdac01a 100644 --- a/packages/types/src/internal-maintenance.ts +++ b/packages/types/src/internal-maintenance.ts @@ -12,66 +12,6 @@ const InternalRunIdListSchema = z const ReleaseShaSchema = z.string().regex(/^[0-9a-f]{40}$/u); const DeletionFenceSchema = z.string().regex(/^[1-9]\d{12}$/u); const DeletionGenerationSchema = z.string().datetime({ offset: true }); -const ProjectWorkspaceSlugSchema = z - .string() - .min(1) - .max(64) - .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u); - -export const DurableObjectStorageClassSchema = z.enum([ - "AgentRun", - "ProjectSandbox", - "IdempotencyStore", - "QuotaTracker", - "RateLimiter", - "WebhookIdempotencyStore", -]); - -export type DurableObjectStorageClass = z.infer; - -export const DURABLE_OBJECT_STORAGE_SCHEMA_VERSIONS = { - AgentRun: "agent-run-sqlite-v1", - IdempotencyStore: "idempotency-store-sqlite-v1", - ProjectSandbox: "project-sandbox-sqlite-v1", - QuotaTracker: "quota-tracker-sqlite-v1", - RateLimiter: "rate-limiter-sqlite-v1", - WebhookIdempotencyStore: "webhook-idempotency-store-sqlite-v1", -} as const satisfies Record; - -const DurableObjectIdSchema = z.string().regex(/^[0-9a-f]{64}$/u); - -export const InternalDurableObjectStorageRequestSchema = z - .object({ - className: DurableObjectStorageClassSchema, - mode: z.enum(["reconcile", "verify"]), - objectId: DurableObjectIdSchema, - releaseSha: ReleaseShaSchema, - }) - .strict(); - -export type InternalDurableObjectStorageRequest = z.infer< - typeof InternalDurableObjectStorageRequestSchema ->; - -export const InternalDurableObjectStorageResponseSchema = z - .object({ - className: DurableObjectStorageClassSchema, - objectId: DurableObjectIdSchema, - releaseSha: ReleaseShaSchema, - schemaVersion: z.string().min(1), - verified: z.literal(true), - }) - .strict() - .superRefine((value, context) => { - if (value.schemaVersion !== DURABLE_OBJECT_STORAGE_SCHEMA_VERSIONS[value.className]) { - context.addIssue({ code: "custom", message: "Durable Object schema version mismatch." }); - } - }); - -export type InternalDurableObjectStorageResponse = z.infer< - typeof InternalDurableObjectStorageResponseSchema ->; - export const CanonicalProjectWorkspaceSlugSchema = z .string() .min(38) @@ -81,42 +21,6 @@ export const CanonicalProjectWorkspaceSlugSchema = z "Workspace slug must end with its lowercase project UUID.", ); -export const WorkspaceTransitionProjectSchema = z - .object({ - canonicalWorkspaceSlug: CanonicalProjectWorkspaceSlugSchema, - currentWorkspaceSlug: ProjectWorkspaceSlugSchema, - projectId: z.string().uuid().toLowerCase(), - }) - .strict() - .refine( - (project) => project.canonicalWorkspaceSlug.endsWith(`-${project.projectId}`), - "Canonical workspace slug must belong to its project.", - ); - -export type WorkspaceTransitionProject = z.infer; - -const WorkspaceTransitionProjectsSchema = z - .array(WorkspaceTransitionProjectSchema) - .max(10_000) - .superRefine((projects, context) => { - assertUniqueTransitionValues(projects, context, "projectId"); - assertUniqueTransitionValues(projects, context, "currentWorkspaceSlug"); - assertUniqueTransitionValues(projects, context, "canonicalWorkspaceSlug"); - const currentSlugs = new Set(projects.map((project) => project.currentWorkspaceSlug)); - for (const [index, project] of projects.entries()) { - if ( - project.currentWorkspaceSlug !== project.canonicalWorkspaceSlug && - currentSlugs.has(project.canonicalWorkspaceSlug) - ) { - context.addIssue({ - code: "custom", - message: "A canonical workspace cannot be another project's current workspace.", - path: [index, "canonicalWorkspaceSlug"], - }); - } - } - }); - export const InternalAgentStateDeleteBodySchema = z.discriminatedUnion("scope", [ z .object({ @@ -164,79 +68,6 @@ export const InternalAgentStateDeleteBodySchema = z.discriminatedUnion("scope", export type InternalAgentStateDeleteBody = z.infer; -export const InternalWorkspaceReconciliationBodySchema = z - .object({ - phase: z.enum(["prepare", "finalize"]), - projects: WorkspaceTransitionProjectsSchema, - releaseSha: ReleaseShaSchema, - }) - .strict(); - -export type InternalWorkspaceReconciliationBody = z.infer< - typeof InternalWorkspaceReconciliationBodySchema ->; - -const SandboxSnapshotReconciliationSchema = z - .object({ - complete: z.boolean(), - sourceSnapshot: z.string().min(1).nullable(), - status: z.enum(["absent", "current", "upgraded", "upgrading"]), - targetSnapshot: z.string().min(1).max(500), - upgradeId: z - .string() - .regex(/^[0-9a-f]{32}$/u) - .nullable(), - workspaceDigest: z - .string() - .regex(/^[0-9a-f]{64}$/u) - .nullable(), - }) - .strict() - .superRefine((value, context) => { - if (value.complete === (value.status === "upgrading")) { - context.addIssue({ code: "custom", message: "Snapshot completion and status disagree." }); - } - if (value.status === "upgraded" && (!value.upgradeId || !value.workspaceDigest)) { - context.addIssue({ code: "custom", message: "Completed upgrade evidence is incomplete." }); - } - if ((value.status === "absent" || value.status === "current") && value.upgradeId) { - context.addIssue({ - code: "custom", - message: "Unchanged sandboxes cannot expose an upgrade.", - }); - } - if ((value.status === "absent" || value.status === "current") && value.workspaceDigest) { - context.addIssue({ code: "custom", message: "Unchanged sandboxes cannot expose a digest." }); - } - if (value.status === "absent" && value.sourceSnapshot !== null) { - context.addIssue({ code: "custom", message: "An absent sandbox cannot expose a source." }); - } - if (value.status === "current" && value.sourceSnapshot !== value.targetSnapshot) { - context.addIssue({ code: "custom", message: "A current sandbox must match its target." }); - } - }); - -export type SandboxSnapshotReconciliation = z.infer; - -export const InternalWorkspaceReconciliationResponseSchema = z - .object({ - canonicalDigest: z.string().regex(/^[0-9a-f]{64}$/u), - canonicalWorkspaceCount: z.number().int().nonnegative(), - ok: z.literal(true), - processPortReservationsRemoved: z.number().int().nonnegative(), - processRecordsRemoved: z.number().int().nonnegative(), - projectPortsRemoved: z.number().int().nonnegative(), - releaseSha: ReleaseShaSchema, - snapshot: SandboxSnapshotReconciliationSchema, - transitionPhase: z.enum(["prepared", "completed"]), - verified: z.literal(true), - }) - .strict(); - -export type InternalWorkspaceReconciliationResponse = z.infer< - typeof InternalWorkspaceReconciliationResponseSchema ->; - export const InternalDatabaseReadinessRequestSchema = z .object({ releaseSha: ReleaseShaSchema }) .strict(); @@ -371,7 +202,6 @@ export type ResourceDeletionWorkflowPayload = z.infer { - const canonical = [...slugs].sort().join("\n"); - const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonical)); - return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join(""); -} - -function assertUniqueTransitionValues( - projects: z.infer[], - context: z.RefinementCtx, - key: keyof z.infer, -): void { - const values = new Set(); - for (const [index, project] of projects.entries()) { - const value = project[key]; - if (values.has(value)) { - context.addIssue({ code: "custom", message: `${key} must be unique.`, path: [index, key] }); - } - values.add(value); - } -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d24db04..720b0f13 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -52,8 +52,8 @@ catalogs: specifier: 1.51.0 version: 1.51.0 '@next/env': - specifier: 16.2.10 - version: 16.2.10 + specifier: 16.2.11 + version: 16.2.11 '@openrouter/ai-sdk-provider': specifier: 2.9.1 version: 2.9.1 @@ -130,8 +130,8 @@ catalogs: specifier: 1.24.0 version: 1.24.0 next: - specifier: 16.2.10 - version: 16.2.10 + specifier: 16.2.11 + version: 16.2.11 next-themes: specifier: 0.4.6 version: 0.4.6 @@ -202,7 +202,7 @@ overrides: minimatch@>=10.0.0 <10.2.3: 10.2.5 path-to-regexp@>=6.0.0 <6.3.0: 6.3.0 path-to-regexp@>=8.0.0 <8.4.0: 8.4.2 - postcss@<8.5.10: 8.5.10 + postcss@<8.5.18: 8.5.18 sharp@<0.35.0: 0.35.0 smol-toml@<1.6.1: 1.6.1 tar@>=7.0.0 <7.5.11: 7.5.20 @@ -423,7 +423,7 @@ importers: version: link:../../packages/ui '@clerk/nextjs': specifier: 'catalog:' - version: 7.5.19(next@16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + version: 7.5.19(next@16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react-dom@19.2.7(react@19.2.7))(react@19.2.7) '@clerk/ui': specifier: 'catalog:' version: 1.25.4(@solana/web3.js@1.98.4(bufferutil@4.1.0)(typescript@6.0.3)(utf-8-validate@5.0.10))(@types/react@19.2.17)(bs58@6.0.0)(bufferutil@4.1.0)(react-dom@19.2.7(react@19.2.7))(react-native@0.86.0(@babel/core@7.29.7(supports-color@10.2.2))(@types/react@19.2.17)(bufferutil@4.1.0)(react@19.2.7)(supports-color@10.2.2)(utf-8-validate@5.0.10))(react@19.2.7)(supports-color@10.2.2)(typescript@6.0.3)(utf-8-validate@5.0.10) @@ -432,7 +432,7 @@ importers: version: 5.4.0(react-hook-form@7.81.0(react@19.2.7)) '@next/env': specifier: 'catalog:' - version: 16.2.10 + version: 16.2.11 '@tanstack/react-query': specifier: 'catalog:' version: 5.101.2(react@19.2.7) @@ -447,19 +447,19 @@ importers: version: 1.1.1(@types/react-dom@19.2.3(@types/react@19.2.17))(@types/react@19.2.17)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) geist: specifier: 'catalog:' - version: 1.7.2(next@16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)) + version: 1.7.2(next@16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)) katex: specifier: 'catalog:' version: 0.17.0 next: specifier: 'catalog:' - version: 16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + version: 16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) next-themes: specifier: 'catalog:' version: 0.4.6(react-dom@19.2.7(react@19.2.7))(react@19.2.7) nuqs: specifier: 'catalog:' - version: 2.9.0(next@16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react@19.2.7) + version: 2.9.0(next@16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react@19.2.7) qrcode.react: specifier: 'catalog:' version: 4.2.0(react@19.2.7) @@ -749,10 +749,6 @@ importers: version: 6.0.3 packages/durable-storage: - dependencies: - '@cheatcode/types': - specifier: workspace:* - version: link:../types devDependencies: '@cheatcode/tsconfig': specifier: workspace:* @@ -966,7 +962,7 @@ importers: devDependencies: next: specifier: 'catalog:' - version: 16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + version: 16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) packages/types: dependencies: @@ -2119,57 +2115,57 @@ packages: '@emnapi/core': ^1.7.1 '@emnapi/runtime': ^1.7.1 - '@next/env@16.2.10': - resolution: {integrity: sha512-zLPxg9M0MEHmygpj5OuxjQ+vHMiy/K7cSp74G8ecYolmgUWw0RwN02tF56npup/+qaI8JB97hQgS/r2Hb6QwVA==} + '@next/env@16.2.11': + resolution: {integrity: sha512-0do5A3BJ2gxWr0ZCMcD6BhW+e595jyxdTl3rXTS6lOtD8ektMiW6CO+EPwt1Eca1DBnm90r/7GdiKWBKxH++DA==} - '@next/swc-darwin-arm64@16.2.10': - resolution: {integrity: sha512-v9IdJCa0H0mbo+8z5zwUpOk1Vj7RjkcI5uNYf5Ws1y6szf/p3Mzl9hLaST8SCt6L9h8NGnruZcd2+o0NTNwDhA==} + '@next/swc-darwin-arm64@16.2.11': + resolution: {integrity: sha512-wryL4pjKmDwGv2ox6+GZDFxvmtSRLqApBR8kL1j4+vhB7Z5vJC/zAnXpiR9Xkfzl0AS8WLMnsuGV/UKI67/rrw==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@next/swc-darwin-x64@16.2.10': - resolution: {integrity: sha512-17IS0jJRViROGmA9uGdNR8VPJpfbnaVG7E9qhso5jDLkmyd0lSDORWxbcKINzcFqzZqGwGtMSnrFRxBpuUYjLQ==} + '@next/swc-darwin-x64@16.2.11': + resolution: {integrity: sha512-aZl2j4f/fLyjQvOhv0Oe9UaMAQHolYpKhctsoYzplSumKJKPUmgjcf6545aBtysLTcu994TREd0+pSgNE4ohmg==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@next/swc-linux-arm64-gnu@16.2.10': - resolution: {integrity: sha512-GRQRsRtuciNJvB54AvvuQTiq0oZtFwa1owQqtZD8wwnGpM2L39MV22kpI72YSXLKIyY40LC66EiLFv4PiicXxg==} + '@next/swc-linux-arm64-gnu@16.2.11': + resolution: {integrity: sha512-5jEriyEnH/LWFy27L2ZG0XaLlyEJIjhsImEsiS9P563PKEVp2BVups/xfOucIrsvVntp11oNcZwjHvaDPYVB5g==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [glibc] - '@next/swc-linux-arm64-musl@16.2.10': - resolution: {integrity: sha512-zkN9MQYS7UQBro+FnISUq1itaQjXI9xqISzuQ+2bc921NcJ1x4yPCqrn77tVN6/dOOXaaWVX3k6/bR07pPwK+A==} + '@next/swc-linux-arm64-musl@16.2.11': + resolution: {integrity: sha512-eIjcpx2fnnFSSkZDbTxy74KnokUXDjfoLClpWelfgHLf621aTqswhwXQ7GkD5K5rplrS6LZ/Bj+mVuvzluBOEg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] libc: [musl] - '@next/swc-linux-x64-gnu@16.2.10': - resolution: {integrity: sha512-iCVJnwvrPYECvA6WM/7+oo+OiTvedIKLxtCLAZP4xZR3nXa1zmzZyLPbYCmWvpd4CvMYF1EMTafd0ii3DygLvA==} + '@next/swc-linux-x64-gnu@16.2.11': + resolution: {integrity: sha512-8WgzpaWMs46qJT9kiV47cje86L0x/Mu9t8/Gwj+pnbgW3rETVfCnaScPjlYUwNScpOozdcIMHWmAvuZJUonR2w==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [glibc] - '@next/swc-linux-x64-musl@16.2.10': - resolution: {integrity: sha512-ov2g4H0dHY9bPoOU83m91hWT7Iq5qy13bUnyyshLU3HGR1Ownn0X9QpmDPc5iIUaahTp7f7LeGAhV4DSFtackw==} + '@next/swc-linux-x64-musl@16.2.11': + resolution: {integrity: sha512-I3UgPds7G4ZYnTb/H+5GBGuUT2DhAk6j0mL6A4s63RjFs74wB2hOWP0vaxsK+3NJraExt3eYEPQ/UtT0x/64Nw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] libc: [musl] - '@next/swc-win32-arm64-msvc@16.2.10': - resolution: {integrity: sha512-DwAnhLX76HQiFFQNgWlcK+JzlnD1rZ+UK/WY0ZMI/deXpvgnesjNYrqcfo1JzBuz4Kf7o3brIBL0glI1junatA==} + '@next/swc-win32-arm64-msvc@16.2.11': + resolution: {integrity: sha512-n89CjtcThnjrwgJMAiI5xbqwLY51zvwC9tSlArmVndAJLYVl9T9UAdlkXTmZvE++idoXe8KdglQlhNRdUp1c6g==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@next/swc-win32-x64-msvc@16.2.10': - resolution: {integrity: sha512-0JXq3b85Jk9Jg4ntLUbXSPvoDw3gpZou7twuKdoFG2jOw635v7+IiXfTaa0TxVMyx78pUjnrVYwLgjKfX4e6/A==} + '@next/swc-win32-x64-msvc@16.2.11': + resolution: {integrity: sha512-md8CLNggS1Dx9pUgApzps5uAf+N8GN9xywzmNx9vHAWo94HtBwCCqkSnhIrdfQe83Dhz8Lfo/20Nb1Zxal092w==} engines: {node: '>= 10'} cpu: [x64] os: [win32] @@ -5556,8 +5552,8 @@ packages: react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc - next@16.2.10: - resolution: {integrity: sha512-2som5AVXb3kE6Yjine3/mNbBayYF58eguBWIVVUdr1y/L426xyVEgYxgBG+1QC34P2x5E+tcDup6XkuOAX3dCA==} + next@16.2.11: + resolution: {integrity: sha512-B339zaqbyK8cmxhoAvLrcwoabwCP1wz21zSzfqxqXAemTu2BXnH7tQnfcglKv1vnMUIDBc+Hth7XODQriTZiRQ==} engines: {node: '>=20.9.0'} hasBin: true peerDependencies: @@ -5813,12 +5809,8 @@ packages: points-on-path@0.2.1: resolution: {integrity: sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==} - postcss@8.5.10: - resolution: {integrity: sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==} - engines: {node: ^10 || ^12 || >=14} - - postcss@8.5.15: - resolution: {integrity: sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==} + postcss@8.5.18: + resolution: {integrity: sha512-xdB1oSLHbz1vRWgCDalrCqEFTWzFlhqFC5tIHLMOSUIjhm3XXQ1qrFy8S/ESr1JYRRXqM3c1QFiMZUJdUTqyMQ==} engines: {node: ^10 || ^12 || >=14} postgres-array@2.0.0: @@ -7015,12 +7007,12 @@ snapshots: - react - react-dom - '@clerk/nextjs@7.5.19(next@16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react-dom@19.2.7(react@19.2.7))(react@19.2.7)': + '@clerk/nextjs@7.5.19(next@16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react-dom@19.2.7(react@19.2.7))(react@19.2.7)': dependencies: '@clerk/backend': 3.11.6(react-dom@19.2.7(react@19.2.7))(react@19.2.7) '@clerk/react': 6.12.4(react-dom@19.2.7(react@19.2.7))(react@19.2.7) '@clerk/shared': 4.25.4(react-dom@19.2.7(react@19.2.7))(react@19.2.7) - next: 16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + next: 16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) react: 19.2.7 react-dom: 19.2.7(react@19.2.7) server-only: 0.0.1 @@ -7792,30 +7784,30 @@ snapshots: '@tybys/wasm-util': 0.10.2 optional: true - '@next/env@16.2.10': {} + '@next/env@16.2.11': {} - '@next/swc-darwin-arm64@16.2.10': + '@next/swc-darwin-arm64@16.2.11': optional: true - '@next/swc-darwin-x64@16.2.10': + '@next/swc-darwin-x64@16.2.11': optional: true - '@next/swc-linux-arm64-gnu@16.2.10': + '@next/swc-linux-arm64-gnu@16.2.11': optional: true - '@next/swc-linux-arm64-musl@16.2.10': + '@next/swc-linux-arm64-musl@16.2.11': optional: true - '@next/swc-linux-x64-gnu@16.2.10': + '@next/swc-linux-x64-gnu@16.2.11': optional: true - '@next/swc-linux-x64-musl@16.2.10': + '@next/swc-linux-x64-musl@16.2.11': optional: true - '@next/swc-win32-arm64-msvc@16.2.10': + '@next/swc-win32-arm64-msvc@16.2.11': optional: true - '@next/swc-win32-x64-msvc@16.2.10': + '@next/swc-win32-x64-msvc@16.2.11': optional: true '@noble/curves@1.9.7': @@ -9059,7 +9051,7 @@ snapshots: '@alloc/quick-lru': 5.2.0 '@tailwindcss/node': 4.3.2 '@tailwindcss/oxide': 4.3.2 - postcss: 8.5.15 + postcss: 8.5.18 tailwindcss: 4.3.2 '@tanstack/query-core@5.101.2': {} @@ -10323,9 +10315,9 @@ snapshots: transitivePeerDependencies: - supports-color - geist@1.7.2(next@16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)): + geist@1.7.2(next@16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7)): dependencies: - next: 16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + next: 16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) gensync@1.0.0-beta.2: {} @@ -11583,25 +11575,25 @@ snapshots: react: 19.2.7 react-dom: 19.2.7(react@19.2.7) - next@16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7): + next@16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7): dependencies: - '@next/env': 16.2.10 + '@next/env': 16.2.11 '@swc/helpers': 0.5.15 baseline-browser-mapping: 2.10.37 caniuse-lite: 1.0.30001799 - postcss: 8.5.10 + postcss: 8.5.18 react: 19.2.7 react-dom: 19.2.7(react@19.2.7) styled-jsx: 5.1.6(@babel/core@7.29.7(supports-color@10.2.2))(babel-plugin-macros@3.1.0)(react@19.2.7) optionalDependencies: - '@next/swc-darwin-arm64': 16.2.10 - '@next/swc-darwin-x64': 16.2.10 - '@next/swc-linux-arm64-gnu': 16.2.10 - '@next/swc-linux-arm64-musl': 16.2.10 - '@next/swc-linux-x64-gnu': 16.2.10 - '@next/swc-linux-x64-musl': 16.2.10 - '@next/swc-win32-arm64-msvc': 16.2.10 - '@next/swc-win32-x64-msvc': 16.2.10 + '@next/swc-darwin-arm64': 16.2.11 + '@next/swc-darwin-x64': 16.2.11 + '@next/swc-linux-arm64-gnu': 16.2.11 + '@next/swc-linux-arm64-musl': 16.2.11 + '@next/swc-linux-x64-gnu': 16.2.11 + '@next/swc-linux-x64-musl': 16.2.11 + '@next/swc-win32-arm64-msvc': 16.2.11 + '@next/swc-win32-x64-msvc': 16.2.11 '@opentelemetry/api': 1.9.1 sharp: 0.35.0 transitivePeerDependencies: @@ -11634,12 +11626,12 @@ snapshots: nullthrows@1.1.1: {} - nuqs@2.9.0(next@16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react@19.2.7): + nuqs@2.9.0(next@16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7))(react@19.2.7): dependencies: '@standard-schema/spec': 1.0.0 react: 19.2.7 optionalDependencies: - next: 16.2.10(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) + next: 16.2.11(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(babel-plugin-macros@3.1.0)(react-dom@19.2.7(react@19.2.7))(react@19.2.7) ob1@0.84.4: dependencies: @@ -11843,13 +11835,7 @@ snapshots: path-data-parser: 0.1.0 points-on-curve: 0.2.0 - postcss@8.5.10: - dependencies: - nanoid: 3.3.12 - picocolors: 1.1.1 - source-map-js: 1.2.1 - - postcss@8.5.15: + postcss@8.5.18: dependencies: nanoid: 3.3.12 picocolors: 1.1.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 382ed7d0..59eacc4e 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -56,7 +56,7 @@ overrides: 'minimatch@>=10.0.0 <10.2.3': 10.2.5 'path-to-regexp@>=6.0.0 <6.3.0': 6.3.0 'path-to-regexp@>=8.0.0 <8.4.0': 8.4.2 - 'postcss@<8.5.10': 8.5.10 + 'postcss@<8.5.18': 8.5.18 'sharp@<0.35.0': 0.35.0 'smol-toml@<1.6.1': 1.6.1 'tar@>=7.0.0 <7.5.11': 7.5.20 @@ -93,7 +93,7 @@ catalog: '@hookform/resolvers': 5.4.0 '@google/genai': 2.12.0 '@mastra/core': 1.51.0 - '@next/env': 16.2.10 + '@next/env': 16.2.11 '@openrouter/ai-sdk-provider': 2.9.1 '@polar-sh/sdk': 0.48.1 '@streamdown/code': 1.1.1 @@ -119,7 +119,7 @@ catalog: knip: 6.27.0 lefthook: 2.1.10 lucide-react: 1.24.0 - next: 16.2.10 + next: 16.2.11 next-themes: 0.4.6 nuqs: 2.9.0 pg: 8.22.0 diff --git a/scripts/archive-audit-log.ts b/scripts/archive-audit-log.ts index c3954b46..ad3c6e40 100644 --- a/scripts/archive-audit-log.ts +++ b/scripts/archive-audit-log.ts @@ -679,7 +679,7 @@ async function runArchive(options: ArchiveOptions): Promise { await acquireDatabaseMaintenanceLock(client, "audit archive"); hasMaintenanceLock = true; await ensureFuturePartitions(client, options); - await assertSupabaseTarget(client, "prod-ready"); + await assertSupabaseTarget(client); validateManifestCatalog(await loadArchiveManifest(client), await loadCatalogPartitions(client)); if (options.mode === "dry-run") { await printArchivePlan(client, options); diff --git a/scripts/migrate.ts b/scripts/migrate.ts index e1c8a748..ca876a86 100644 --- a/scripts/migrate.ts +++ b/scripts/migrate.ts @@ -1,9 +1,7 @@ -import { createHash } from "node:crypto"; -import { readdir, readFile } from "node:fs/promises"; +import { readFile } from "node:fs/promises"; import { createRequire } from "node:module"; -import { dirname, join, relative, resolve } from "node:path"; +import { dirname, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; -import { z } from "zod"; import { type DrizzleMigrationClient, runDrizzleMigrations, @@ -18,7 +16,6 @@ import { releaseDatabaseMaintenanceLock, } from "./database-operation-safety"; import { - assertExpandOnlyDrizzleMigrations, type DrizzleMigration, loadDrizzleMigrations, verifyDrizzleMigrationIntegrity, @@ -28,196 +25,27 @@ import { loadMigrationEnvFromFiles } from "./migration-env"; interface PgModule { Client: new (config: { connectionString: string }) => DrizzleMigrationClient; } -type Mode = "apply" | "dry-run"; -type ApplyMigrationPhase = "post-deploy" | "pre-deploy" | "release-finalization"; -type MigrationPhase = "all" | ApplyMigrationPhase; -interface MigrationOptions { - mode: Mode; - phase: MigrationPhase; -} -interface MigrationFiles { - contractions: string[]; - drizzle: DrizzleMigration[]; - expansions: string[]; - finalizations: string[]; - foundations: string[]; - post: string[]; - retired: Map; -} -type RawMigrationLedger = Map; -type RawMigrationPhaseMap = Map; -type RawMigrationAttestations = ReadonlyMap; -const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), ".."); -const PRE_DIR = join(ROOT, "infra/supabase/migrations/pre"); -const POST_DIR = join(ROOT, "infra/supabase/migrations/post"); -const RETIRED_RAW_PATH = join(ROOT, "infra/supabase/migrations/retired-raw.json"); -const RAW_PHASES_PATH = join(ROOT, "infra/supabase/migrations/raw-phases.json"); -const FIRST_PHASE_ENFORCED_RAW_INDEX = 28; -const RAW_MIGRATION_PATH_PATTERN = - /^infra\/supabase\/migrations\/(?:pre|post)\/\d{4}_[a-z0-9_]+\.sql$/; -const SHA256_PATTERN = /^[0-9a-f]{64}$/; -const MIGRATION_ATTESTATION_SETTING = "cheatcode.migration_attestation"; -const MIGRATION_SHA256_SETTING = "cheatcode.migration_sha256"; -const V1_REMOVAL_MIGRATION = "infra/supabase/migrations/post/0046_remove_v1_database_surface.sql"; -const MigrationAttestationEnvelopeSchema = z - .object({ - "v1-external-cleanup": z.record(z.string(), z.unknown()).optional(), - }) - .strict(); +type MigrationMode = "apply" | "dry-run"; +const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), ".."); const writeLine = (line = ""): void => void process.stdout.write(`${line}\n`); -function parseOptions(argv: string[]): MigrationOptions { - if (argv.includes("--help")) { - writeLine( - "Usage: pnpm tsx scripts/migrate.ts [--dry-run|--apply] [--phase=all|pre-deploy|post-deploy|release-finalization]", - ); +function parseMode(argv: string[]): MigrationMode { + const args = argv.filter((argument) => argument !== "--"); + if (args.includes("--help")) { + writeLine("Usage: pnpm db:migrate [--dry-run|--apply]"); process.exit(0); } - const hasApply = argv.includes("--apply"); - const hasDryRun = argv.includes("--dry-run"); - if (hasApply && hasDryRun) { - throw new Error("Pass only one of --apply or --dry-run."); - } - const known = new Set(["--apply", "--dry-run"]); - const phaseArguments = argv.filter((argument) => argument.startsWith("--phase=")); - const unknown = argv.find((argument) => !known.has(argument) && !argument.startsWith("--phase=")); + const allowed = new Set(["--apply", "--dry-run"]); + const unknown = args.find((argument) => !allowed.has(argument)); if (unknown) { throw new Error(`Unknown migration option: ${unknown}`); } - if (phaseArguments.length > 1) { - throw new Error("Pass --phase only once."); - } - if ( - argv.filter((argument) => argument === "--apply").length > 1 || - (hasDryRun && argv.filter((argument) => argument === "--dry-run").length > 1) - ) { - throw new Error("Pass the migration mode only once."); + if (args.length > 1 || (args.includes("--apply") && args.includes("--dry-run"))) { + throw new Error("Pass exactly one migration mode."); } - const phaseArgument = phaseArguments[0]; - const phaseValue = phaseArgument?.slice("--phase=".length) ?? "all"; - if ( - phaseValue !== "all" && - phaseValue !== "pre-deploy" && - phaseValue !== "post-deploy" && - phaseValue !== "release-finalization" - ) { - throw new Error(`Invalid migration phase: ${phaseValue}`); - } - return { - mode: hasApply ? "apply" : "dry-run", - phase: phaseValue, - }; -} - -async function sqlFiles(dir: string): Promise { - const entries = await readdir(dir, { withFileTypes: true }); - return entries - .filter((entry) => entry.isFile() && entry.name.endsWith(".sql")) - .map((entry) => join(dir, entry.name)) - .sort((a, b) => a.localeCompare(b)); -} - -async function stringRecord(file: string, label: string): Promise> { - const parsed: unknown = JSON.parse(await readFile(file, "utf8")); - if (!isRecord(parsed)) { - throw new Error(`${label} must be a JSON object.`); - } - const entries = new Map(); - for (const [key, value] of Object.entries(parsed)) { - if (!RAW_MIGRATION_PATH_PATTERN.test(key) || typeof value !== "string") { - throw new Error(`${label} contains an invalid entry for ${key}.`); - } - entries.set(key, value); - } - return entries; -} - -async function retiredRawMigrations(): Promise> { - const retired = await stringRecord(RETIRED_RAW_PATH, "Retired raw migration manifest"); - for (const [filename, checksum] of retired) { - if (!SHA256_PATTERN.test(checksum)) { - throw new Error(`Retired raw migration has an invalid checksum: ${filename}`); - } - } - return retired; -} - -async function rawMigrationPhases(postFiles: string[]): Promise { - const configured = await stringRecord(RAW_PHASES_PATH, "Raw migration phase manifest"); - const sourceNames = new Set(postFiles.map((file) => relative(ROOT, file))); - const unknown = [...configured.keys()].filter((filename) => !sourceNames.has(filename)); - const missing = [...sourceNames].filter((filename) => !configured.has(filename)); - if (unknown.length || missing.length) { - throw new Error( - [ - unknown.length ? `phase entries without source: ${unknown.join(", ")}` : "", - missing.length ? `post migrations without a phase: ${missing.join(", ")}` : "", - ] - .filter(Boolean) - .join("; "), - ); - } - const phases: RawMigrationPhaseMap = new Map(); - for (const [filename, phase] of configured) { - if (phase !== "pre-deploy" && phase !== "post-deploy" && phase !== "release-finalization") { - throw new Error(`Raw migration has an invalid phase: ${filename}`); - } - phases.set(filename, phase); - } - return phases; -} - -function assertUniqueRawMigrationIndexes( - files: readonly string[], - retired: ReadonlyMap, -): void { - const identities = new Map(); - for (const filename of [...files.map((file) => relative(ROOT, file)), ...retired.keys()]) { - const match = /^(infra\/supabase\/migrations\/(?:pre|post))\/(\d{4})_/.exec(filename); - if (!match) { - throw new Error(`Invalid raw migration filename: ${filename}`); - } - const identity = `${match[1]}/${match[2]}`; - const existing = identities.get(identity); - if (existing) { - throw new Error(`Raw migration index reused by ${existing} and ${filename}.`); - } - identities.set(identity, filename); - } -} - -async function assertExpandOnlyRawMigrations(files: readonly string[]): Promise { - for (const file of files) { - const index = Number.parseInt(file.split("/").at(-1)?.slice(0, 4) ?? "", 10); - if (!Number.isInteger(index) || index < FIRST_PHASE_ENFORCED_RAW_INDEX) { - continue; - } - const sql = stripFunctionBodies(stripSqlComments(await readFile(file, "utf8"))); - if (IRREVERSIBLE_SQL_PATTERN.test(sql)) { - throw new Error( - `Pre-deploy raw migration must be expand-only: ${relative(ROOT, file)}. Classify irreversible contractions as post-deploy.`, - ); - } - } -} - -function isRecord(value: unknown): value is Record { - return typeof value === "object" && value !== null && !Array.isArray(value); -} - -function parseRawMigrationAttestations(raw: string | undefined): RawMigrationAttestations { - if (!raw) return new Map(); - let decoded: unknown; - try { - decoded = JSON.parse(raw); - } catch { - throw new Error("CHEATCODE_MIGRATION_ATTESTATIONS must contain valid JSON."); - } - const envelope = MigrationAttestationEnvelopeSchema.parse(decoded); - const cleanup = envelope["v1-external-cleanup"]; - return cleanup ? new Map([[V1_REMOVAL_MIGRATION, JSON.stringify(cleanup)]]) : new Map(); + return args.includes("--apply") ? "apply" : "dry-run"; } function createClient(databaseUrl: string): DrizzleMigrationClient { @@ -226,143 +54,12 @@ function createClient(databaseUrl: string): DrizzleMigrationClient { return new Client({ connectionString: databaseUrl }); } -async function ensureRawLedger(client: PgClient): Promise { - await client.query( - `create table if not exists public._raw_migrations ( - filename text primary key, - sha256 text not null - constraint _raw_migrations_sha256_check check (sha256 ~ '^[0-9a-f]{64}$'), - applied_at timestamptz not null default now() - )`, - ); -} - -async function assertRawLedgerShape(client: PgClient, allowMissing: boolean): Promise { - const result = await client.query( - `select - to_regclass('public._raw_migrations') is not null as table_exists, - exists ( - select 1 from information_schema.columns - where table_schema = 'public' - and table_name = '_raw_migrations' - and column_name = 'sha256' - and data_type = 'text' - and is_nullable = 'NO' - ) as checksum_valid_shape, - exists ( - select 1 from pg_constraint - where conrelid = to_regclass('public._raw_migrations') - and conname = '_raw_migrations_sha256_check' - and convalidated - ) as checksum_constraint_validated`, - ); - const row = result.rows[0]; - if (row?.["table_exists"] !== true && allowMissing) { - return; - } - if ( - row?.["table_exists"] !== true || - row["checksum_valid_shape"] !== true || - row["checksum_constraint_validated"] !== true - ) { - throw new Error("Raw migration ledger must have a required, validated SHA-256 identity."); - } -} - -async function appliedRawMigrations(client: PgClient): Promise { - try { - const result = await client.query("select filename, sha256 from public._raw_migrations"); - const applied: RawMigrationLedger = new Map(); - for (const row of result.rows) { - const filename = String(row["filename"]); - const checksum = row["sha256"]; - if (typeof checksum !== "string" || !SHA256_PATTERN.test(checksum)) { - throw new Error(`Applied raw migration has no valid checksum: ${filename}`); - } - applied.set(filename, checksum); - } - return applied; - } catch (error) { - if (isUndefinedTable(error)) { - return new Map(); - } - throw error; - } -} - -function isUndefinedTable(error: unknown): boolean { - return pgErrorCode(error) === "42P01"; -} - -function pgErrorCode(error: unknown): string | undefined { - if (typeof error !== "object" || error === null || !("code" in error)) { - return undefined; - } - const code = (error as { code?: unknown }).code; - return typeof code === "string" ? code : undefined; -} - -async function fileChecksum(file: string): Promise { - return createHash("sha256") - .update(await readFile(file)) - .digest("hex"); -} - -async function applyRawFile( - client: PgClient, - file: string, - attestations: RawMigrationAttestations, -): Promise { - const filename = relative(ROOT, file); - const sql = await readFile(file, "utf8"); - const sha256 = await fileChecksum(file); - await client.query("begin"); - try { - const attestation = attestations.get(filename); - if (attestation) { - await client.query("select set_config($1, $2, true)", [ - MIGRATION_ATTESTATION_SETTING, - attestation, - ]); - await client.query("select set_config($1, $2, true)", [MIGRATION_SHA256_SETTING, sha256]); - } - await client.query(sql); - await client.query("insert into public._raw_migrations (filename, sha256) values ($1, $2)", [ - filename, - sha256, - ]); - await client.query("commit"); - } catch (error) { - await client.query("rollback"); - throw error; - } -} - -async function applyRawPhase( - client: PgClient, - title: string, - files: string[], - attestations: RawMigrationAttestations, -): Promise { - const applied = await appliedRawMigrations(client); - for (const file of files) { - const filename = relative(ROOT, file); - if (applied.has(filename)) { - writeLine(`skip ${title}: ${filename}`); - continue; - } - writeLine(`apply ${title}: ${filename}`); - await applyRawFile(client, file, attestations); - } -} - -async function runDrizzleMigrate( - client: DrizzleMigrationClient, +async function loadPendingPlans( migrations: readonly DrizzleMigration[], -): Promise { - const applied = await verifyDrizzleMigrationIntegrity(client, migrations, writeLine); + applied: ReadonlySet, +) { const pending = migrations.filter((migration) => !applied.has(migration.file)); - const plans = await Promise.all( + return Promise.all( pending.map(async (migration) => ({ checksum: migration.checksum, file: migration.file, @@ -372,103 +69,39 @@ async function runDrizzleMigrate( when: migration.when, })), ); - await runDrizzleMigrations(client, plans, writeLine); } -async function printPlan( - client: PgClient, - foundations: string[], - expansions: string[], - contractions: string[], - finalizations: string[], - phase: MigrationPhase, - drizzle: readonly DrizzleMigration[], - appliedDrizzle: ReadonlySet, +async function executeMigration( + client: DrizzleMigrationClient, + mode: MigrationMode, ): Promise { - const applied = await appliedRawMigrations(client); - writeLine("Migration plan:"); - if (phase === "all" || phase === "pre-deploy") { - printRawPlan("Phase 1 raw foundations", foundations, applied); - writeLine("Phase 2 Drizzle expansions"); - for (const migration of drizzle) { - const state = appliedDrizzle.has(migration.file) ? "applied" : "pending"; - writeLine(` ${state} ${migration.file}`); - } - printRawPlan("Phase 3 raw expansions and security overlays", expansions, applied); - } - if (phase === "all" || phase === "post-deploy") { - printRawPlan("Phase 4 post-deploy contractions", contractions, applied); - } - if (phase === "all" || phase === "release-finalization") { - printRawPlan("Phase 5 release finalization", finalizations, applied); - } -} + const migrations = await loadDrizzleMigrations(); + const applied = await verifyDrizzleMigrationIntegrity(client, migrations); + const pending = migrations.filter((migration) => !applied.has(migration.file)); -function printRawPlan(title: string, files: string[], applied: RawMigrationLedger): void { - writeLine(title); - for (const file of files) { - const filename = relative(ROOT, file); - const state = applied.has(filename) ? "applied" : "pending"; - writeLine(` ${state} ${filename}`); + writeLine("Migration plan:"); + for (const migration of migrations) { + writeLine(` ${applied.has(migration.file) ? "applied" : "pending"} ${migration.file}`); } -} -async function assertRawApplyOrder( - client: PgClient, - groups: ReadonlyArray, -): Promise { - const applied = await appliedRawMigrations(client); - for (const files of groups) { - // Expansion and contraction indexes interleave across release waves; only - // each phase stream is append-only. - let firstPending: string | undefined; - for (const file of files) { - const filename = relative(ROOT, file); - if (!applied.has(filename)) { - firstPending ??= filename; - } else if (firstPending) { - throw new Error(`Raw migration ${filename} was applied before ${firstPending}.`); - } + if (mode === "dry-run") { + if (pending.length === 0) { + await assertSupabaseTarget(client); + writeLine("Production schema contract verified."); } + return; } -} - -async function assertPreDeployComplete( - client: PgClient, - foundations: readonly string[], - expansions: readonly string[], - drizzle: readonly DrizzleMigration[], -): Promise { - const raw = await appliedRawMigrations(client); - const missingRaw = [...foundations, ...expansions] - .map((file) => relative(ROOT, file)) - .filter((filename) => !raw.has(filename)); - const appliedDrizzle = await verifyDrizzleMigrationIntegrity(client, drizzle, writeLine); - const missingDrizzle = drizzle - .map((migration) => migration.file) - .filter((filename) => !appliedDrizzle.has(filename)); - if (missingRaw.length > 0 || missingDrizzle.length > 0) { - throw new Error( - `Post-deploy contractions require a complete pre-deploy phase: missing ${[...missingRaw, ...missingDrizzle].join(", ")}.`, - ); - } -} -async function assertRawPhaseComplete( - client: PgClient, - files: readonly string[], - requiredPhase: string, -): Promise { - const applied = await appliedRawMigrations(client); - const missing = files - .map((file) => relative(ROOT, file)) - .filter((filename) => !applied.has(filename)); - if (missing.length > 0) { - throw new Error(`${requiredPhase} is incomplete: missing ${missing.join(", ")}.`); + await runDrizzleMigrations(client, await loadPendingPlans(migrations, applied), writeLine); + const finalLedger = await verifyDrizzleMigrationIntegrity(client, migrations); + if (finalLedger.size !== migrations.length) { + throw new Error("Migration runner returned before applying the complete journal."); } + await assertSupabaseTarget(client); + writeLine("Production schema contract verified."); } -async function closeMigrationClient( +async function closeClient( client: PgClient, hasMaintenanceLock: boolean, operationFailed: boolean, @@ -500,134 +133,10 @@ function errorMessage(error: unknown, fallback: string): string { return error instanceof Error ? error.message : fallback; } -async function verifyRawMigrationIntegrity( - client: PgClient, - files: string[], - retired: Map, -): Promise { - const applied = await appliedRawMigrations(client); - const sourceFiles = new Set(files.map((file) => relative(ROOT, file))); - assertRawMigrationCoverage(applied, sourceFiles, retired); - const appliedChecksums = await collectAppliedChecksums(files, retired, applied); - assertAppliedChecksums(appliedChecksums, applied); -} - -function assertRawMigrationCoverage( - applied: RawMigrationLedger, - sourceFiles: Set, - retired: Map, -): void { - const overlap = [...retired.keys()].filter((filename) => sourceFiles.has(filename)); - if (overlap.length > 0) { - throw new Error(`Retired raw migrations still exist as executable SQL: ${overlap.join(", ")}`); - } - const missing = [...applied.keys()].filter( - (filename) => !sourceFiles.has(filename) && !retired.has(filename), - ); - if (missing.length > 0) { - throw new Error( - `Applied raw migrations are missing from source and the retired manifest: ${missing.join(", ")}`, - ); - } -} - -async function collectAppliedChecksums( - files: string[], - retired: Map, - applied: RawMigrationLedger, -): Promise> { - const appliedChecksums = new Map(); - for (const file of files) { - const filename = relative(ROOT, file); - if (!applied.has(filename)) { - continue; - } - appliedChecksums.set(filename, await fileChecksum(file)); - } - for (const [filename, checksum] of retired) { - if (applied.has(filename)) { - appliedChecksums.set(filename, checksum); - } - } - return appliedChecksums; -} - -function assertAppliedChecksums( - appliedChecksums: Map, - applied: RawMigrationLedger, -): void { - for (const [filename, actual] of appliedChecksums) { - const expected = applied.get(filename); - if (expected !== actual) { - throw new Error(`Applied raw migration was modified: ${filename}`); - } - } -} - -function stripSqlComments(sql: string): string { - return sql.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/--[^\n]*/g, " "); -} - -function stripFunctionBodies(sql: string): string { - return sql.replace(/\bas\s+(\$[a-z0-9_]*\$)[\s\S]*?\1/gi, " "); -} - -const IRREVERSIBLE_SQL_PATTERN = - /\b(?:delete\s+from|detach\s+partition|drop\s+(?:column|constraint|extension|function|index|materialized\s+view|policy|procedure|schema|sequence|table|trigger|type|view)|rename\s+(?:column|constraint|to)|truncate\s+(?!on\b)|alter\s+column\s+[^;]+\s+(?:drop\s+default|set\s+not\s+null|type\b))/i; - -async function loadMigrationFiles(): Promise { - await assertExpandOnlyDrizzleMigrations(); - const foundations = await sqlFiles(PRE_DIR); - const post = await sqlFiles(POST_DIR); - const phases = await rawMigrationPhases(post); - const expansions = post.filter((file) => phases.get(relative(ROOT, file)) === "pre-deploy"); - const contractions = post.filter((file) => phases.get(relative(ROOT, file)) === "post-deploy"); - const finalizations = post.filter( - (file) => phases.get(relative(ROOT, file)) === "release-finalization", - ); - assertReleaseFinalizationContract(finalizations); - const retired = await retiredRawMigrations(); - assertUniqueRawMigrationIndexes([...foundations, ...post], retired); - await assertExpandOnlyRawMigrations([...foundations, ...expansions]); - const drizzle = await loadDrizzleMigrations(); - return { contractions, drizzle, expansions, finalizations, foundations, post, retired }; -} - -function assertReleaseFinalizationContract(files: readonly string[]): void { - const filenames = files.map((file) => relative(ROOT, file)); - if (filenames.length !== 1 || filenames[0] !== V1_REMOVAL_MIGRATION) { - throw new Error( - `Release finalization must contain only the protected V1 removal migration ${V1_REMOVAL_MIGRATION}.`, - ); - } -} - -async function assertNoLeasedDestructiveJobs(client: PgClient): Promise { - const tables = ["v2_resource_deletion_jobs", "v2_user_deletion_jobs"] as const; - for (const table of tables) { - const relation = await client.query( - `select to_regclass('public.${table}') is not null as table_exists`, - ); - if (relation.rows[0]?.["table_exists"] !== true) { - continue; - } - const leased = await client.query( - `select exists (select 1 from public.${table} where status = 'leased') as has_leased_job`, - ); - if (leased.rows[0]?.["has_leased_job"] === true) { - throw new Error( - `Schema migration cannot run while ${table} has a leased job; finish or release every active lease first.`, - ); - } - } -} - async function runMigration( databaseUrl: string, identity: DatabaseIdentityExpectation, - options: MigrationOptions, - files: MigrationFiles, - rawAttestations: string | undefined, + mode: MigrationMode, ): Promise { const client = createClient(databaseUrl); await client.connect(); @@ -638,125 +147,33 @@ async function runMigration( applicationName: "cheatcode-schema-migration", statementTimeout: "10min", }); - await assertPinnedDatabaseIdentity(client, identity, options.mode); + await assertPinnedDatabaseIdentity(client, identity, mode); await acquireDatabaseMaintenanceLock(client, "schema migration"); hasMaintenanceLock = true; - await assertNoLeasedDestructiveJobs(client); - await executeMigration(client, options, files, rawAttestations); + await executeMigration(client, mode); } catch (error) { operationFailed = true; throw error; } finally { - await closeMigrationClient(client, hasMaintenanceLock, operationFailed); - } -} - -async function executeMigration( - client: DrizzleMigrationClient, - options: MigrationOptions, - files: MigrationFiles, - rawAttestations: string | undefined, -): Promise { - const { contractions, drizzle, expansions, finalizations, foundations, post, retired } = files; - await assertSupabaseTarget(client, "pre-migration"); - if (options.mode === "apply") { - await ensureRawLedger(client); - } - await assertRawLedgerShape(client, options.mode === "dry-run"); - await verifyRawMigrationIntegrity(client, [...foundations, ...post], retired); - await assertRawApplyOrder(client, [foundations, expansions, contractions, finalizations]); - if (options.mode === "dry-run" && options.phase === "release-finalization") { - await assertPreDeployComplete(client, foundations, expansions, drizzle); - await assertRawPhaseComplete(client, contractions, "Post-deploy contraction phase"); - } - const attestations = parseRawMigrationAttestations(rawAttestations); - const appliedDrizzle = await verifyDrizzleMigrationIntegrity(client, drizzle, writeLine); - if (options.mode === "dry-run") { - await printPlan( - client, - foundations, - expansions, - contractions, - finalizations, - options.phase, - drizzle, - appliedDrizzle, - ); - return; - } - await applySelectedPhases(client, options.phase, files, attestations); - await verifyRawMigrationIntegrity(client, [...foundations, ...post], retired); - await assertRawApplyOrder(client, [foundations, expansions, contractions, finalizations]); -} - -async function applySelectedPhases( - client: DrizzleMigrationClient, - phase: MigrationPhase, - files: MigrationFiles, - attestations: RawMigrationAttestations, -): Promise { - if (phase === "pre-deploy") { - await applyRawPhase(client, "raw foundations", files.foundations, attestations); - await runDrizzleMigrate(client, files.drizzle); - const applied = await verifyDrizzleMigrationIntegrity(client, files.drizzle, writeLine); - if (applied.size !== files.drizzle.length) { - throw new Error("Drizzle returned without applying the complete migration journal."); - } - await applyRawPhase(client, "raw expansions", files.expansions, attestations); - await assertPreDeployComplete(client, files.foundations, files.expansions, files.drizzle); - return; - } - if (phase === "post-deploy") { - await assertPreDeployComplete(client, files.foundations, files.expansions, files.drizzle); - await applyRawPhase(client, "post-deploy contractions", files.contractions, attestations); - await assertRawPhaseComplete(client, files.contractions, "Post-deploy contraction phase"); - await assertSupabaseTarget(client, "pre-migration"); - return; - } - if (phase === "release-finalization") { - await assertPreDeployComplete(client, files.foundations, files.expansions, files.drizzle); - await assertRawPhaseComplete(client, files.contractions, "Post-deploy contraction phase"); - await applyRawPhase(client, "release finalization", files.finalizations, attestations); - await assertRawPhaseComplete(client, files.finalizations, "Release finalization phase"); - await assertSupabaseTarget(client, "prod-ready"); - return; + await closeClient(client, hasMaintenanceLock, operationFailed); } - throw new Error("The all-phases migration plan is read-only."); } async function main(): Promise { - const options = parseOptions(process.argv.slice(2)); - if (options.mode === "apply" && options.phase === "all") { - throw new Error( - "Refusing --apply --phase=all. Apply pre-deploy, post-deploy, and release-finalization in separate release gates.", - ); - } - const { - databaseUrl, - expectedDatabase, - expectedHost, - expectedRole, - expectedSystemIdentifier, - migrationAttestations, - } = loadMigrationEnvFromFiles(ROOT); + const mode = parseMode(process.argv.slice(2)); + const { databaseUrl, expectedDatabase, expectedHost, expectedRole, expectedSystemIdentifier } = + loadMigrationEnvFromFiles(ROOT); const identity: DatabaseIdentityExpectation = { ...(expectedDatabase ? { expectedDatabase } : {}), ...(expectedHost ? { expectedHost } : {}), ...(expectedRole ? { expectedRole } : {}), ...(expectedSystemIdentifier ? { expectedSystemIdentifier } : {}), }; - assertAdministrativeConnectionTarget(databaseUrl, identity, options.mode); - await runMigration( - databaseUrl, - identity, - options, - await loadMigrationFiles(), - migrationAttestations, - ); + assertAdministrativeConnectionTarget(databaseUrl, identity, mode); + await runMigration(databaseUrl, identity, mode); } main().catch((error: unknown) => { - const message = error instanceof Error ? error.message : "Unknown migration error"; - process.stderr.write(`${message}\n`); + process.stderr.write(`${errorMessage(error, "Unknown migration error")}\n`); process.exitCode = 1; }); diff --git a/scripts/migration-drizzle.ts b/scripts/migration-drizzle.ts index 9b184420..2511e60d 100644 --- a/scripts/migration-drizzle.ts +++ b/scripts/migration-drizzle.ts @@ -10,12 +10,6 @@ interface DrizzleJournalEntry { when: number; } -interface DrizzleLedgerException { - databaseSha256: string; - reason: string; - sourceSha256: string; -} - export interface DrizzleMigration { checksum: string; file: string; @@ -25,17 +19,7 @@ export interface DrizzleMigration { const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), ".."); const DRIZZLE_DIR = join(ROOT, "packages/db/drizzle"); const DRIZZLE_JOURNAL_PATH = join(DRIZZLE_DIR, "meta/_journal.json"); -const DRIZZLE_LEDGER_EXCEPTIONS_PATH = join( - ROOT, - "infra/supabase/migrations/drizzle-ledger-exceptions.json", -); -const FIRST_EXPAND_ONLY_DRIZZLE_INDEX = 18; const SHA256_PATTERN = /^[0-9a-f]{64}$/; -const DESTRUCTIVE_SQL_PATTERN = - /\b(?:delete\s+from|detach\s+partition|drop\s+(?:column|constraint|extension|function|index|materialized\s+view|policy|procedure|schema|sequence|table|trigger|type|view)|rename\s+(?:column|constraint|to)|revoke\b|truncate\b|alter\s+column\s+[^;]+\s+(?:drop\s+default|set\s+not\s+null|type\b))/i; -const USER_DELETION_GENERATION_PRECISION_WIDENING = - 'ALTER TABLE "v2_user_deletion_jobs" ALTER COLUMN "generation" SET DATA TYPE timestamp with time zone;'; -const USER_DELETION_GENERATION_PRECISION_MIGRATION = "packages/db/drizzle/0043_third_sleeper.sql"; export async function loadDrizzleMigrations(): Promise { const parsed: unknown = JSON.parse(await readFile(DRIZZLE_JOURNAL_PATH, "utf8")); @@ -46,6 +30,7 @@ export async function loadDrizzleMigrations(): Promise { ) { throw new Error("Drizzle migration journal is invalid."); } + const entries = parsed["entries"].map(parseDrizzleJournalEntry); assertDrizzleJournalSequence(entries); const files = await sqlFiles(DRIZZLE_DIR); @@ -57,6 +42,7 @@ export async function loadDrizzleMigrations(): Promise { `Drizzle journal/source mismatch: missing=${paths(missing)}; unexpected=${paths(unexpected)}.`, ); } + return Promise.all( entries.map(async (entry) => ({ checksum: await fileChecksum(join(DRIZZLE_DIR, `${entry.tag}.sql`)), @@ -66,110 +52,26 @@ export async function loadDrizzleMigrations(): Promise { ); } -function paths(files: readonly string[]): string { - return files.map((file) => relative(ROOT, file)).join(", ") || "none"; -} - -function parseDrizzleJournalEntry(value: unknown, position: number): DrizzleJournalEntry { - if (!isRecord(value)) { - throw new Error(`Drizzle journal entry ${position} is invalid.`); - } - const { idx, tag, when } = value; - if ( - typeof idx !== "number" || - !Number.isSafeInteger(idx) || - typeof when !== "number" || - !Number.isSafeInteger(when) || - typeof tag !== "string" || - !/^\d{4}_[a-z0-9_]+$/.test(tag) - ) { - throw new Error(`Drizzle journal entry ${position} has invalid identity fields.`); - } - return { idx, tag, when }; -} - -function assertDrizzleJournalSequence(entries: readonly DrizzleJournalEntry[]): void { - for (const [position, entry] of entries.entries()) { - if (entry.idx !== position || Number(entry.tag.slice(0, 4)) !== entry.idx) { - throw new Error(`Drizzle journal must be contiguous; invalid entry ${entry.tag}.`); - } - const previous = entries[position - 1]; - if (previous && previous.when >= entry.when) { - throw new Error(`Drizzle journal timestamps must increase; invalid entry ${entry.tag}.`); - } - } -} - export async function verifyDrizzleMigrationIntegrity( client: PgClient, migrations: readonly DrizzleMigration[], - report: (message: string) => void, ): Promise> { - const exceptions = await loadDrizzleLedgerExceptions(); - assertDrizzleExceptionSources(migrations, exceptions); - const result = await loadAppliedDrizzleMigrations(client); - if (result.length > migrations.length) { - throw new Error("Database contains more Drizzle migrations than the source journal."); + const applied = await loadAppliedDrizzleMigrations(client); + if (applied.length > migrations.length) { + throw new Error("Database contains more migrations than the source journal."); } + const appliedFiles = new Set(); - for (const [position, row] of result.entries()) { + for (const [position, row] of applied.entries()) { const migration = migrations[position]; - if (!migration || row.createdAt !== migration.when) { - throw new Error(`Drizzle ledger is not a contiguous source prefix at ${row.createdAt}.`); + if (!migration || row.createdAt !== migration.when || row.hash !== migration.checksum) { + throw new Error(`Migration ledger diverges from source at position ${position}.`); } - assertDrizzleChecksum(migration, row.hash, exceptions.get(migration.file), report); appliedFiles.add(migration.file); } return appliedFiles; } -async function loadDrizzleLedgerExceptions(): Promise> { - const parsed: unknown = JSON.parse(await readFile(DRIZZLE_LEDGER_EXCEPTIONS_PATH, "utf8")); - if (!isRecord(parsed)) { - throw new Error("Drizzle ledger exception manifest must be an object."); - } - const exceptions = new Map(); - for (const [filename, value] of Object.entries(parsed)) { - if (!/^packages\/db\/drizzle\/\d{4}_[a-z0-9_]+\.sql$/.test(filename)) { - throw new Error(`Invalid Drizzle ledger exception path: ${filename}`); - } - exceptions.set(filename, parseDrizzleLedgerException(filename, value)); - } - return exceptions; -} - -function parseDrizzleLedgerException(filename: string, value: unknown): DrizzleLedgerException { - if (!isRecord(value)) { - throw new Error(`Invalid Drizzle ledger exception: ${filename}`); - } - const databaseSha256 = value["databaseSha256"]; - const sourceSha256 = value["sourceSha256"]; - const reason = value["reason"]; - if ( - typeof databaseSha256 !== "string" || - !SHA256_PATTERN.test(databaseSha256) || - typeof sourceSha256 !== "string" || - !SHA256_PATTERN.test(sourceSha256) || - typeof reason !== "string" || - reason.trim().length < 20 - ) { - throw new Error(`Invalid Drizzle ledger exception details: ${filename}`); - } - return { databaseSha256, reason, sourceSha256 }; -} - -function assertDrizzleExceptionSources( - migrations: readonly DrizzleMigration[], - exceptions: ReadonlyMap, -): void { - const sources = new Map(migrations.map((migration) => [migration.file, migration.checksum])); - for (const [filename, exception] of exceptions) { - if (sources.get(filename) !== exception.sourceSha256) { - throw new Error(`Drizzle ledger exception source identity mismatch: ${filename}`); - } - } -} - async function loadAppliedDrizzleMigrations( client: PgClient, ): Promise> { @@ -181,7 +83,7 @@ async function loadAppliedDrizzleMigrations( const hash = row["hash"]; const createdAt = row["created_at"]; if (typeof hash !== "string" || !SHA256_PATTERN.test(hash) || typeof createdAt !== "string") { - throw new Error(`Drizzle ledger row ${position} is invalid.`); + throw new Error(`Migration ledger row ${position} is invalid.`); } return { createdAt, hash }; }); @@ -193,51 +95,36 @@ async function loadAppliedDrizzleMigrations( } } -function assertDrizzleChecksum( - migration: DrizzleMigration, - databaseChecksum: string, - exception: DrizzleLedgerException | undefined, - report: (message: string) => void, -): void { - if (databaseChecksum === migration.checksum) { - return; +function parseDrizzleJournalEntry(value: unknown, position: number): DrizzleJournalEntry { + if (!isRecord(value)) { + throw new Error(`Drizzle journal entry ${position} is invalid.`); } + const { idx, tag, when } = value; if ( - exception && - databaseChecksum === exception.databaseSha256 && - migration.checksum === exception.sourceSha256 + typeof idx !== "number" || + !Number.isSafeInteger(idx) || + typeof when !== "number" || + !Number.isSafeInteger(when) || + typeof tag !== "string" || + !/^\d{4}_[a-z0-9_]+$/.test(tag) ) { - report(`attested Drizzle ledger divergence: ${migration.file}`); - return; + throw new Error(`Drizzle journal entry ${position} has invalid identity fields.`); } - throw new Error(`Applied Drizzle migration identity mismatch: ${migration.file}`); + return { idx, tag, when }; } -export async function assertExpandOnlyDrizzleMigrations(): Promise { - const files = await sqlFiles(DRIZZLE_DIR); - for (const file of files) { - const index = Number.parseInt(file.split("/").at(-1)?.slice(0, 4) ?? "", 10); - if (!Number.isInteger(index) || index < FIRST_EXPAND_ONLY_DRIZZLE_INDEX) { - continue; +function assertDrizzleJournalSequence(entries: readonly DrizzleJournalEntry[]): void { + for (const [position, entry] of entries.entries()) { + if (entry.idx !== position || Number(entry.tag.slice(0, 4)) !== entry.idx) { + throw new Error(`Drizzle journal must be contiguous; invalid entry ${entry.tag}.`); } - const source = stripSqlComments(await readFile(file, "utf8")); - const sql = removeApprovedPrecisionWidening(relative(ROOT, file), source); - if (DESTRUCTIVE_SQL_PATTERN.test(sql)) { - throw new Error( - `Drizzle migration must be expand-only: ${relative(ROOT, file)}. Put contractions in an explicitly post-deploy raw migration.`, - ); + const previous = entries[position - 1]; + if (previous && previous.when >= entry.when) { + throw new Error(`Drizzle journal timestamps must increase; invalid entry ${entry.tag}.`); } } } -function removeApprovedPrecisionWidening(filename: string, sql: string): string { - if (filename !== USER_DELETION_GENERATION_PRECISION_MIGRATION) { - return sql; - } - const parts = sql.split(USER_DELETION_GENERATION_PRECISION_WIDENING); - return parts.length === 2 ? parts.join("") : sql; -} - async function sqlFiles(dir: string): Promise { const entries = await readdir(dir, { withFileTypes: true }); return entries @@ -252,8 +139,8 @@ async function fileChecksum(file: string): Promise { .digest("hex"); } -function stripSqlComments(sql: string): string { - return sql.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/--[^\n]*/g, " "); +function paths(files: readonly string[]): string { + return files.map((file) => relative(ROOT, file)).join(", ") || "none"; } function isRecord(value: unknown): value is Record {