From da8774caa259cde2f7fe022999b41c1eb2f52093 Mon Sep 17 00:00:00 2001 From: Rafael Freire Cunha <62675285+RaFaeL-Cunha@users.noreply.github.com> Date: Sun, 9 Nov 2025 14:56:53 -0400 Subject: [PATCH] =?UTF-8?q?fix(chatwoot):=20corrige=20erro=20de=20duplica?= =?UTF-8?q?=C3=A7=C3=A3o=20na=20importa=C3=A7=C3=A3o=20de=20contatos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve o erro 'ON CONFLICT DO UPDATE command cannot affect row a second time' que ocorria ao importar histórico de contatos duplicados. A correção remove a tentativa de atualizar o campo 'identifier' no ON CONFLICT, já que este campo faz parte da constraint de conflito e não pode ser atualizado. Erro original: - identifier = EXCLUDED.identifier Correção: - updated_at = NOW() Isso permite que contatos duplicados sejam atualizados corretamente sem causar erro. --- .../chatbot/chatwoot/utils/chatwoot-import-helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts b/src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts index a4fd01df4..7d55da416 100644 --- a/src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts +++ b/src/api/integrations/chatbot/chatwoot/utils/chatwoot-import-helper.ts @@ -137,7 +137,7 @@ class ChatwootImport { DO UPDATE SET name = EXCLUDED.name, phone_number = EXCLUDED.phone_number, - identifier = EXCLUDED.identifier`; + updated_at = NOW()`; totalContactsImported += (await pgClient.query(sqlInsert, bindInsert))?.rowCount ?? 0;