开发者

Capistrano deployment changing directory for migrations

I have a rails app that is not in the root directory of the repository. When it is deployed, some other static files are deployed with it in a parent directory. The structure is something like this:

root
-- otherstuff
-- railsapp

When I do a deployment with cap deploy:migrations, the Capistrano command that gets executed looks like this, which of cou开发者_如何学编程rse doesn't work:

cd /u/apps/minicart/releases/20100717215044; rake RAILS_ENV=staging  db:migrate

How do I change this so that it will be:

cd /u/apps/minicart/releases/20100717215044/railsapp; rake RAILS_ENV=staging  db:migrate

I made it work by adding a task that executes this command after deploy:finalize_update, but I would prefer to use the built in method, plus my hacked version is executed with every deployment.

Any advice would be appreciated.

Tim


This turned out to be very simple.

I added a deploy namepace to my deploy.rb file and then redefined the migrate method. Now my method runs on cap deploy:migrations.

namespace :deploy do
  desc "Migrating the database"
  task :migrate, :roles => :app do
    run <<-CMD
      cd  #{release_path}/minicart; RAILS_ENV=#{stage} rake db:migrate
    CMD
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜