diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2011-07-02 23:43:13 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2011-07-02 23:43:13 +0530 |
commit | 15f35c0ac0adb5cdec8dfdba407e2ad42172121e (patch) | |
tree | 043b8fa46e4d9705d7093384f86f80ccbfad3744 /activerecord/lib/active_record/migration | |
parent | 908be47781de892779639d5ae83b3471d46e6e48 (diff) | |
download | rails-15f35c0ac0adb5cdec8dfdba407e2ad42172121e.tar.gz rails-15f35c0ac0adb5cdec8dfdba407e2ad42172121e.tar.bz2 rails-15f35c0ac0adb5cdec8dfdba407e2ad42172121e.zip |
Reversing the changes done in c278a2c while still resolving #1857.
The changes broke bulk migration tests and were fixed in 4d256bc6;
however that brought back the issue of #1857 and so this commit goes
back to the original scenario and just adds change_table to the list
of methods which are to be recorded in the CommandRecorder. The
method_missing now delegates all calls to the underlying connection as
before.
Diffstat (limited to 'activerecord/lib/active_record/migration')
-rw-r--r-- | activerecord/lib/active_record/migration/command_recorder.rb | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/migration/command_recorder.rb b/activerecord/lib/active_record/migration/command_recorder.rb index 4a01313c61..311789aa7f 100644 --- a/activerecord/lib/active_record/migration/command_recorder.rb +++ b/activerecord/lib/active_record/migration/command_recorder.rb @@ -48,7 +48,7 @@ module ActiveRecord super || delegate.respond_to?(*args) end - [:create_table, :rename_table, :add_column, :remove_column, :rename_index, :rename_column, :add_index, :remove_index, :add_timestamps, :remove_timestamps, :change_column, :change_column_default].each do |method| + [:create_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].each do |method| class_eval <<-EOV, __FILE__, __LINE__ + 1 def #{method}(*args) # def create_table(*args) record(:"#{method}", args) # record(:create_table, args) @@ -93,15 +93,11 @@ module ActiveRecord [:remove_timestamps, args] end - # Record all the methods called in the +change+ method of a migration. - # This will ensure that IrreversibleMigration is raised when the corresponding - # invert_method does not exist while the migration is rolled back. + # Forwards any missing method call to the \target. def method_missing(method, *args, &block) - if delegate.respond_to?(method) - delegate.send(method, *args, &block) - else - record(method, args) - end + @delegate.send(method, *args, &block) + rescue NoMethodError => e + raise e, e.message.sub(/ for #<.*$/, " via proxy for #{@delegate}") end end |