Created
August 26, 2009 22:08
-
-
Save jpemberthy/175882 to your computer and use it in GitHub Desktop.
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
config = Rails::Configuration.new | |
database = config.database_configuration[RAILS_ENV]["database"] | |
username = config.database_configuration[RAILS_ENV]["username"] | |
password = config.database_configuration[RAILS_ENV]["password"] | |
namespace :db do | |
#rake db:dump | |
desc "dumps the database to a sql file" | |
task :dump => :environment do | |
puts "Creating #{database}_dump.sql file." | |
`mysqldump -u "#{username}" --password="#{password}" "#{database}" > "#{database}"_dump.sql` | |
end | |
#rake db:dumpimport - Resets the DB. | |
desc "imports the #{database}_dump.sql file to the current db" | |
task :dumpimport => [:environment, :reset] do | |
`mysql -u root --password="#{password}" "#{database}" < "#{database}"_dump.sql` | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment