1 require "./db/migrate/20141208185217_search_index.rb"
3 class NoDescriptionInSearchIndex < ActiveRecord::Migration
5 all_tables = %w{collections groups jobs pipeline_instances pipeline_templates}
6 all_tables.each do |table|
7 indexes = ActiveRecord::Base.connection.indexes(table)
8 search_index_by_name = indexes.select do |index|
9 index.name == "#{table}_search_index"
12 index_columns = search_index_by_name.first.andand.columns
13 has_description = index_columns.select.each do |column|
14 column == 'description'
17 if !has_description.empty?
18 SearchIndex.new.migrate(:down)
19 SearchIndex.new.migrate(:up)