Skip to content

Commit 665ee9e

Browse files
authored
Mariano/agent screenshots 2 (#1918)
* chore(db): add migration for organizationId and new browser automation tables
1 parent c2cbd35 commit 665ee9e

File tree

1 file changed

+90
-0
lines changed
  • packages/db/prisma/migrations/20251215033455_add_org_id

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `authenticatedAt` on the `BrowserbaseContext` table. All the data in the column will be lost.
5+
- You are about to drop the column `connectionId` on the `BrowserbaseContext` table. All the data in the column will be lost.
6+
- You are about to drop the column `isAuthenticated` on the `BrowserbaseContext` table. All the data in the column will be lost.
7+
- A unique constraint covering the columns `[organizationId]` on the table `BrowserbaseContext` will be added. If there are existing duplicate values, this will fail.
8+
- Added the required column `organizationId` to the `BrowserbaseContext` table without a default value. This is not possible if the table is not empty.
9+
10+
*/
11+
-- CreateEnum
12+
CREATE TYPE "BrowserAutomationEvaluationStatus" AS ENUM ('pass', 'fail');
13+
14+
-- CreateEnum
15+
CREATE TYPE "BrowserAutomationRunStatus" AS ENUM ('pending', 'running', 'completed', 'failed');
16+
17+
-- DropForeignKey
18+
ALTER TABLE "BrowserbaseContext" DROP CONSTRAINT "BrowserbaseContext_connectionId_fkey";
19+
20+
-- DropIndex
21+
DROP INDEX "BrowserbaseContext_connectionId_idx";
22+
23+
-- DropIndex
24+
DROP INDEX "BrowserbaseContext_connectionId_key";
25+
26+
-- AlterTable
27+
ALTER TABLE "BrowserbaseContext" DROP COLUMN "authenticatedAt",
28+
DROP COLUMN "connectionId",
29+
DROP COLUMN "isAuthenticated",
30+
ADD COLUMN "organizationId" TEXT NOT NULL;
31+
32+
-- CreateTable
33+
CREATE TABLE "BrowserAutomation" (
34+
"id" TEXT NOT NULL DEFAULT generate_prefixed_cuid('bau'::text),
35+
"name" TEXT NOT NULL,
36+
"description" TEXT,
37+
"taskId" TEXT NOT NULL,
38+
"targetUrl" TEXT NOT NULL,
39+
"instruction" TEXT NOT NULL,
40+
"isEnabled" BOOLEAN NOT NULL DEFAULT false,
41+
"schedule" TEXT,
42+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
43+
"updatedAt" TIMESTAMP(3) NOT NULL,
44+
45+
CONSTRAINT "BrowserAutomation_pkey" PRIMARY KEY ("id")
46+
);
47+
48+
-- CreateTable
49+
CREATE TABLE "BrowserAutomationRun" (
50+
"id" TEXT NOT NULL DEFAULT generate_prefixed_cuid('bar'::text),
51+
"automationId" TEXT NOT NULL,
52+
"status" "BrowserAutomationRunStatus" NOT NULL DEFAULT 'pending',
53+
"startedAt" TIMESTAMP(3),
54+
"completedAt" TIMESTAMP(3),
55+
"durationMs" INTEGER,
56+
"screenshotUrl" TEXT,
57+
"evaluationStatus" "BrowserAutomationEvaluationStatus",
58+
"evaluationReason" TEXT,
59+
"error" TEXT,
60+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
61+
62+
CONSTRAINT "BrowserAutomationRun_pkey" PRIMARY KEY ("id")
63+
);
64+
65+
-- CreateIndex
66+
CREATE INDEX "BrowserAutomation_taskId_idx" ON "BrowserAutomation"("taskId");
67+
68+
-- CreateIndex
69+
CREATE INDEX "BrowserAutomationRun_automationId_idx" ON "BrowserAutomationRun"("automationId");
70+
71+
-- CreateIndex
72+
CREATE INDEX "BrowserAutomationRun_status_idx" ON "BrowserAutomationRun"("status");
73+
74+
-- CreateIndex
75+
CREATE INDEX "BrowserAutomationRun_createdAt_idx" ON "BrowserAutomationRun"("createdAt");
76+
77+
-- CreateIndex
78+
CREATE UNIQUE INDEX "BrowserbaseContext_organizationId_key" ON "BrowserbaseContext"("organizationId");
79+
80+
-- CreateIndex
81+
CREATE INDEX "BrowserbaseContext_organizationId_idx" ON "BrowserbaseContext"("organizationId");
82+
83+
-- AddForeignKey
84+
ALTER TABLE "BrowserbaseContext" ADD CONSTRAINT "BrowserbaseContext_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
85+
86+
-- AddForeignKey
87+
ALTER TABLE "BrowserAutomation" ADD CONSTRAINT "BrowserAutomation_taskId_fkey" FOREIGN KEY ("taskId") REFERENCES "Task"("id") ON DELETE CASCADE ON UPDATE CASCADE;
88+
89+
-- AddForeignKey
90+
ALTER TABLE "BrowserAutomationRun" ADD CONSTRAINT "BrowserAutomationRun_automationId_fkey" FOREIGN KEY ("automationId") REFERENCES "BrowserAutomation"("id") ON DELETE CASCADE ON UPDATE CASCADE;

0 commit comments

Comments
 (0)