From 426bd810f1161306acc0d2ba27064b3f95cdc788 Mon Sep 17 00:00:00 2001 From: Vinoth Kannan Date: Thu, 14 Feb 2019 03:44:14 +0530 Subject: [PATCH] FIX: S3 inventory can have duplicate etags --- lib/s3_inventory.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/s3_inventory.rb b/lib/s3_inventory.rb index fab17564d8e..5b267177d1f 100644 --- a/lib/s3_inventory.rb +++ b/lib/s3_inventory.rb @@ -37,7 +37,7 @@ class S3Inventory begin table_name = "#{inventory_id}_inventory" connection = ActiveRecord::Base.connection.raw_connection - connection.exec("CREATE TEMP TABLE #{table_name}(key text UNIQUE, etag text PRIMARY KEY)") + connection.exec("CREATE TEMP TABLE #{table_name}(key text UNIQUE, etag text, PRIMARY KEY(etag, key))") connection.copy_data("COPY #{table_name} FROM STDIN CSV") do files.each do |file| CSV.foreach(file[:filename][0...-3], headers: false) do |row|