X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/011cdc12d3d3a664e8a8ef09bc0e7f5223afa6df..f4707d4ab4a998a2af2a489141393fc4e793ee89:/services/api/db/migrate/20141208185217_search_index.rb diff --git a/services/api/db/migrate/20141208185217_search_index.rb b/services/api/db/migrate/20141208185217_search_index.rb index 639bdc268a..c8e9fef872 100644 --- a/services/api/db/migrate/20141208185217_search_index.rb +++ b/services/api/db/migrate/20141208185217_search_index.rb @@ -1,10 +1,14 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + class SearchIndex < ActiveRecord::Migration def tables_with_searchable_columns { "api_client_authorizations" => ["api_token", "created_by_ip_address", "last_used_by_ip_address", "default_owner_uuid"], "api_clients" => ["uuid", "owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "name", "url_prefix"], "authorized_keys" => ["uuid", "owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "name", "key_type", "authorized_user_uuid"], - "collections" => ["owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "portable_data_hash", "redundancy_confirmed_by_client_uuid", "uuid", "name", "description"], + "collections" => ["owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "portable_data_hash", "redundancy_confirmed_by_client_uuid", "uuid", "name", "file_names"], "groups" => ["uuid", "owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "name", "group_class"], "humans" => ["uuid", "owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid"], "job_tasks" => ["uuid", "owner_uuid", "modified_by_client_uuid", "modified_by_user_uuid", "job_uuid", "created_by_job_task_uuid"], @@ -24,21 +28,9 @@ class SearchIndex < ActiveRecord::Migration } end - def up - tables_with_searchable_columns.each do |table, columns| - add_index(table.to_sym, columns, name: "#{table}_search_index") - end - end - - def down + def change tables_with_searchable_columns.each do |table, columns| - indexes = ActiveRecord::Base.connection.indexes(table) - search_index = indexes.select do |index| - index.name == "#{table}_search_index" - end - if !search_index.empty? - remove_index(table.to_sym, name: "#{table}_search_index") - end + add_index table.to_sym, columns, name: "#{table}_search_index" end end end