views:

12

answers:

1

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 course 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

A: 

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
Tim Stephenson