diff options
author | yui-knk <spiketeika@gmail.com> | 2015-08-30 09:21:36 +0900 |
---|---|---|
committer | yui-knk <spiketeika@gmail.com> | 2015-08-30 09:21:36 +0900 |
commit | e16c93400be814b8ea961ae58b00890e3860a8d8 (patch) | |
tree | 96d650d5b724bb18b2d58dd0ab65f9dec593a788 /activerecord/lib/active_record | |
parent | bef377c666d54719ec8bd58979da55fd48cb5dfd (diff) | |
download | rails-e16c93400be814b8ea961ae58b00890e3860a8d8.tar.gz rails-e16c93400be814b8ea961ae58b00890e3860a8d8.tar.bz2 rails-e16c93400be814b8ea961ae58b00890e3860a8d8.zip |
Add detailed error message to `IrreversibleMigration`
Diffstat (limited to 'activerecord/lib/active_record')
-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 6a0539e938..73dc51912a 100644 --- a/activerecord/lib/active_record/migration/command_recorder.rb +++ b/activerecord/lib/active_record/migration/command_recorder.rb @@ -69,7 +69,12 @@ module ActiveRecord # invert the +command+. def inverse_of(command, args, &block) method = :"invert_#{command}" - raise IrreversibleMigration, "This migration uses #{command} that is not automatically reversible, please define down method" unless respond_to?(method, true) + raise IrreversibleMigration, <<-MSG.strip_heredoc unless respond_to?(method, true) + This migration uses #{command} that is not automatically reversible. + There are two ways to mitigate this problem. + 1. Define up and down methods instead of change method + 2. Use reversible method in change method + MSG send(method, args, &block) end |