fix workflows when duplicating event types (#6873)
This commit is contained in:
1 parent
24be8a63f2
commit
5cf7e32852
1 file changed
+4
-12
@@ -770,20 +770,12 @@ export const eventTypesRouter = router({
|
||||
}
|
||||
|
||||
if (workflows.length > 0) {
|
||||
const workflowIds = workflows.map((workflow) => {
|
||||
return { id: workflow.workflowId };
|
||||
const relationCreateData = workflows.map((workflow) => {
|
||||
return { eventTypeId: newEventType.id, workflowId: workflow.workflowId };
|
||||
});
|
||||
|
||||
const eventUpdateData: Prisma.EventTypeUpdateInput = {
|
||||
workflows: {
|
||||
connect: workflowIds,
|
||||
},
|
||||
};
|
||||
await ctx.prisma.eventType.update({
|
||||
where: {
|
||||
id: newEventType.id,
|
||||
},
|
||||
data: eventUpdateData,
|
||||
await ctx.prisma.workflowsOnEventTypes.createMany({
|
||||
data: relationCreateData,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user