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: 20140820124117_undo_wrong_migration20140801080705_add_users_to_events.rb
    path of file: ./repos/osem/db/migrate
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class UndoWrongMigration20140801080705AddUsersToEvents < ActiveRecord::Migration
  class TempEvent < ActiveRecord::Base
    self.table_name = 'events'
  end

  class TempUser < ActiveRecord::Base
    self.table_name = 'users'
  end

  class TempEventUser < ActiveRecord::Base
    self.table_name = 'event_users'
   
    
  def up
    if ActiveRecord::Migrator.get_all_versions.include? 20140801080705
      user_deleted = TempUser.find_by(email: 'deleted@localhost.osem')

      TempEvent.all.each do |event|
        whodunnit = Version.find_by(item_type: 'Event', item_id: event.id, event: 'create').whodunnit
        original_user = TempUser.find_by(id: whodunnit)

        if original_user.blank?
          original_submitter = user_deleted
        else
          original_submitter = original_user
        end

        # Substitute submitter record
        submitter = TempEventUser.find_by(event_id: event.id, event_role: 'submitter')
        submitter.user_id = original_submitter.id
        submitter.save!

        # Substitute speaker record
        speaker = TempEventUser.find_by(event_id: event.id, event_role: 'speaker')
        speaker.user_id = original_submitter.id
        speaker.save!
      end