Return to Snippet

Revision: 21942
at December 24, 2009 22:37 by sgtrock


Initial Code
module ActiveRecord
  module ConnectionAdapters
    module SchemaStatements
      def cannot_undo!
        raise ActiveRecord::IrreversibleMigration.new("**********  This migration cannot be undone ***********************************")
      end
    end
  end
end

Initial URL

                                

Initial Description
I never can remember the exact name of the exception to call in self.down for a migration that cannot be undone. So I decided to come up with something easier to remember. This feels more "ruby-ish" and "rails-ish" to me, and so far it works just fine. It also displays a message that is easier to pick out amongst all the other migration output on the screen so you can see at a glance that it failed.

Initial Title
Monkeypatch for easier to read migrations

Initial Tags
rails, ruby

Initial Language
Rails