1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class OwnerUuidIndex < ActiveRecord::Migration
6 def tables_with_owner_uuid
7 %w{api_clients authorized_keys collections groups humans
8 job_tasks jobs keep_disks keep_services links logs
9 nodes pipeline_instances pipeline_templates repositories
10 specimens traits users virtual_machines}
14 tables_with_owner_uuid.each do |table|
15 add_index table.to_sym, :owner_uuid
20 tables_with_owner_uuid.each do |table|
21 indexes = ActiveRecord::Base.connection.indexes(table)
22 owner_uuid_index = indexes.select do |index|
23 index.columns == ['owner_uuid']
25 if !owner_uuid_index.empty?
26 remove_index table.to_sym, :owner_uuid