mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-18 09:02:11 +03:00
Migrate data for activity targets
This commit is contained in:
parent
486d54cf56
commit
f89bc30689
@ -0,0 +1,20 @@
|
||||
-- This is a manually written migration to populate company and person on the activity targets based on the previous commentable id
|
||||
-- This is a one time migration and should not be run again, it could also be ran as a one-off script
|
||||
|
||||
UPDATE "activity_targets" as atg SET
|
||||
"companyId"="commentableId"
|
||||
WHERE "commentableType"='Company'
|
||||
AND "commentableId" IS NOT NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM "companies" AS c
|
||||
WHERE c."id" = atg."commentableId"
|
||||
);
|
||||
|
||||
UPDATE "activity_targets" as atg SET
|
||||
"personId"="commentableId"
|
||||
WHERE "commentableType"='Person'
|
||||
AND "commentableId" IS NOT NULL
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM "people" AS p
|
||||
WHERE p."id" = atg."commentableId"
|
||||
);
|
Loading…
Reference in New Issue
Block a user