8784: Fix test for latest firefox.
[arvados.git] / services / api / db / migrate / 20150122175935_no_description_in_search_index.rb
1 # If the database reflects an obsolete version of the 20141208185217
2 # migration (i.e., before commit:5c1db683), revert it and reapply the
3 # current version. (The down-migration is the same in both versions.)
4
5 require "./db/migrate/20141208185217_search_index.rb"
6
7 class NoDescriptionInSearchIndex < ActiveRecord::Migration
8   def up
9     all_tables = %w{collections groups jobs pipeline_instances pipeline_templates}
10     all_tables.each do |table|
11       indexes = ActiveRecord::Base.connection.indexes(table)
12       search_index_by_name = indexes.select do |index|
13         index.name == "#{table}_search_index"
14       end
15
16       if !search_index_by_name.empty?
17         index_columns = search_index_by_name.first.columns
18         has_description = index_columns.include? 'description'
19         if has_description
20           SearchIndex.new.migrate(:down)
21           SearchIndex.new.migrate(:up)
22           break
23         end
24       end
25     end
26   end
27
28   def down
29   end
30 end