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

@ -0,0 +1,9 @@
-- AlterTable
ALTER TABLE "pipeline_progresses" ADD COLUMN "companyId" TEXT,
ADD COLUMN "personId" TEXT;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "companies"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "pipeline_progresses" ADD CONSTRAINT "pipeline_progresses_personId_fkey" FOREIGN KEY ("personId") REFERENCES "people"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@ -0,0 +1,8 @@
-- This is a manually written data migration that copies the progressable ids to the right colums in pipeline progress.
UPDATE "pipeline_progresses" SET
"companyId"="progressableId"
WHERE "progressableType"='Company';
UPDATE "pipeline_progresses" SET
"personId"="progressableId"
WHERE "progressableType"='Person';

View File

@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `progressableId` on the `pipeline_progresses` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "pipeline_progresses" DROP COLUMN "progressableId";

View File

@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `progressableType` on the `pipeline_progresses` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "pipeline_progresses" DROP COLUMN "progressableType";