Guest User

Untitled

a guest
Feb 28th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. before "deploy:setup", "db:configure"
  2. after "deploy:update_code", "db:symlink"
  3.  
  4. set(:database_username, "arubything")
  5. # set(:database_password, "root")
  6. set(:development_database) { application + "_development" }
  7. set(:test_database) { application + "_test" }
  8. set(:production_database) { application + "_production" }
  9.  
  10. namespace :db do
  11. desc "Create database yaml in shared path"
  12. task :configure do
  13. set :database_password do
  14. Capistrano::CLI.password_prompt "Database Password: "
  15. end
  16.  
  17. db_config = <<-EOF
  18. base: &base
  19. adapter: mysql
  20. encoding: utf8
  21. username: #{database_username}
  22. password: #{database_password}
  23.  
  24. development:
  25. database: #{development_database}
  26. <<: *base
  27.  
  28. test:
  29. database: #{test_database}
  30. <<: *base
  31.  
  32. production:
  33. database: #{production_database}
  34. <<: *base
  35. EOF
  36.  
  37. run "mkdir -p #{shared_path}/config"
  38. put db_config, "#{shared_path}/config/database.yml"
  39. end
  40.  
  41. desc "Make symlink for database yaml"
  42. task :symlink do
  43. run "ln -nfs #{shared_path}/config/database.yml #{latest_release}/config/database.yml"
  44. end
  45. end
Add Comment
Please, Sign In to add comment