Track person import source and previous names; add source report and edit UX.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Person" ADD COLUMN IF NOT EXISTS "previousFirstName" TEXT;
|
||||
ALTER TABLE "Person" ADD COLUMN IF NOT EXISTS "previousLastName" TEXT;
|
||||
ALTER TABLE "Person" ADD COLUMN IF NOT EXISTS "importSource" TEXT NOT NULL DEFAULT 'manual';
|
||||
ALTER TABLE "Person" ADD COLUMN IF NOT EXISTS "sourceRef" TEXT;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX IF NOT EXISTS "Person_organizationId_importSource_idx" ON "Person"("organizationId", "importSource");
|
||||
CREATE INDEX IF NOT EXISTS "Person_organizationId_sourceRef_idx" ON "Person"("organizationId", "sourceRef");
|
||||
|
||||
-- Backfill from legacy customFields / notes
|
||||
UPDATE "Person"
|
||||
SET
|
||||
"importSource" = 'didar',
|
||||
"sourceRef" = COALESCE(NULLIF(BTRIM("sourceRef"), ''), NULLIF(BTRIM("customFields"->>'didarId'), ''))
|
||||
WHERE COALESCE(BTRIM("customFields"->>'didarId'), '') <> '';
|
||||
|
||||
UPDATE "Person"
|
||||
SET "importSource" = 'tahesab'
|
||||
WHERE "importSource" = 'manual'
|
||||
AND notes ILIKE '%تهحساب%';
|
||||
|
||||
UPDATE "Person"
|
||||
SET "importSource" = 'excel'
|
||||
WHERE "importSource" = 'manual'
|
||||
AND COALESCE(BTRIM("customFields"->>'customerCode'), '') <> ''
|
||||
AND COALESCE(BTRIM("customFields"->>'didarId'), '') = '';
|
||||
Reference in New Issue
Block a user