Forum: Ruby on Rails Capistrano - how do I set up the database config?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-04-03 23:52
(Received via mailing list)
My app is set up without database.yml in version control.  I created a
shared_path/config dir, and put database.yml in it.  After I update
the code, I want to link the app's database.yml file to the shared
config.  So I added this task

desc 'Copy the database config'
task :after_update_code, :roles => :app do
  run "ln -s #{shared_path}/config/database.yml
#{current_path}/config/database.yml"
end

Unfortunately that doesnt work, because update_code is in a
transaction, so current_path points to the app that's currently
running, rather than the most recently checked out code version.  So I
get the following error:

  * executing task after_update_code
  * executing "ln -s ~/apps/blog/shared/config/database.yml
~/apps/blog/current/config/database.yml"
    servers: ["www.mydomain.com"]
    [www.mydomain.com] executing command
 ** [out :: www.mydomain.com] ln:
/home/pergesu/apps/blog/current/config/database.yml: File exists
    command finished
rake aborted!
command "ln -s ~/apps/blog/shared/config/database.yml
~/apps/blog/current/config/database.yml" failed on www.mydomain.com

In the past I've put the ln in the restart task, but that's an ugly
hack, plus it doesn't allow me to "rake remote:restart" - the file
already exists, so it fails.  I have to do a full deploy just to
restart it.  So how do I do what I want?

Finally, I have a question about running migrations.  Does rake deploy
just do remote:update_code and remote:restart?  Or does it do other
stuff?  If I need to run migrations, it'd be best if I can update the
code, run migrations, and restart the app.  "rake remote:update_code;
rake remote:migrate; rake remote:restart", instead of what I'm
currently doing now chich is "rake deploy; rake remote:migrate; rake
remote:restart"

Thanks for any info.

Pat
59ea1b450935b9d70abfec4186b7a4d5?d=identicon&s=25 Jeff Coleman (progressions)
on 2006-04-04 00:32
Pat,

I'm afraid I can't help with your other issues, but there is a
"deploy_with_migrations" task in the remote namespace.

rake remote:deploy_with_migrations

Jeff

Pat Maddox wrote:
> My app is set up without database.yml in version control.  I created a
> shared_path/config dir, and put database.yml in it.  After I update
> the code, I want to link the app's database.yml file to the shared
> config.  So I added this task
>
> desc 'Copy the database config'
> task :after_update_code, :roles => :app do
>   run "ln -s #{shared_path}/config/database.yml
> #{current_path}/config/database.yml"
> end
>
> Unfortunately that doesnt work, because update_code is in a
> transaction, so current_path points to the app that's currently
> running, rather than the most recently checked out code version.  So I
> get the following error:
>
>   * executing task after_update_code
>   * executing "ln -s ~/apps/blog/shared/config/database.yml
> ~/apps/blog/current/config/database.yml"
>     servers: ["www.mydomain.com"]
>     [www.mydomain.com] executing command
>  ** [out :: www.mydomain.com] ln:
> /home/pergesu/apps/blog/current/config/database.yml: File exists
>     command finished
> rake aborted!
> command "ln -s ~/apps/blog/shared/config/database.yml
> ~/apps/blog/current/config/database.yml" failed on www.mydomain.com
>
> In the past I've put the ln in the restart task, but that's an ugly
> hack, plus it doesn't allow me to "rake remote:restart" - the file
> already exists, so it fails.  I have to do a full deploy just to
> restart it.  So how do I do what I want?
>
> Finally, I have a question about running migrations.  Does rake deploy
> just do remote:update_code and remote:restart?  Or does it do other
> stuff?  If I need to run migrations, it'd be best if I can update the
> code, run migrations, and restart the app.  "rake remote:update_code;
> rake remote:migrate; rake remote:restart", instead of what I'm
> currently doing now chich is "rake deploy; rake remote:migrate; rake
> remote:restart"
>
> Thanks for any info.
>
> Pat
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-04-04 02:10
(Received via mailing list)
Hey Jeff,

Thanks for the tip on deploy_with_migrations

I found out that I need to use release_path instead of current_path
inside after_update_code, because update_code doesn't do any
symlinking.  release_path is the path to the release that's being
checked out.

Pat
This topic is locked and can not be replied to.