17755: Merge branch 'main' into 17755-add-singularity-to-compute-image
[arvados.git] / services / api / db / migrate / 20210816191509_drop_fts_index.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class DropFtsIndex < ActiveRecord::Migration[5.2]
6   def fts_indexes
7     {
8       "collections" => "collections_full_text_search_idx",
9       "container_requests" => "container_requests_full_text_search_idx",
10       "groups" => "groups_full_text_search_idx",
11       "jobs" => "jobs_full_text_search_idx",
12       "pipeline_instances" => "pipeline_instances_full_text_search_idx",
13       "pipeline_templates" => "pipeline_templates_full_text_search_idx",
14       "workflows" => "workflows_full_text_search_idx",
15     }
16   end
17
18   def up
19     fts_indexes.keys.each do |t|
20       i = fts_indexes[t]
21       execute "DROP INDEX IF EXISTS #{i}"
22     end
23   end
24
25   def down
26     fts_indexes.keys.each do |t|
27       i = fts_indexes[t]
28       execute "CREATE INDEX #{i} ON #{t} USING gin(#{t.classify.constantize.full_text_tsvector})"
29     end
30   end
31 end