1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 # If the database reflects an obsolete version of the 20141208185217
6 # migration (i.e., before commit:5c1db683), revert it and reapply the
7 # current version. (The down-migration is the same in both versions.)
9 require "./db/migrate/20141208185217_search_index.rb"
11 class NoDescriptionInSearchIndex < ActiveRecord::Migration[4.2]
13 all_tables = %w{collections groups jobs pipeline_instances pipeline_templates}
14 all_tables.each do |table|
15 indexes = ActiveRecord::Base.connection.indexes(table)
16 search_index_by_name = indexes.select do |index|
17 index.name == "#{table}_search_index"
20 if !search_index_by_name.empty?
21 index_columns = search_index_by_name.first.columns
22 has_description = index_columns.include? 'description'
24 SearchIndex.new.migrate(:down)
25 SearchIndex.new.migrate(:up)