ActiveRecord::Base.connection.begin_transaction(joinable: false)

at_exit do
  ActiveRecord::Base.connection.rollback_transaction
end

ActiveRecord::Base.connection.begin_transaction(joinable: false)

at_exit do
  if ActiveRecord::Base.connection.transaction_open?
    ActiveRecord::Base.connection.rollback_transaction
  end
end

FIX reload! within rails console --sandbox causes undefined method rollback upon exiting
FIX reload! within rails console --sandbox causes undefined method rollback upon exiting [https://github.com/rails/rails/issues/11834]
