21855: Change RPM repo quoting in Python READMEs
[arvados.git] / services / api / db / migrate / 20140423132913_add_object_owner_to_logs.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class AddObjectOwnerToLogs < ActiveRecord::Migration[4.2]
6   include CurrentApiClient
7
8   def up
9     add_column :logs, :object_owner_uuid, :string
10     act_as_system_user do
11       Log.find_in_batches(:batch_size => 500) do |batch|
12         upd = {}
13         ActiveRecord::Base.transaction do
14           batch.each do |log|
15             if log.properties["new_attributes"]
16               log.object_owner_uuid = log.properties['new_attributes']['owner_uuid']
17               log.save
18             elsif log.properties["old_attributes"]
19               log.object_owner_uuid = log.properties['old_attributes']['owner_uuid']
20               log.save
21             end
22           end
23         end
24       end
25     end
26   end
27
28   def down
29     remove_column :logs, :object_owner_uuid
30   end
31 end