Some useful rake tasks…
I wrote a couple handy rake tasks the other day and thought I’d post them for anyone else who might be interested.
DB Version – this one is handy when you are trying to get into sync with some new migrations, especially if any of the migrations have errors (I know…that should never happen :) )
desc "Get the current schema version"
task :version => :environment do
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
result = ActiveRecord::Base.connection.execute("select * from schema_info")
version = result.fetch_hash['version']
puts "Current Database Schema Version: #{version}"
end
Just add that code to your databases.rake and then you can rake db:version away.