Merge branch '8784-dir-listings'
[arvados.git] / services / api / db / migrate / 20130125220425_rename_created_by_to_owner.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class RenameCreatedByToOwner < ActiveRecord::Migration
6   def tables
7     %w{api_clients collections logs metadata nodes pipelines pipeline_invocations projects specimens users}
8   end
9
10   def up
11     tables.each do |t|
12       remove_column t.to_sym, :created_by_client
13       rename_column t.to_sym, :created_by_user, :owner
14     end
15   end
16
17   def down
18     tables.reverse.each do |t|
19       rename_column t.to_sym, :owner, :created_by_user
20       add_column t.to_sym, :created_by_client, :string
21     end
22   end
23 end