From 1c915bdb3a4868bd60d46e25a0328b5590e4e84f Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Thu, 3 Jan 2019 15:06:02 -0600 Subject: [PATCH] conflict_target and on_conflict for Block Rewards importer Fixes #1297 --- .../lib/indexer/block/uncataloged_rewards/importer.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/indexer/lib/indexer/block/uncataloged_rewards/importer.ex b/apps/indexer/lib/indexer/block/uncataloged_rewards/importer.ex index 8c544f2837..5c98a9eaa3 100644 --- a/apps/indexer/lib/indexer/block/uncataloged_rewards/importer.ex +++ b/apps/indexer/lib/indexer/block/uncataloged_rewards/importer.ex @@ -100,7 +100,10 @@ defmodule Indexer.Block.UncatalogedRewards.Importer do defp insert_reward_group(rewards) do rewards |> Enum.reduce({Multi.new(), 0}, fn changeset, {multi, index} -> - {Multi.insert(multi, "insert_#{index}", changeset), index + 1} + {Multi.insert(multi, "insert_#{index}", changeset, + conflict_target: ~w(address_hash address_type block_hash), + on_conflict: {:replace, [:reward]} + ), index + 1} end) |> elem(0) |> Explorer.Repo.transaction()