1 class OwnerUuidIndex < ActiveRecord::Migration
2 def tables_with_owner_uuid
3 %w{api_clients authorized_keys collections groups humans
4 job_tasks jobs keep_disks keep_services links logs
5 nodes pipeline_instances pipeline_templates repositories
6 specimens traits users virtual_machines}
10 tables_with_owner_uuid.each do |table|
11 add_index table.to_sym, :owner_uuid
16 tables_with_owner_uuid.each do |table|
17 indexes = ActiveRecord::Base.connection.indexes(table)
18 owner_uuid_index = indexes.select do |index|
19 index.columns == ['owner_uuid']
21 if !owner_uuid_index.empty?
22 remove_index table.to_sym, :owner_uuid