From e16c93400be814b8ea961ae58b00890e3860a8d8 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 30 Aug 2015 09:21:36 +0900 Subject: Add detailed error message to `IrreversibleMigration` --- activerecord/lib/active_record/migration/command_recorder.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') 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 -- cgit v1.2.3