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:
@ -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;
|
||||
@ -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';
|
||||
@ -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";
|
||||
@ -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";
|
||||
Reference in New Issue
Block a user