aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/migration
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2012-11-11 14:43:57 -0500
committerMarc-Andre Lafortune <github@marc-andre.ca>2012-12-21 13:54:51 -0500
commit99770e4c659013461fb308040e3d594f2038ed24 (patch)
tree9d929f687f5ff003d0d23f962be7e196c2196f41 /activerecord/lib/active_record/migration
parent65e154f33b54acf40b51082fc5b681ba605015d9 (diff)
downloadrails-99770e4c659013461fb308040e3d594f2038ed24.tar.gz
rails-99770e4c659013461fb308040e3d594f2038ed24.tar.bz2
rails-99770e4c659013461fb308040e3d594f2038ed24.zip
Add Migration#reversible for reversible data operations [#8267]
Diffstat (limited to 'activerecord/lib/active_record/migration')
-rw-r--r--activerecord/lib/active_record/migration/command_recorder.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/migration/command_recorder.rb b/activerecord/lib/active_record/migration/command_recorder.rb
index a79428b69a..d0e54240d3 100644
--- a/activerecord/lib/active_record/migration/command_recorder.rb
+++ b/activerecord/lib/active_record/migration/command_recorder.rb
@@ -72,7 +72,7 @@ module ActiveRecord
[:create_table, :create_join_table, :change_table, :rename_table, :add_column, :remove_column,
:rename_index, :rename_column, :add_index, :remove_index, :add_timestamps, :remove_timestamps,
- :change_column, :change_column_default, :add_reference, :remove_reference,
+ :change_column, :change_column_default, :add_reference, :remove_reference, :transaction,
].each do |method|
class_eval <<-EOV, __FILE__, __LINE__ + 1
def #{method}(*args, &block) # def create_table(*args, &block)
@@ -85,6 +85,10 @@ module ActiveRecord
private
+ def invert_transaction(args, &block)
+ [:transaction, args, block]
+ end
+
def invert_create_table(args)
[:drop_table, [args.first]]
end