2
0

🐛 Remove delete result cascade

This commit is contained in:
Baptiste Arnaud
2022-09-25 20:16:08 +02:00
committed by Baptiste Arnaud
parent 30dff2d5d7
commit 3c803b1345
11 changed files with 396 additions and 180 deletions

View File

@ -4,14 +4,7 @@ import { ChatGroup } from './ChatGroup'
import { useFrame } from 'react-frame-component'
import { setCssVariablesValue } from '../services/theme'
import { useAnswers } from '../contexts/AnswersContext'
import {
Group,
Edge,
PublicTypebot,
Theme,
VariableWithValue,
Block,
} from 'models'
import { Group, Edge, PublicTypebot, Theme, VariableWithValue } from 'models'
import { byId, isDefined, isInputBlock, isNotDefined } from 'utils'
import { animateScroll as scroll } from 'react-scroll'
import { LinkedTypebot, useTypebot } from 'contexts/TypebotContext'
@ -80,7 +73,6 @@ export const ConversationContainer = ({
}
const nextGroup = currentTypebot.groups.find(byId(nextEdge.to.groupId))
if (!nextGroup) return onCompleted()
console.log(nextGroup, nextEdge)
const startBlockIndex = nextEdge.to.blockId
? nextGroup.blocks.findIndex(byId(nextEdge.to.blockId))
: 0

View File

@ -0,0 +1,5 @@
-- DropForeignKey
ALTER TABLE "Result" DROP CONSTRAINT "Result_typebotId_fkey";
-- AddForeignKey
ALTER TABLE "Result" ADD CONSTRAINT "Result_typebotId_fkey" FOREIGN KEY ("typebotId") REFERENCES "Typebot"("id") ON DELETE NO ACTION ON UPDATE CASCADE;

View File

@ -212,7 +212,7 @@ model Result {
isCompleted Boolean
hasStarted Boolean?
isArchived Boolean?
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: NoAction)
answers Answer[]
logs Log[]
}

View File

@ -13,10 +13,10 @@ const prisma = new PrismaClient()
const main = async () => {
await injectFakeResults(prisma)({
count: 150,
typebotId: 'cl89sq4vb030109laivd9ck97',
count: 200,
typebotId: 'cl8hl08xt009909l6pwqenf63',
isChronological: false,
idPrefix: 'batch2',
fakeStorage: 3 * 1024 * 1024 * 1024,
})
}