Keep previous import source and code when a person is re-imported from another source
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
ALTER TABLE "Person" ADD COLUMN IF NOT EXISTS "previousImportSource" TEXT;
|
||||
ALTER TABLE "Person" ADD COLUMN IF NOT EXISTS "previousSourceRef" TEXT;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "Person_organizationId_previousSourceRef_idx" ON "Person"("organizationId", "previousSourceRef");
|
||||
|
||||
-- اشخاصی که قبلاً از دیدار آمدهاند و بعد با تهحساب بازنویسی شدهاند: کد دیدار را بهعنوان کد قبلی بازیابی کن
|
||||
UPDATE "Person"
|
||||
SET "previousImportSource" = 'didar',
|
||||
"previousSourceRef" = TRIM("customFields"->>'didarId')
|
||||
WHERE "importSource" = 'tahesab'
|
||||
AND "previousSourceRef" IS NULL
|
||||
AND "customFields" IS NOT NULL
|
||||
AND jsonb_typeof("customFields") = 'object'
|
||||
AND COALESCE(TRIM("customFields"->>'didarId'), '') <> '';
|
||||
Reference in New Issue
Block a user