2
0

♻️ Introduce typebot v6 with events (#1013)

Closes #885
This commit is contained in:
Baptiste Arnaud
2023-11-08 15:34:16 +01:00
committed by GitHub
parent 68e4fc71fb
commit 35300eaf34
634 changed files with 58971 additions and 31449 deletions

View File

@ -180,6 +180,7 @@ model Typebot {
name String @db.VarChar(255)
folderId String?
groups Json
events Json?
variables Json
edges Json
theme Json
@ -237,6 +238,7 @@ model PublicTypebot {
updatedAt DateTime @default(now()) @updatedAt
typebotId String @unique
groups Json
events Json?
variables Json
edges Json
theme Json
@ -245,21 +247,31 @@ model PublicTypebot {
}
model Result {
id String @id @default(cuid())
createdAt DateTime @default(now())
id String @id @default(cuid())
createdAt DateTime @default(now())
typebotId String
variables Json
isCompleted Boolean
hasStarted Boolean?
isArchived Boolean? @default(false)
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
isArchived Boolean? @default(false)
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
answers Answer[]
logs Log[]
edges VisitedEdge[]
@@index([typebotId, isArchived, hasStarted, createdAt(sort: Desc)])
@@index([typebotId, isArchived, isCompleted])
}
model VisitedEdge {
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
resultId String
edgeId String
index Int
@@unique([resultId, index])
}
model Log {
id String @id @default(cuid())
createdAt DateTime @default(now())

View File

@ -22,6 +22,6 @@
"prisma": "5.0.0",
"@typebot.io/tsconfig": "workspace:*",
"tsx": "3.12.7",
"typescript": "5.1.6"
"typescript": "5.2.2"
}
}

View File

@ -0,0 +1,18 @@
-- AlterTable
ALTER TABLE "PublicTypebot" ADD COLUMN "events" JSONB;
-- AlterTable
ALTER TABLE "Typebot" ADD COLUMN "events" JSONB;
-- CreateTable
CREATE TABLE "VisitedEdge" (
"resultId" TEXT NOT NULL,
"edgeId" TEXT NOT NULL,
"index" INTEGER NOT NULL
);
-- CreateIndex
CREATE UNIQUE INDEX "VisitedEdge_resultId_index_key" ON "VisitedEdge"("resultId", "index");
-- AddForeignKey
ALTER TABLE "VisitedEdge" ADD CONSTRAINT "VisitedEdge_resultId_fkey" FOREIGN KEY ("resultId") REFERENCES "Result"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -164,6 +164,7 @@ model Typebot {
name String
folderId String?
groups Json
events Json?
variables Json
edges Json
theme Json
@ -218,6 +219,7 @@ model PublicTypebot {
updatedAt DateTime @default(now()) @updatedAt
typebotId String @unique
groups Json
events Json?
variables Json
edges Json
theme Json
@ -226,21 +228,31 @@ model PublicTypebot {
}
model Result {
id String @id @default(cuid())
createdAt DateTime @default(now())
id String @id @default(cuid())
createdAt DateTime @default(now())
typebotId String
variables Json
isCompleted Boolean
hasStarted Boolean?
isArchived Boolean? @default(false)
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
isArchived Boolean? @default(false)
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
answers Answer[]
logs Log[]
edges VisitedEdge[]
@@index([typebotId, hasStarted, createdAt(sort: Desc)])
@@index([typebotId, isCompleted])
}
model VisitedEdge {
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
resultId String
edgeId String
index Int
@@unique([resultId, index])
}
model Log {
id String @id @default(cuid())
createdAt DateTime @default(now())