From 1579db1aec4ffe532040adbb5fdaa44edc134b21 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Thu, 20 Dec 2018 14:14:40 -0600 Subject: [PATCH] Add ON CONFLICT to derive_transaction_forks Fixes #1262 --- apps/explorer/lib/explorer/chain/import/runner/blocks.ex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex index 9f24d0be7b..5917ae9968 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex @@ -133,6 +133,9 @@ defmodule Explorer.Chain.Import.Runner.Blocks do insert_sql = """ INSERT INTO transaction_forks (uncle_hash, index, hash, inserted_at, updated_at) #{select_sql} + ON CONFLICT (uncle_hash, index) + DO UPDATE SET hash = EXCLUDED.hash + WHERE EXCLUDED.hash <> transaction_forks.hash RETURNING uncle_hash, hash """