Fix `MigratePollsData` failing when poll-votes have duplicated options.
This commit is contained in:
parent
f4020d9134
commit
439b3fe10a
|
@ -134,7 +134,10 @@ class MigratePollsData < ActiveRecord::Migration[5.2]
|
||||||
options
|
options
|
||||||
.select { |o| option_ids.has_key?(o) }
|
.select { |o| option_ids.has_key?(o) }
|
||||||
.map { |o| "(#{poll_id}, #{option_ids[o]}, #{user_id.to_i}, '#{r.created_at}', '#{r.updated_at}')" }
|
.map { |o| "(#{poll_id}, #{option_ids[o]}, #{user_id.to_i}, '#{r.created_at}', '#{r.updated_at}')" }
|
||||||
end.flatten
|
end
|
||||||
|
|
||||||
|
poll_votes.flatten!
|
||||||
|
poll_votes.uniq!
|
||||||
|
|
||||||
if poll_votes.present?
|
if poll_votes.present?
|
||||||
execute <<~SQL
|
execute <<~SQL
|
||||||
|
|
|
@ -90,7 +90,8 @@ RSpec.describe MigratePollsData do
|
||||||
"1" => {
|
"1" => {
|
||||||
"testing" => [
|
"testing" => [
|
||||||
"b2c3e3668a886d09e97e38b8adde7d45",
|
"b2c3e3668a886d09e97e38b8adde7d45",
|
||||||
"28df49fa9e9c09d3a1eb8cfbcdcda7790",
|
"b2c3e3668a886d09e97e38b8adde7d45",
|
||||||
|
"28df49fa9e9c09d3a1eb8cfbcdcda7790"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"2" => {
|
"2" => {
|
||||||
|
|
Loading…
Reference in New Issue