The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Managing database.yml with Capistrano

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jeremy Voorhis

Posts: 212
Nickname: jvoorhis
Registered: Oct, 2005

Jeremy Voorhis is a Rubyist in northeast Ohio.
Managing database.yml with Capistrano Posted: Jul 7, 2006 10:21 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jeremy Voorhis.
Original Post: Managing database.yml with Capistrano
Feed Title: JVoorhis
Feed URL: http://feeds.feedburner.com/jvoorhis
Feed Description: JVoorhis is a Rubyist in northeast Ohio. He rambles about Ruby on Rails, development practices, other frameworks such as Django, and on other days he is just full of snark.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jeremy Voorhis
Latest Posts From JVoorhis

Advertisement

At PLANET ARGON, we typically do not keep our database.yml files in subversion, leaving behind a database.yml.example file instead. This makes it easy for us to share the repository with multiple developers who work on their own conventions, or sometimes an alternate database engine. We still want to have a one-step automated deployment process, however, and ssh-ing into the server to create database.yml manually just feels a little… uncouth.

The solution? Building upon Tim’s post at “http://toolmantim.com/article/2006/5/26/setting_up_capistrano_on_segpub”, our Capistrano deployment recipe now writes database.yml after we deploy, and symlinks it to the latest release directory after we update the code. Here is the code that lets us do that:



desc "Create database.yml in shared/config" 
task :after_setup do
  write_database_configuration
end

desc "Link in the production database.yml" 
task :after_update_code do
  link_database_configuration
end

def write_database_configuration
  FileUtils.mkdir_p "#{shared_dir}/config" 
  File.open("#{shared_dir}/config/database.yml", 'w') do |f|
    f.write %Q{login: &login
  adapter: postgresql
  host: localhost
  port: #{postgresql_port}
  username: #{user}
  password: #{password}

development:
  database: #{application}_development
  <<: *login

test:
  database: #{application}_test
  <<: *login

production:
  database: #{application}_production
  <<: *login
}
  end
end

def link_database_configuration
  run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml" 
end

Read: Managing database.yml with Capistrano

Topic: Rails :: Diferencia entre el respond_to y el request.xhr? Previous Topic   Next Topic Topic: Rails Core Weekly June 19 - July 2

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use