mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
b337390889
Closes #9483. There are SQL Queries that can't run inside a transaction. Since the Migrator used to wrap all Migrations inside a transaction there was no way to run these queries within a migration. This patch adds `self.disable_ddl_transaction!` to the migration to turn transactions off when necessary.
37 lines
993 B
Ruby
37 lines
993 B
Ruby
require "cases/helper"
|
|
|
|
module ActiveRecord
|
|
class Migration
|
|
class LoggerTest < ActiveRecord::TestCase
|
|
# mysql can't roll back ddl changes
|
|
self.use_transactional_fixtures = false
|
|
|
|
Migration = Struct.new(:name, :version) do
|
|
def disable_ddl_transaction; false end
|
|
def migrate direction
|
|
# do nothing
|
|
end
|
|
end
|
|
|
|
def setup
|
|
super
|
|
ActiveRecord::SchemaMigration.create_table
|
|
ActiveRecord::SchemaMigration.delete_all
|
|
end
|
|
|
|
def teardown
|
|
super
|
|
ActiveRecord::SchemaMigration.drop_table
|
|
end
|
|
|
|
def test_migration_should_be_run_without_logger
|
|
previous_logger = ActiveRecord::Base.logger
|
|
ActiveRecord::Base.logger = nil
|
|
migrations = [Migration.new('a', 1), Migration.new('b', 2), Migration.new('c', 3)]
|
|
ActiveRecord::Migrator.new(:up, migrations).migrate
|
|
ensure
|
|
ActiveRecord::Base.logger = previous_logger
|
|
end
|
|
end
|
|
end
|
|
end
|