Skip to content

Commit

Permalink
Fixes #11339 - ensure unique parameters before adding uniq index
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsherrill committed Aug 13, 2015
1 parent 3bd9a89 commit aabf3c2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions db/migrate/20140805114754_add_unique_index_to_parameter.rb
@@ -1,5 +1,15 @@
class AddUniqueIndexToParameter < ActiveRecord::Migration
def up
found = []
Parameter.find_each do |param|
new_param = {:name => param.name, :type => param.type, :reference_id => param.reference_id}
if found.include?(new_param)
param.destroy
else
found << new_param
end
end

add_index :parameters, [:type, :reference_id, :name], :unique => true
end

Expand Down

0 comments on commit aabf3c2

Please sign in to comment.