# Capistrano only runs migration against production env?

**URL:** <https://www.ruby-forum.com/t/capistrano-only-runs-migration-against-production-env/95254>\
**Category:** Rails\
**Created:** [May 25, 2006, 6:44pm UTC](https://www.ruby-forum.com/t/capistrano-only-runs-migration-against-production-env/95254 "2006-05-25T18:44:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 25, 2006, 6:44pm UTC](https://www.ruby-forum.com/t/capistrano-only-runs-migration-against-production-env/95254/1 "2006-05-25T18:44:13Z")

</div>

All,

Just read in the Capistrano manual about the Capistrano “migrate” task.  
There it says that:

“By default, all this task does is change to the directory of your  
current release (as indicated by the current symlink), and run rake  
RAILS\_ENV=production migrate. You can specify that it should run against  
the latest release (regardless of what the current release is) by  
setting the migrate\_target variable to :latest before invoking this  
task. Likewise, if you want to specify additional environment variables  
(beside RAILS\_ENV) you can set the migrate\_env variable to the  
space-delimited list of name=value pairs to use.”

Can anyone verify the truth of this statement.

Currently I use Capistrano to deploy to a test environment, so I’d like  
to be able to run my migrations against test.

Can you modify the RAILS\_ENV that Capistrano is using to do the  
migration or not?

I think I will just add the “rake migrate RAILS\_ENV=test” command as a  
command line to run within my deploy script. That should work, no?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 25, 2006, 7:00pm UTC](https://www.ruby-forum.com/t/capistrano-only-runs-migration-against-production-env/95254/2 "2006-05-25T19:00:02Z")

</div>

OK, I attempted to add a “rake migrate RAILS\_ENV=test” command into my  
Capistrano deploy as a regular command line, like so:

run “cd #{current\_path}; chmod 777 public; rake migrate RAILS\_ENV=test;  
rake appdoc”

(yes I know the chmod 777 public is scary)

But when I run it appears that when that command gets run I get:

\*\* [out :: 192.168.1.102] WARNING: STMT 0x8b31910 was not dropped  
before garbage collection.

Anyone ever seen that?

Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [May 25, 2006, 7:04pm UTC](https://www.ruby-forum.com/t/capistrano-only-runs-migration-against-production-env/95254/3 "2006-05-25T19:04:54Z")

</div>

Wes G. wrote:

> OK, I attempted to add a “rake migrate RAILS\_ENV=test” command into my  
> Capistrano deploy as a regular command line, like so:
> 
> run “cd #{current\_path}; chmod 777 public; rake migrate RAILS\_ENV=test;  
> rake appdoc”
> 
> (yes I know the chmod 777 public is scary)
> 
> But when I run it appears that when that command gets run I get:
> 
> \*\* [out :: 192.168.1.102] WARNING: STMT 0x8b31910 was not dropped  
> before garbage collection.
> 
> Anyone ever seen that?
> 
> Wes

Doh! My migration wasn’t checked in so it didn’t exist when I ran “rake  
migrate”

Looks like it runs correctly, but then I get several of those STMT blah  
was not dropped before garbage collection.

I’m guessing that the database resources on the Ruby invocation of  
capistrano aren’t getting freed correctly or something.

Wes
