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: 20140723110551_adopt_xpath_in_website_agent.rb
    path of file: ./repos/huginn/db/migrate
    
    the code of the file until where you have to start completion: class AdoptXpathInWebsiteAgent < ActiveRecord::Migration[4.2]
  class Agent < ActiveRecord::Base
    include JsonSerializedField
    json_serialize :options
  end

  def up
    Agent.where(type: 'Agents::WebsiteAgent').each do |agent|
      extract = agent.options['extract']

    
  def up
    Agent.where(type: 'Agents::WebsiteAgent').each do |agent|
      extract = agent.options['extract']
      next unless extract.is_a?(Hash) && extract.all? { |name, detail|
        detail.key?('xpath') || detail.key?('css')
      }

      agent.options_will_change!
      agent.options['extract'].each { |name, extraction|
        case
        when extraction.delete('text')
          extraction['value'] = 'string(.)'
        when attr = extraction.delete('attr')
          extraction['value'] = "@#{attr}"
        end
      }
      agent.save!
    end