Add 'apps/arv-web/' from commit 'f9732ad8460d013c2f28363655d0d1b91894dca5'
[arvados.git] / services / api / db / migrate / 20141208164553_owner_uuid_index.rb
1 class OwnerUuidIndex < ActiveRecord::Migration
2   def tables_with_owner_uuid
3     ActiveRecord::Base.connection.tables.select do |table|
4       columns = ActiveRecord::Base.connection.columns(table)
5       columns.collect(&:name).include? 'owner_uuid'
6     end
7   end
8
9   def up
10     tables_with_owner_uuid.each do |table|
11       add_index table.to_sym, :owner_uuid
12     end
13   end
14
15   def down
16     tables_with_owner_uuid.each do |table|
17       remove_index table.to_sym, :owner_uuid
18     end
19   end
20 end