You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 20130118002239_rename_metadata_attributes.rb
    path of file: ./repos/arvados/services/api/db/migrate
    
    the code of the file until where you have to start completion: # Copyright (C) The Arvados Authors. All rights reserved.
#
# SPDX-License-Identifier: AGPL-3.0

class RenameMetadataAttributes < ActiveRecord::Migration[4.2]
  def up
    rename_column :metadata, :target_kind, :tail_kind
    rename_column :metadata, :target_uuid, :tail
    rename_column :metadata, :value, :head
    rename_column :metadata, :key, :name
    add_column :metadata, :head
    
  def up
    rename_column :metadata, :target_kind, :tail_kind
    rename_column :metadata, :target_uuid, :tail
    rename_column :metadata, :value, :head
    rename_column :metadata, :key, :name
    add_column :metadata, :head_kind, :string
    add_index :metadata, :head
    add_index :metadata, :head_kind
    add_index :metadata, :tail
    add_index :metadata, :tail_kind
    begin
      Metadatum.where('head like ?', 'orvos#%').each do |m|
        kind_uuid = m.head.match /^(orvos\#.*)\#([-0-9a-z]+)$/
        if kind_uuid
          m.update(head_kind: kind_uuid[1],
                              head: kind_uuid[2])
        end
      end