Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

database.yml deployment best practice

Tags:

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.

like image 760
robzolkos Avatar asked Apr 26 '11 01:04

robzolkos


2 Answers

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
like image 77
Jake Dempsey Avatar answered Nov 23 '22 00:11

Jake Dempsey


My deployment script was breaking using the after "deploy:update_code" hook because that step seemed to be trying to access the DB already. So I do:

before "deploy:assets:precompile", 'deploy:symlink_shared'

namespace :deploy do

  task :symlink_shared do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
end
like image 34
Dan Caddigan Avatar answered Nov 23 '22 00:11

Dan Caddigan