Guest User

Untitled

a guest
Mar 11th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. config = Rails::Configuration.new
  2. database = config.database_configuration[RAILS_ENV]["database"]
  3. username = config.database_configuration[RAILS_ENV]["username"]
  4. password = config.database_configuration[RAILS_ENV]["password"]
  5.  
  6. namespace :db do
  7.  
  8. #rake db:dump
  9. desc "dumps the database to a sql file"
  10. task :dump => :environment do
  11. puts "Creating #{database}_dump.sql file."
  12. `mysqldump -u "#{username}" --password="#{password}" "#{database}" > "#{database}"_dump.sql`
  13. end
  14.  
  15. #rake db:dumpimport - Resets the DB.
  16. desc "imports the #{database}_dump.sql file to the current db"
  17. task :dumpimport => [:environment, :reset] do
  18. `mysql -u root --password="#{password}" "#{database}" < "#{database}"_dump.sql`
  19. end
  20.  
  21. end
Add Comment
Please, Sign In to add comment