/ Published in: Rails
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
module ActiveRecord module ConnectionAdapters module SchemaStatements def cannot_undo! raise ActiveRecord::IrreversibleMigration.new("********** This migration cannot be undone ***********************************") end end end end