1 class OwnerUuidIndex < ActiveRecord::Migration
2 def tables_with_owner_uuid
3 all_tables = ActiveRecord::Base.connection.tables
5 all_tables.each do |table|
6 columns = ActiveRecord::Base.connection.columns(table)
7 uuid_column = columns.select do |column|
8 column.name == 'owner_uuid'
10 my_tables << table if !uuid_column.empty?
16 tables_with_owner_uuid.each do |table|
17 add_index table.to_sym, :owner_uuid
22 tables_with_owner_uuid.each do |table|
23 remove_index table.to_sym, :owner_uuid