Tuesday, January 20, 2009

Rails Migrations - Running a Single Migration

We all know the good old
rake db:migrate
And we all know the Rails 2.x
rake db:migrate:rollback
to go back in time and fix what we did.
Now, in Rails 2.x you can specify a single migration by specifing one of the each
rake db:migrate:up VERSION=<migration_timestamp> # Runs the self.up
rake db:migrate:down VERSION=<migration_timestamp> # Runs the self.down
Note that migrations are meant to be concurrent and that's the most basic purpose in which they are there for, executing an out of line migration may cause you problems in the future, so try to stay as clean as possible when dealing with migrations

2 comments:

  1. nice!

    you just solved me an ancient problem!
    thanks.

    ReplyDelete
  2. NP.
    I am always up to some old-school quirks :)

    ReplyDelete

Tell me what you think