How to get the schema version number out of your Rails migrations
When you want to revert your Rails migration you need the version number so that you can perform the rollback:
rake db:migration VERSION=?One way is to access the database and take a look in the
schema_info table to find the version number.An easier way is to add an additional task to Rake (found via the Quoted-Printable):
namespace :db doCopy this code into a file called
desc 'Print the current database migration version number'
task :version => :environment do
puts ActiveRecord::Migrator.current_version
end
end
db_version.rake and place it in the lib/tasks directory within your Rails application.To find out the current version number, simply run:
rake db:versionTechnorati Tags: Rails, Version, Migration, Rake, QuotedPrintable, Andrew Beacock



Buy Stuff From Amazon