# Capistrano errors when running \`cap migrate\`

**URL:** <https://www.ruby-forum.com/t/capistrano-errors-when-running-cap-migrate/68681>\
**Category:** Rails\
**Created:** [September 14, 2006, 1:27pm UTC](https://www.ruby-forum.com/t/capistrano-errors-when-running-cap-migrate/68681 "2006-09-14T13:27:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![B\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@B\_N](https://www.ruby-forum.com/u/B_N)\
**Post date:** [September 14, 2006, 1:27pm UTC](https://www.ruby-forum.com/t/capistrano-errors-when-running-cap-migrate/68681/1 "2006-09-14T13:27:39Z")

</div>

Hello all,  
I can deploy, enable/disable\_web, cleanup, restart and so forth, but  
I am unable to migrate without errors.

When I am on the server I can run `rake RAILS_ENV="production" migrate`  
successfully. When I run cap migrate:

- executing task migrate
- executing “cd /var/www/localhost/rails\_test/current && rake  
RAILS\_ENV=production migrate”  
/opt/local/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/actor.rb:416:in

`execute\_on\_servers’: The migrate task is only run for servers matching  
{:only=\>{:primary=\>true}, :roles=\>:db, :desc=\>“Run the migrate rake  
task. By default, it runs this in the version of the app\nindicated by  
the ‘current’ symlink. (This means you should not invoke this  
task\nuntil the symlink has been updated to the most recent version.)  
However, you\ncan specify a different release via the migrate\_target  
variable, which must be\none of "current" (for the default behavior),  
or "latest" (for the latest release\nto be deployed with the  
update\_code task). You can also specify additional\nenvironment  
variables to pass to rake via the migrate\_env variable. Finally,  
you\ncan specify the full path to the rake executable by setting the  
rake variable.\n”}, but no servers matched (RuntimeError)

My deploy file specifies:  
task :switch\_to\_production do  
set :use\_sudo, false  
set :user, “root”  
role :web, “[mysite.com](http://mysite.com)”  
role :app, “[mysite.com](http://mysite.com)”  
role :db, “[mysite.com](http://mysite.com)”  
set :deploy\_to, “/var/www/localhost/rails\_test”  
set :rails\_env, “production”  
end

task :migrate\_production do  
switch\_to\_production  
migrate  
end

I have similar task :whatever\_production ones that work (as I’d  
mentioned). Any ideas?  
Thanks in advance for any advice.

---

<div class="post-metadata">

**Author:** ![B\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@B\_N](https://www.ruby-forum.com/u/B_N)\
**Post date:** [September 14, 2006, 3:01pm UTC](https://www.ruby-forum.com/t/capistrano-errors-when-running-cap-migrate/68681/2 "2006-09-14T15:01:54Z")

</div>

B N wrote:

> you\ncan specify the full path to the rake executable by setting the  
> set :rails\_env, “production”
> 
> &nbsp; set :user, "root"   
> &nbsp; role :web, "[mysite.com](http://mysite.com)"   
> &nbsp; role :app, "[mysite.com](http://mysite.com)"   
> &nbsp; role :db, &nbsp;"[  
> mysite.com](http://mysite.com)"   
> &nbsp; set :deploy\_to, "/var/www/localhost/rails\_test"   
> &nbsp; set :rails\_env, "production"   
> end
> 
> task :migrate\_production do   
> &nbsp; switch\_to\_production   
> &nbsp; migrate  
>   
> end
> 
> I have similar task :whatever\_production ones that work (as I’d   
> mentioned). Any ideas?
> 
> Thanks in advance for any advice.

Try:

role :db, “[mysite.com](http://mysite.com)”, :primary=\>true

Jamey

---

<div class="post-metadata">

**Author:** ![B\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/db5fbb/32.png) [@B\_N](https://www.ruby-forum.com/u/B_N)\
**Post date:** [September 14, 2006, 6:15pm UTC](https://www.ruby-forum.com/t/capistrano-errors-when-running-cap-migrate/68681/3 "2006-09-14T18:15:14Z")

</div>

Hmmm, I had encountered that in other code and assumed it only  
necessary when multiple databases were involved. In any event, it  
worked and I am deeply appreciative.

Best regards!
