From d7c28c8f55c9b741ca714ffbe2116340263ede2d Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Sat, 13 Jun 2026 11:47:48 +0200 Subject: [PATCH] =?UTF-8?q?feat(db):=20migracion=20004=20=E2=80=94=20colum?= =?UTF-8?q?na=20import=5Fkey=20+=20indice=20para=20imports=20idempotentes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- migrations/004_import_key.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 migrations/004_import_key.sql diff --git a/migrations/004_import_key.sql b/migrations/004_import_key.sql new file mode 100644 index 0000000..35dfc38 --- /dev/null +++ b/migrations/004_import_key.sql @@ -0,0 +1,13 @@ +-- 004_import_key.sql +-- Clave de importación determinística para imports idempotentes de contactos. +-- +-- import_key se deriva de la identidad estable del contacto (teléfonos +-- normalizados > emails > nombre normalizado) con la función del registry +-- contact_import_key_py_core. Permite re-importar el mismo .vcf de Google (u +-- otra fuente) y matchear la fila existente sin depender del UID opaco goog- +-- ni del FN, que el pipeline de import transforma. El backfill de las filas +-- existentes lo hace el tool de importación (no esta migración: requiere Python). +-- +-- Aditiva e idempotente: ADD COLUMN IF NOT EXISTS + CREATE INDEX IF NOT EXISTS. +ALTER TABLE contacts ADD COLUMN IF NOT EXISTS import_key TEXT; +CREATE INDEX IF NOT EXISTS idx_contacts_import_key ON contacts (import_key);