diff options
author | Eileen M. Uchitelle <eileencodes@users.noreply.github.com> | 2018-09-27 11:45:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 11:45:11 -0400 |
commit | cb6ea5148bffdc6266740e2e7bf30965f3060680 (patch) | |
tree | 0888353d1ebce507db0aa066dba47f4fa5f5c1ec /activerecord/lib/active_record/migration.rb | |
parent | 8a0194f1514fc2374b18db909f78f733ba0857b9 (diff) | |
parent | bdd8d5898710e727c55b514804a221b6eddbda41 (diff) | |
download | rails-cb6ea5148bffdc6266740e2e7bf30965f3060680.tar.gz rails-cb6ea5148bffdc6266740e2e7bf30965f3060680.tar.bz2 rails-cb6ea5148bffdc6266740e2e7bf30965f3060680.zip |
Merge pull request #31604 from fatkodima/reverting-transaction
Fix `transaction` reverting for migrations
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 9651e69edd..d712d4b3cf 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -678,15 +678,13 @@ module ActiveRecord if connection.respond_to? :revert connection.revert { yield } else - recorder = CommandRecorder.new(connection) + recorder = command_recorder @connection = recorder suppress_messages do connection.revert { yield } end @connection = recorder.delegate - recorder.commands.each do |cmd, args, block| - send(cmd, *args, &block) - end + recorder.replay(self) end end end @@ -962,6 +960,10 @@ module ActiveRecord yield end end + + def command_recorder + CommandRecorder.new(connection) + end end # MigrationProxy is used to defer loading of the actual migration classes |