ai-chatbot/lib/db/migrations/0104_add_canvas_agent_runs.sql

17 lines
761 B
SQL

CREATE TABLE IF NOT EXISTS "CanvasAgentRun" (
"id" uuid PRIMARY KEY NOT NULL,
"userId" uuid NOT NULL REFERENCES "User"("id") ON DELETE CASCADE,
"chatId" uuid NOT NULL REFERENCES "Chat"("id") ON DELETE CASCADE,
"projectId" uuid NOT NULL REFERENCES "CanvasProject"("id") ON DELETE CASCADE,
"status" varchar(24) NOT NULL DEFAULT 'running',
"leaseId" uuid NOT NULL,
"cancelRequested" boolean NOT NULL DEFAULT false,
"pendingInputs" jsonb NOT NULL DEFAULT '[]'::jsonb,
"snapshot" jsonb NOT NULL,
"assistantMessageId" uuid NOT NULL,
"createdAt" timestamp NOT NULL DEFAULT now(),
"updatedAt" timestamp NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS "CanvasAgentRun_owner_chat_idx"
ON "CanvasAgentRun" ("userId", "chatId", "updatedAt");