1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #27596 from schneems/schneems/migrator-result

Preserve `up` and `down` return type
This commit is contained in:
Richard Schneeman 2017-01-06 20:24:11 -06:00 committed by GitHub
commit 7b13236818
2 changed files with 18 additions and 2 deletions

View file

@ -1170,9 +1170,10 @@ module ActiveRecord
def run_without_lock
migration = migrations.detect { |m| m.version == @target_version }
raise UnknownMigrationVersionError.new(@target_version) if migration.nil?
execute_migration_in_transaction(migration, @direction)
result = execute_migration_in_transaction(migration, @direction)
record_environment
result
end
# Used for running multiple migrations up to or down to a certain value.
@ -1181,11 +1182,12 @@ module ActiveRecord
raise UnknownMigrationVersionError.new(@target_version)
end
runnable.each do |migration|
result = runnable.each do |migration|
execute_migration_in_transaction(migration, @direction)
end
record_environment
result
end
# Stores the current environment in the database.

View file

@ -290,6 +290,20 @@ class MigratorTest < ActiveRecord::TestCase
assert_equal [[:up, 1], [:up, 2], [:up, 3]], calls
end
def test_migrator_output
_, migrator = migrator_class(3)
result = migrator.migrate("valid")
assert_equal(3, result.count)
# Nothing migrated from duplicate run
result = migrator.migrate("valid")
assert_equal(0, result.count)
result = migrator.rollback("valid")
assert_equal(1, result.count)
end
def test_migrator_rollback
_, migrator = migrator_class(3)