2
0

(setVariable) Add Transcription system var (#1507)

Closes #1484
This commit is contained in:
Baptiste Arnaud
2024-05-15 14:24:55 +02:00
committed by GitHub
parent ec7ff8d9ca
commit 40f21203b5
102 changed files with 2911 additions and 986 deletions

View File

@@ -255,22 +255,36 @@ model PublicTypebot {
}
model Result {
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)
answers Answer[]
logs Log[]
edges VisitedEdge[]
id String @id @default(cuid())
createdAt DateTime @default(now())
typebotId String
variables Json
isCompleted Boolean
hasStarted Boolean?
isArchived Boolean? @default(false)
lastChatSessionId String?
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
answers Answer[]
logs Log[]
edges VisitedEdge[]
setVariableHistory SetVariableHistoryItem[]
answersV2 AnswerV2[]
@@index([typebotId, isArchived, hasStarted, createdAt(sort: Desc)])
@@index([typebotId, isArchived, isCompleted])
}
model SetVariableHistoryItem {
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
resultId String
index Int
variableId String
blockId String
value Json // string or list of strings
@@unique([resultId, index])
}
model VisitedEdge {
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
resultId String
@@ -292,20 +306,28 @@ model Log {
@@index([resultId])
}
// TODO: gradually remove variableId and groupId
model Answer {
createdAt DateTime @default(now()) @updatedAt
resultId String
blockId String
itemId String?
groupId String
variableId String?
content String @db.Text
storageUsed Int?
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now()) @updatedAt
resultId String
blockId String
groupId String
variableId String?
content String @db.Text
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
@@unique([resultId, blockId, groupId])
@@index([blockId, itemId])
@@index([storageUsed])
}
model AnswerV2 {
id Int @id @default(autoincrement())
blockId String
content String
resultId String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
@@index([resultId])
@@index([blockId])
}
model Coupon {

View File

@@ -0,0 +1,47 @@
/*
Warnings:
- You are about to drop the column `itemId` on the `Answer` table. All the data in the column will be lost.
- You are about to drop the column `storageUsed` on the `Answer` table. All the data in the column will be lost.
*/
-- DropIndex
DROP INDEX "Answer_blockId_itemId_idx";
-- AlterTable
ALTER TABLE "Answer" DROP COLUMN "itemId",
DROP COLUMN "storageUsed";
-- AlterTable
ALTER TABLE "Result" ADD COLUMN "lastChatSessionId" TEXT;
-- CreateTable
CREATE TABLE "SetVariableHistoryItem" (
"resultId" TEXT NOT NULL,
"index" INTEGER NOT NULL,
"variableId" TEXT NOT NULL,
"blockId" TEXT NOT NULL,
"value" JSONB NOT NULL
);
-- CreateTable
CREATE TABLE "AnswerV2" (
"id" SERIAL NOT NULL,
"blockId" TEXT NOT NULL,
"content" TEXT NOT NULL,
"resultId" TEXT NOT NULL,
CONSTRAINT "AnswerV2_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "SetVariableHistoryItem_resultId_index_key" ON "SetVariableHistoryItem"("resultId", "index");
-- CreateIndex
CREATE INDEX "AnswerV2_blockId_idx" ON "AnswerV2"("blockId");
-- AddForeignKey
ALTER TABLE "SetVariableHistoryItem" ADD CONSTRAINT "SetVariableHistoryItem_resultId_fkey" FOREIGN KEY ("resultId") REFERENCES "Result"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "AnswerV2" ADD CONSTRAINT "AnswerV2_resultId_fkey" FOREIGN KEY ("resultId") REFERENCES "Result"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -236,22 +236,36 @@ model PublicTypebot {
}
model Result {
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)
answers Answer[]
logs Log[]
edges VisitedEdge[]
id String @id @default(cuid())
createdAt DateTime @default(now())
typebotId String
variables Json
isCompleted Boolean
hasStarted Boolean?
isArchived Boolean? @default(false)
lastChatSessionId String?
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
answers Answer[]
answersV2 AnswerV2[]
logs Log[]
edges VisitedEdge[]
setVariableHistory SetVariableHistoryItem[]
@@index([typebotId, hasStarted, createdAt(sort: Desc)])
@@index([typebotId, isCompleted])
}
model SetVariableHistoryItem {
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
resultId String
index Int
variableId String
blockId String
value Json // string or list
@@unique([resultId, index])
}
model VisitedEdge {
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
resultId String
@@ -274,19 +288,25 @@ model Log {
}
model Answer {
createdAt DateTime @default(now()) @updatedAt
resultId String
blockId String
itemId String?
groupId String
variableId String?
content String
storageUsed Int?
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now()) @updatedAt
resultId String
blockId String
groupId String
variableId String?
content String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
@@unique([resultId, blockId, groupId])
@@index([blockId, itemId])
@@index([storageUsed])
}
model AnswerV2 {
id Int @id @default(autoincrement())
blockId String
content String
resultId String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
@@index([blockId])
}
model Coupon {