annotate db/migrate/20130201184705_add_unique_index_on_tokens_value.rb @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents 261b3d9a4903
children
rev   line source
Chris@1464 1 class AddUniqueIndexOnTokensValue < ActiveRecord::Migration
Chris@1464 2 def up
Chris@1464 3 say_with_time "Adding unique index on tokens, this may take some time..." do
Chris@1464 4 # Just in case
Chris@1464 5 duplicates = Token.connection.select_values("SELECT value FROM #{Token.table_name} GROUP BY value HAVING COUNT(id) > 1")
Chris@1464 6 Token.where(:value => duplicates).delete_all
Chris@1464 7
Chris@1464 8 add_index :tokens, :value, :unique => true, :name => 'tokens_value'
Chris@1464 9 end
Chris@1464 10 end
Chris@1464 11
Chris@1464 12 def down
Chris@1464 13 remove_index :tokens, :name => 'tokens_value'
Chris@1464 14 end
Chris@1464 15 end