X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/155e542971974020412ad41d22e616290be5cc94..77c8223f5ddd64cff2b08d0857749644c474946f:/services/api/db/migrate/20141208164553_owner_uuid_index.rb diff --git a/services/api/db/migrate/20141208164553_owner_uuid_index.rb b/services/api/db/migrate/20141208164553_owner_uuid_index.rb index 9ba0c5a349..a3f68954b2 100644 --- a/services/api/db/migrate/20141208164553_owner_uuid_index.rb +++ b/services/api/db/migrate/20141208164553_owner_uuid_index.rb @@ -1,15 +1,13 @@ -class OwnerUuidIndex < ActiveRecord::Migration +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + +class OwnerUuidIndex < ActiveRecord::Migration[4.2] def tables_with_owner_uuid - all_tables = ActiveRecord::Base.connection.tables - my_tables = [] - all_tables.each do |table| - columns = ActiveRecord::Base.connection.columns(table) - uuid_column = columns.select do |column| - column.name == 'owner_uuid' - end - my_tables << table if !uuid_column.empty? - end - my_tables + %w{api_clients authorized_keys collections groups humans + job_tasks jobs keep_disks keep_services links logs + nodes pipeline_instances pipeline_templates repositories + specimens traits users virtual_machines} end def up @@ -20,7 +18,13 @@ class OwnerUuidIndex < ActiveRecord::Migration def down tables_with_owner_uuid.each do |table| - remove_index table.to_sym, :owner_uuid + indexes = ActiveRecord::Base.connection.indexes(table) + owner_uuid_index = indexes.select do |index| + index.columns == ['owner_uuid'] + end + if !owner_uuid_index.empty? + remove_index table.to_sym, :owner_uuid + end end end end