Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment