diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-01-08 15:51:06 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-01-08 15:51:06 +0100 |
commit | 724509a9d5322ff502aefa90dd282ba33a281a96 (patch) | |
tree | 24626ff4ef1bbe98775ee08ea9e35ab9941e4e71 /activerecord/lib/active_record/migration | |
parent | b502e3db958fdfd27453db52f6f455183a449831 (diff) | |
download | rails-724509a9d5322ff502aefa90dd282ba33a281a96.tar.gz rails-724509a9d5322ff502aefa90dd282ba33a281a96.tar.bz2 rails-724509a9d5322ff502aefa90dd282ba33a281a96.zip |
make `change_column_null` reversible. Closes #13576.
Closes #13623.
Diffstat (limited to 'activerecord/lib/active_record/migration')
-rw-r--r-- | activerecord/lib/active_record/migration/command_recorder.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/migration/command_recorder.rb b/activerecord/lib/active_record/migration/command_recorder.rb index 17300f0598..9139ad953c 100644 --- a/activerecord/lib/active_record/migration/command_recorder.rb +++ b/activerecord/lib/active_record/migration/command_recorder.rb @@ -74,7 +74,7 @@ module ActiveRecord :rename_index, :rename_column, :add_index, :remove_index, :add_timestamps, :remove_timestamps, :change_column_default, :add_reference, :remove_reference, :transaction, :drop_join_table, :drop_table, :execute_block, :enable_extension, - :change_column, :execute, :remove_columns, # irreversible methods need to be here too + :change_column, :execute, :remove_columns, :change_column_null # irreversible methods need to be here too ].each do |method| class_eval <<-EOV, __FILE__, __LINE__ + 1 def #{method}(*args, &block) # def create_table(*args, &block) @@ -157,6 +157,11 @@ module ActiveRecord alias :invert_add_belongs_to :invert_add_reference alias :invert_remove_belongs_to :invert_remove_reference + def invert_change_column_null(args) + args[2] = !args[2] + [:change_column_null, args] + end + # Forwards any missing method call to the \target. def method_missing(method, *args, &block) if @delegate.respond_to?(method) |