I often find myself needing to know what migration version my database is at. There is the ./script/about script, which tells me the version number (and a host of other things), but I don’t want to have to look through all that. All I want is the migration number I’m currently at.
Here is a simple rake task you can plop in your lib/tasks directory that will print the current version.
# lib/tasks/db_migration_version.rake
namespace :db do
desc 'Print the current database migration version number'
task :version => :environment do
puts ActiveRecord::Migrator.current_version
end
end
Example usage:
$ rake db:version 29
Fun!


Niiiiice…I’ve wanted this for a while now! Thanks!