Add foreign key constraints and perform on Cascade Delete (#1219)

This commit is contained in:
Charles Bochet
2023-08-15 20:52:23 +02:00
committed by GitHub
parent 83b900e016
commit 7a330b4a02
3 changed files with 68 additions and 43 deletions

View File

@ -233,7 +233,7 @@ model Company {
employees Int?
people Person[]
accountOwner User? @relation(fields: [accountOwnerId], references: [id])
accountOwner User? @relation(fields: [accountOwnerId], references: [id], onDelete: SetNull)
accountOwnerId String?
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
@ -346,9 +346,9 @@ model Activity {
activityTargets ActivityTarget[]
comments Comment[]
attachments Attachment[]
author User @relation(fields: [authorId], references: [id], name: "authoredActivities")
author User @relation(fields: [authorId], references: [id], name: "authoredActivities", onDelete: Cascade)
authorId String
assignee User? @relation(fields: [assigneeId], references: [id], name: "assignedActivities")
assignee User? @relation(fields: [assigneeId], references: [id], name: "assignedActivities", onDelete: SetNull)
assigneeId String?
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
@ -371,7 +371,7 @@ model Comment {
/// @Validator.IsString()
body String
author User @relation(fields: [authorId], references: [id])
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
authorId String
activity Activity? @relation(fields: [activityId], references: [id], onDelete: Cascade)
activityId String?
@ -462,7 +462,7 @@ model PipelineStage {
pipelineProgresses PipelineProgress[]
///
pipeline Pipeline @relation(fields: [pipelineId], references: [id])
pipeline Pipeline @relation(fields: [pipelineId], references: [id], onDelete: Cascade)
pipelineId String
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
@ -491,11 +491,11 @@ model PipelineProgress {
closeDate DateTime?
probability Int?
pipeline Pipeline @relation(fields: [pipelineId], references: [id])
pipeline Pipeline @relation(fields: [pipelineId], references: [id], onDelete: Cascade)
pipelineId String
pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id])
pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id], onDelete: Cascade)
pipelineStageId String
pointOfContact Person? @relation("PointOfContactPipelineProgress", fields: [pointOfContactId], references: [id])
pointOfContact Person? @relation("PointOfContactPipelineProgress", fields: [pointOfContactId], references: [id], onDelete: SetNull)
pointOfContactId String?
/// @TypeGraphQL.omit(input: true, output: true)
@ -540,9 +540,9 @@ model Attachment {
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
author User @relation(fields: [authorId], references: [id], name: "authoredAttachments")
author User @relation(fields: [authorId], references: [id], name: "authoredAttachments", onDelete: Cascade)
authorId String
activity Activity @relation(fields: [activityId], references: [id])
activity Activity @relation(fields: [activityId], references: [id], onDelete: Cascade)
activityId String
/// @TypeGraphQL.omit(input: true, output: false)
@ -559,10 +559,10 @@ model Favorite {
id String @id @default(uuid())
workspaceId String?
/// @TypeGraphQL.omit(input: true, output: false)
person Person? @relation(fields: [personId], references: [id])
person Person? @relation(fields: [personId], references: [id], onDelete: Cascade)
personId String?
/// @TypeGraphQL.omit(input: true, output: false)
company Company? @relation(fields: [companyId], references: [id])
company Company? @relation(fields: [companyId], references: [id], onDelete: Cascade)
companyId String?
/// @TypeGraphQL.omit(input: true, output: false)
workspaceMember WorkspaceMember? @relation(fields: [workspaceMemberId], references: [id])