FIX: Skip duplicate data when migrating from custom fields

FIX: Skip duplicate data when migrating from custom fields

diff --git a/db/migrate/20200728222920_create_discourse_voting_votes.rb b/db/migrate/20200728222920_create_discourse_voting_votes.rb
index b5b8a71..9035349 100644
--- a/db/migrate/20200728222920_create_discourse_voting_votes.rb
+++ b/db/migrate/20200728222920_create_discourse_voting_votes.rb
@@ -15,6 +15,7 @@ class CreateDiscourseVotingVotes < ActiveRecord::Migration[6.0]
       SELECT value::integer, user_id, 'false', created_at, updated_at
       FROM user_custom_fields
       WHERE name = 'votes'
+      ON CONFLICT(user_id, topic_id) DO NOTHING
     SQL
 
     DB.exec <<~SQL
@@ -22,6 +23,7 @@ class CreateDiscourseVotingVotes < ActiveRecord::Migration[6.0]
       SELECT value::integer, user_id, 'true', created_at, updated_at
       FROM user_custom_fields
       WHERE name = 'votes_archive'
+      ON CONFLICT(user_id, topic_id) DO NOTHING
     SQL
   end
 

GitHub sha: 142b3db6