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: 20190726092304_add_journal_to_inventory.rb
    path of file: ./repos/ekylibre/db/migrate
    
    the code of the file until where you have to start completion: class AddJournalToInventory < ActiveRecord::Migration[4.2]
  def change
    add_reference :inventories, :journal, foreign_key: true

    reversible do |dir|
      dir
    
  def change
    add_reference :inventories, :journal, foreign_key: true

    reversible do |dir|
      dir.up do
        execute <<-SQL
          UPDATE inventories
          SET journal_id = (
            SELECT j.id
            FROM journals j
            WHERE j.nature = 'various'
              AND j.used_for_permanent_stock_inventory = 't'
          )
        SQL
      end
    end
  end