Monkeypatch for easier to read migrations

/ Published in: Rails
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  1. module ActiveRecord
  2. module ConnectionAdapters
  3. module SchemaStatements
  4. def cannot_undo!
  5. raise"********** This migration cannot be undone ***********************************")
  6. end
  7. end
  8. end
  9. end

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.