feat(sync-log): historial de sincronizaciones WhatsApp en sync_wa_log

- Nueva tabla sync_wa_log (total, created, skipped, updated, errores, origen, modo)
- Log guardado en /pacientes/sync-all, /terceros/send y /automation/run
- Ruta GET /pacientes/historial devuelve últimos 100 registros
- UI: tabla de historial con origen, modo, conteos y detalle de errores

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-09 11:13:28 -05:00
co-authored by Claude Sonnet 4.6
parent 1aab14f705
commit b0175a2ca5
6 changed files with 174 additions and 7 deletions
+15
View File
@@ -76,6 +76,21 @@ def init_db():
created_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (user_id) REFERENCES users(id)
);
CREATE TABLE IF NOT EXISTS sync_wa_log (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER,
origen TEXT NOT NULL DEFAULT 'manual',
modo TEXT NOT NULL DEFAULT 'insertar',
total INTEGER NOT NULL DEFAULT 0,
created INTEGER NOT NULL DEFAULT 0,
skipped INTEGER NOT NULL DEFAULT 0,
updated INTEGER NOT NULL DEFAULT 0,
errores INTEGER NOT NULL DEFAULT 0,
errores_det TEXT,
created_at TEXT NOT NULL DEFAULT (datetime('now')),
FOREIGN KEY (user_id) REFERENCES users(id)
);
""")
conn.commit()
_migrate(conn)