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.)
5 require "./db/migrate/20141208185217_search_index.rb"
7 class NoDescriptionInSearchIndex < ActiveRecord::Migration
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"
16 if !search_index_by_name.empty?
17 index_columns = search_index_by_name.first.columns
18 has_description = index_columns.include? 'description'
20 SearchIndex.new.migrate(:down)
21 SearchIndex.new.migrate(:up)