Refactor: Morph strategy on PipelineProgress (#1065)

* Deprecate pipelineprogress backref on person to improve naming

* Remove deprecated point of contact fields

* Add company and person entities on pipelineprogress

* Migrate data from old progressable to new entity fields

* Codegen frontend

* Use company Id, deprecate progressableId

* Get rid of deprecated progressableId field

* Remove deprecated progressableType field from pipeline progress

* Remove useless migrations
This commit is contained in:
Emilien Chauvet
2023-08-03 18:08:35 +02:00
committed by GitHub
parent 4252a0a2c3
commit 21e3d8fcac
15 changed files with 327 additions and 263 deletions

View File

@ -240,9 +240,10 @@ model Company {
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ActivityTarget ActivityTarget[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ActivityTarget ActivityTarget[]
PipelineProgress PipelineProgress[]
@@map("companies")
}
@ -276,20 +277,21 @@ model Person {
/// @Validator.IsOptional()
avatarUrl String?
company Company? @relation(fields: [companyId], references: [id])
companyId String?
company Company? @relation(fields: [companyId], references: [id])
companyId String?
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
pipelineProgresses PipelineProgress[]
workspaceId String
contactPipelineProgresses PipelineProgress[] @relation("PointOfContactPipelineProgress")
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ActivityTarget ActivityTarget[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ActivityTarget ActivityTarget[]
PipelineProgress PipelineProgress[]
@@map("people")
}
@ -488,18 +490,17 @@ model PipelineProgress {
closeDate DateTime?
probability Int?
pipeline Pipeline @relation(fields: [pipelineId], references: [id])
pipeline Pipeline @relation(fields: [pipelineId], references: [id])
pipelineId String
pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id])
pipelineStage PipelineStage @relation(fields: [pipelineStageId], references: [id])
pipelineStageId String
pointOfContact Person? @relation(fields: [pointOfContactId], references: [id])
pointOfContact Person? @relation("PointOfContactPipelineProgress", fields: [pointOfContactId], references: [id])
pointOfContactId String?
progressableType PipelineProgressableType
progressableId String
/// @TypeGraphQL.omit(input: true, output: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
workspace Workspace @relation(fields: [workspaceId], references: [id])
/// @TypeGraphQL.omit(input: true, output: true)
workspaceId String
workspaceId String
/// @TypeGraphQL.omit(input: true, output: true)
deletedAt DateTime?
@ -507,6 +508,12 @@ model PipelineProgress {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
companyId String?
company Company? @relation(fields: [companyId], references: [id])
personId String?
person Person? @relation(fields: [personId], references: [id])
@@map("pipeline_progresses")
}