3147: PySDK tests use mock>=1.0 and easier mock side_effect.
[arvados.git] / services / api / db / migrate / 20140423132913_add_object_owner_to_logs.rb
1 class AddObjectOwnerToLogs < ActiveRecord::Migration
2   include CurrentApiClient
3
4   def up
5     add_column :logs, :object_owner_uuid, :string
6     act_as_system_user do
7       Log.find_in_batches(:batch_size => 500) do |batch|
8         upd = {}
9         ActiveRecord::Base.transaction do
10           batch.each do |log|
11             if log.properties["new_attributes"]
12               log.object_owner_uuid = log.properties['new_attributes']['owner_uuid']
13               log.save
14             elsif log.properties["old_attributes"]
15               log.object_owner_uuid = log.properties['old_attributes']['owner_uuid']
16               log.save
17             end
18           end
19         end
20       end
21     end
22   end
23
24   def down
25     remove_column :logs, :object_owner_uuid
26   end
27 end