8784: Fix test for latest firefox.
[arvados.git] / services / api / db / migrate / 20170216170823_no_cr_mounts_and_workflow_def_in_full_text_search_index.rb
1 class NoCrMountsAndWorkflowDefInFullTextSearchIndex < ActiveRecord::Migration
2   def fts_indexes
3     {
4       "container_requests" => "container_requests_full_text_search_idx",
5       "workflows" => "workflows_full_text_search_idx",
6     }
7   end
8
9   def up
10     # remove existing fts index and recreate for container_requests and workflows
11     fts_indexes.each do |t, i|
12       t.classify.constantize.reset_column_information
13       ActiveRecord::Base.connection.indexes(t).each do |idx|
14         if idx.name == i
15           remove_index t.to_sym, :name => i
16           break
17         end
18       end
19       execute "CREATE INDEX #{i} ON #{t} USING gin(#{t.classify.constantize.full_text_tsvector});"
20     end
21   end
22
23   def down
24     fts_indexes.each do |t, i|
25       t.classify.constantize.reset_column_information
26       ActiveRecord::Base.connection.indexes(t).each do |idx|
27         if idx.name == i
28           remove_index t.to_sym, :name => i
29           break
30         end
31       end
32     end
33   end
34 end