small medium large xlarge


Pierre says:

The hint says to copy after deploy:update_code but this doesn’t work at least not with my installation. Capistrano is processing deploy:update_code and than deploy:create_symlink. If I copy database.yml right after deploy:update_code it would be copied to the old release and not be available in the current folder.

So this is my solution:

On the server copy current/config/database.yml to shared/database.yml

pierre@server:~/depot$ cp current/config/database.yml shared/database.yml

Add a task to config/deploy.rb to copy database.yml from the server’s shared folder to the server’s current/config folder

after 'deploy:create_symlink', 'copy_database_yml'
desc “copy shared/database.yml to current/config/database.yml”
task :copy_database_yml do
  run “cp #{shared_path}/database.yml #{current_path}/config/database.yml”

Now we have to remove database.yml from the repository

pierre@dev:~/work/depot$ git rm config/database.yml
pierre@dev:~/work/depot$ git commit -a -m “removed config/database.yml and added task to copy database.yml from shared to current/config”
pierre@dev:~/work/depot$ git push

Now we can deploy the application with automatically copying database.yml tho the current folder

pierre@dev:~/work/depot$ cap deploy
Page History
  • V4: Pierre Sugar [over 5 years ago]
  • V3: Pierre Sugar [over 5 years ago]
  • V2: Pierre Sugar [over 5 years ago]
  • V1: Pierre Sugar [over 5 years ago]