Search code examples
ruby-on-railsdeploymentcapistrano

database.yml deployment best practice


I don't check my database.yml file into source control and I was wondering what others do/best practice for copying this file over to the server when deploying.

I use Capistrano for deployment.


Solution

  • Currently, I keep a shared folder called shared that lives outside of my deply_to dirs. I keep my database.yml and other config files there and have a hook in cap to cp those over during deployment. Here is my simple cap task for doing the copy:

    after "deploy:update_code","deploy:config_symlink"
    
    namespace :deploy do
    
      task :config_symlink do
        run "cp #{shared_path}/../../shared/database.yml #{release_path}/config/database.yml"
      end
    end