X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4f552c0187f8c31d94ff74485c57ef7f9888597e..cd3966ee048de85447418f00869eec59b38fd7b2:/services/api/db/migrate/20140325175653_remove_kind_columns.rb diff --git a/services/api/db/migrate/20140325175653_remove_kind_columns.rb b/services/api/db/migrate/20140325175653_remove_kind_columns.rb index 115048d091..3303fd9db1 100644 --- a/services/api/db/migrate/20140325175653_remove_kind_columns.rb +++ b/services/api/db/migrate/20140325175653_remove_kind_columns.rb @@ -1,4 +1,10 @@ -class RemoveKindColumns < ActiveRecord::Migration +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + +class RemoveKindColumns < ActiveRecord::Migration[4.2] + include CurrentApiClient + def up remove_column :links, :head_kind remove_column :links, :tail_kind @@ -9,5 +15,17 @@ class RemoveKindColumns < ActiveRecord::Migration add_column :links, :head_kind, :string add_column :links, :tail_kind, :string add_column :logs, :object_kind, :string + + act_as_system_user do + Link.all.each do |l| + l.head_kind = ArvadosModel::resource_class_for_uuid(l.head_uuid).kind if l.head_uuid + l.tail_kind = ArvadosModel::resource_class_for_uuid(l.tail_uuid).kind if l.tail_uuid + l.save + end + Log.all.each do |l| + l.object_kind = ArvadosModel::resource_class_for_uuid(l.object_uuid).kind if l.object_uuid + l.save + end + end end end