Skip to content

Instantly share code, notes, and snippets.

@toddsampson
Last active December 28, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddsampson/7456579 to your computer and use it in GitHub Desktop.
Save toddsampson/7456579 to your computer and use it in GitHub Desktop.
Database.yml and multi-stage Capistrano deployment blog post: http://www.cloudspace.com/blog/2009/09/18/database-yml-and-multi-stage-capistrano-deployment/
after "deploy:symlink", :update_config_file
after "deploy:symlink", :update_database_yml
PRODUCTION_DB_INTERNAL_IP = "1.2.3.4"
desc "Update database.yml with production information"
task :update_database_yml do
replacements = { "DATABASE_IP" => PRODUCTION_DB_INTERNAL_IP }
replacements.each_pair do |pattern, sub|
run "sed -i 's/#{pattern}/#{sub}/' /path/to/deploy/current/config/database.yml"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment