Irreversible Migrations


#1

Hi,

To make a migration irreversable, one has to execute “raise
IrreversibleMigration”. This is how it’s documented everywhere. However,
when I do that, I get this:

rake aborted!
uninitialized constant IrreversibleMigration

This is the migration (the file is called 022_ldap_fix.rb):

class LdapFix < ActiveRecord::Migration
def self.up
execute File.open( FILE.gsub(/.rb$/, ‘.pgsql’) ).read
end

def self.down
raise IrreversibleMigration
end
end

I’m using a frozen gem of Rails 1.1.

What am I doing wrong?


#2

But what’s wrong ? it seems that your db have been rolled back to this
version+1 migration and then : rake stops…

Thus, your migration is reversible as the previous versions can’t be
executed


#3

Nuno wrote:

But what’s wrong ? it seems that your db have been rolled back to this
version+1 migration and then : rake stops…

Thus, your migration is reversible as the previous versions can’t be
executed

In practice yes, but that would mean you could just execute
“adsflkjadslfk
asldfkj asdflk” for every irreversable migration… Not very eloquent.
In
fact, downright ugly…

Rails has methods like ActiveRecord::Base.reload just to avoid doing
ActiveRecord::Base.find(sameobject.id), or a :first modifier on the find
method to avoid having to lookup result 0 in the resultset yourself.
Programming isn’t just about making things work, the programming itself
should be clean and intuitive.


#4

On Thursday 06 April 2006 16:43, Wiebe C. wrote:

What am I doing wrong?

To answer my own question, you have to do:

raise ActiveRecord::IrreversibleMigration