Monday, November 13, 2006

Rails: Get the schema_info version number from Rake

Recently a coworker asked if there was a simple way to get the current version out of the schema_info table. Of course, one simple answer is to simply look in the database.

However, if you want to quickly pull the version from a command line, this rake task should do the trick*:
namespace :db do
desc "Returns the current schema version"
task :version => :environment do
puts "Current version: " + ActiveRecord::Migrator.current_version.to_s
end
end
* 2nd version submitted by Doug as a comment.
Post a Comment