Created
September 9, 2010 14:12
-
-
Save alkesh/571911 to your computer and use it in GitHub Desktop.
db_migrate_all.rake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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