Guest User

Untitled

a guest
Mar 3rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. require 'erb'
  2.  
  3. before "deploy:setup", :db
  4. after "deploy:update_code", "db:symlink"
  5.  
  6. namespace :db do
  7. desc "Create database yaml in shared path"
  8. task :default do
  9. db_config = ERB.new <<-EOF
  10. base: &base
  11. adapter: mysql
  12. socket: /tmp/mysql.sock
  13. username: #{user}
  14. password: #{password}
  15.  
  16. development:
  17. database: #{application}_dev
  18. <<: *base
  19.  
  20. test:
  21. database: #{application}_test
  22. <<: *base
  23.  
  24. production:
  25. database: #{application}_prod
  26. <<: *base
  27. EOF
  28.  
  29. run "mkdir -p #{shared_path}/config"
  30. put db_config.result, "#{shared_path}/config/database.yml"
  31. end
  32.  
  33. desc "Make symlink for database yaml"
  34. task :symlink do
  35. run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  36. end
  37. end
Add Comment
Please, Sign In to add comment