running single migration file

hi all,

         in my db/migrate folder im having many migrations files that creates tables,add columns,and remove columns.i created a new migration file now and can i run only this new migration file using rake to run a specific migration using rake command.people know it help me please.

You can do:    rake db:migrate VERSION=12 to run the migrations necessary to get to version 12 from wherever you are. If the database is at version 11, that will cause the 012_* up migration to run, if at 13, the 012_* down migration will run. There is no command to pluck a particular migration out of the middle and run it (up or down).

Normally, you just add the migration and run: rake db:migrate and it does the right thing. I tend to make a backup of the development database and then run migrations forward VERSION=12 and then backward VERSION=11 until I'm sure that the migration is reversible (usually when there's some non-trivial data-munging going on).


Rob Biedenharn

For specific updates you can manipulate the schema.rb file accordingly and load it. rake db:schema:dump dumps the schema and load does the opposite. So you can dump, include all the migration changes you want and load for a quick solution.