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: 20170509123922_add_references_to_bs_request_action.rb
    path of file: ./repos/open-build-service/src/api/db/migrate
    
    the code of the file until where you have to start completion: class AddReferencesToBsRequestAction < ActiveRecord::Migration[5.0]
  def up
    add_reference(:bs_request_actions, :target_package, index: true)
    add_reference(:bs_request_actions, :target_project, index: true)
    add_reference(:bs_request_actions, :source_package, index: true)
    add_reference(:bs_request_actions, :source_project, index: true)

    sql = <<-SQL.squish
      UPDATE bs_request_actions
      INNER JOIN projects ON projects.name = bs_request_actions.target_project
      SET bs_request_actions.target_project_id = projects.id
      WHERE bs_request_actions.target_project IS NOT NULL
    SQL
    execute(sql)

    sql = <<-SQL.squish
      UPDATE bs_request_actions
      INNER JOIN projects ON projects.name = bs_request_actions.target_project
      INNER JOIN packages ON packages.name = bs_request_actions.target_package AND packages.project_id = projects.id
      SET bs_request_actions.target_package_id = packages.id
      WHERE bs_request_actions.target_project IS NOT NULL AND bs_request_actions.target_package IS NOT NULL
    SQL
    ex
    
  def up
    add_reference(:bs_request_actions, :target_package, index: true)
    add_reference(:bs_request_actions, :target_project, index: true)
    add_reference(:bs_request_actions, :source_package, index: true)
    add_reference(:bs_request_actions, :source_project, index: true)

    sql = <<-SQL.squish
      UPDATE bs_request_actions
      INNER JOIN projects ON projects.name = bs_request_actions.target_project
      SET bs_request_actions.target_project_id = projects.id
      WHERE bs_request_actions.target_project IS NOT NULL
    SQL
    execute(sql)

    sql = <<-SQL.squish
      UPDATE bs_request_actions
      INNER JOIN projects ON projects.name = bs_request_actions.target_project
      INNER JOIN packages ON packages.name = bs_request_actions.target_package AND packages.project_id = projects.id
      SET bs_request_actions.target_package_id = packages.id
      WHERE bs_request_actions.target_project IS NOT NULL AND bs_request_actions.target_package IS NOT NULL
    SQL
    execute(sql)

    sql = <<-SQL.squish
      UPDATE bs_request_actions
      INNER JOIN projects ON projects.name = bs_request_actions.source_project
      SET bs_request_actions.source_project_id = projects.id
      WHERE bs_request_actions.source_project IS NOT NULL
    SQL
    execute(sql)

    sql = <<-SQL.squish
      UPDATE bs_request_actions
      INNER JOIN projects ON projects.name = bs_request_actions.source_project
      INNER JOIN packages ON packages.name = bs_request_actions.source_package AND packages.project_id = projects.id
      SET bs_request_actions.source_package_id = packages.id
      WHERE bs_request_actions.source_project IS NOT NULL AND bs_request_actions.source_package IS NOT NULL
    SQL
    execute(sql)
  end