Is there an easy way to run a single migration? I don't want to migrate to a certain version I just want to run a specific one.
Is this something that you ran once as a migration because it happened to be needed, then turns out to be a useful query that might need to get run a number of times?
perhaps you should refactor the contents of the migration into a model or other object, then have the migration reference that new location.
Then you can simply execute the new object at your lesure by invoking ruby on the command line.
Assuming fairly recent version of Rails you can always run:
rake db:migrate:up VERSION=20090408054532
Where version is the timestamp in the filename of the migration.
You can just run the code directly out of the ruby file:
irb
>> require "db/migrate/20090408054532_add_foos.rb"
>> AddFoos.up
An alternative way (without IRB) which relies on the fact that require returns an array of class names:
script/runner 'require("db/migrate/20090408054532_add_foos.rb").first.constantize.up'
Note that if you do this, it probably won't update the schema_migrations
table, but it seems like that's what you want anyway.