Skip to content

Instantly share code, notes, and snippets.

@alkesh
Created September 9, 2010 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alkesh/571911 to your computer and use it in GitHub Desktop.
Save alkesh/571911 to your computer and use it in GitHub Desktop.
db_migrate_all.rake
namespace :db do
namespace :migrate do
desc "Migrate development, test and production databases"
task :all => :environment do
Dir.glob('config/environments/*.rb').map{|f| File.basename(f).sub(/\.rb$/, '')}.each do |env|
puts "Migrating #{env} database..."
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[env])
ActiveRecord::Migrator.migrate("db/migrate/")
ActiveRecord::Base.remove_connection
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment