class AddSecretTokenForEveryJoinRequest < ActiveRecord::Migration
  def up
    JoinRequest.all.map(&:save)
  end

  def down
  end
end

class AddSecretTokenForEveryJoinRequest < ActiveRecord::Migration
  def up
    connection = ActiveRecord::Base.connection()
    ids = connection.execute("SELECT id from `join_requests`;").to_a

    ids.each do |id|
      tok = SecureRandom.urlsafe_base64(10)
      connection.execute("UPDATE join_requests SET secret_token = '#{tok}' WHERE id = '#{id.first}'")
    end
  end

  def down
  end
end

Use sql syntax for join_request migration
Use sql syntax for join_request migration
