X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3212cecb5c090d2f331fd964a8855eaad508fdb9..7ced789760c7e7b4df4fe3ddecf0611ff1fe12e5:/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 0859d46818..e7e38b0716 100644 --- a/services/api/db/migrate/20141208164553_owner_uuid_index.rb +++ b/services/api/db/migrate/20141208164553_owner_uuid_index.rb @@ -1,9 +1,9 @@ class OwnerUuidIndex < ActiveRecord::Migration def tables_with_owner_uuid - ActiveRecord::Base.connection.tables.select do |table| - columns = ActiveRecord::Base.connection.columns(table) - columns.collect(&:name).include? 'owner_uuid' - end + %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 @@ -14,7 +14,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