Bug in deploy:migrations ?

31 views
Skip to first unread message

max

unread,
Feb 12, 2009, 3:32:08 PM2/12/09
to Capistrano
Hello

I've just noticed a problem when using deploy:migrations (capistrano
2.5.4).

It appears that "db:migrate" is executed from the current release
directory (previously deployed), instead of the latest release
directory (current deployment).

So latest migrations shipped with latest release are not executed !


The problem occurs in migrate task (called by migrations task).

The line 374 in capistrano-2.5.4/lib/recipes/deploy/deploy.rb :
when :latest then current_release
should be :
when :latest then latest_release

So directory of the latest release (just deployed) is used to run
migrations.


I hope I'm not missing something here, and that the google group is
the right place to propose a patch...

Thanks

++

Max

Jamis Buck

unread,
Feb 12, 2009, 4:02:57 PM2/12/09
to capis...@googlegroups.com
Actually, "current_release" is correct. If you look at the definition
for current_release:

_cset(:current_release) { File.join(releases_path, releases.last) }

Which returns the path of the last release in the releases directory:

_cset(:releases) { capture("ls -xt #{releases_path}").split.reverse }

Now, it could be that you've got a before() hook somewhere that is
calling (directly or indirectly) the releases variable, before the new
release is uploaded. In that case, Capistrano is caching the
pre-new-code value. You could try something like this to make sure
you're getting the right version:

before("deploy:migrate") { reset! :releases }

Calling reset! forces Capistrano to forget the cached value, so that the
next query for the releases variable will go and fetch the directory
list again from the server.

- Jamis

max

unread,
Feb 13, 2009, 5:35:29 AM2/13/09
to Capistrano
I had indeed an early call to current_release in my custom copy
strategy, causing my problem...

Thanks a lot for the tip (which fixed my problem) and your quick
answer !

++

Max
Reply all
Reply to author
Forward
0 new messages