Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano deploy but manually run migrations

I'm using Capistrano to deploy a Rails application. I'm thinking of a situation where there were database changes, so I can't simply cap deploy because the migrations need to run before the code is updated. I realize there's a cap deploy:migrations, but that's a little more automatic than I'd like. I'd like to:

  1. Push the new code to the releases directory, but not update the symlink or restart the application.
  2. ssh into the server, run rake:db_abort_if_pending_migrations to confirm that the migrations I want to run are the only pending ones, then run rake db:migrate manually.
  3. Complete the deploy, updating the symlink and restarting the application.

Is there any easy way to do this with the built-in Capistrano tasks, or would I need to write my own deployment steps to accomplish this?

I should mention too that I'm thinking of cases (like adding columns) where the migration can be run on a live database. For more destructive changes I realize I'd need to bring down the site with a maintenance page during the deploy.

like image 306
jrdioko Avatar asked Mar 08 '11 22:03

jrdioko


1 Answers

Try:

  1. cap deploy:update_code

  2. Do what you described loging in to the server manually or via cap shell

  3. cap deploy:symlink deploy:restart

See cap -e deploy:update_code deploy:symlink deploy:restart deploy:shell for more information.

I hope this will be helpful to You.

like image 67
Szymon Jeż Avatar answered Sep 28 '22 06:09

Szymon Jeż