git-deliver icon indicating copy to clipboard operation
git-deliver copied to clipboard

Rails migration failing using remote command

Open thelinuxlich opened this issue 11 years ago • 6 comments

I run bundle install, assets:precompile and db:migrate using the .remote.sh feature, but mgirate always fails, it tries to rerun migrations and throws "IrreversibleMigration" exception, leaving the production schema inconsistent. If I run this command inside the machine, it runs correctly.

thelinuxlich avatar Apr 28 '14 19:04 thelinuxlich

You might want to check that the environment variables are the same in both cases.

If you are using the run_remote function, it might also be an escaping problem.

On Mon, Apr 28, 2014 at 9:50 PM, Alisson Cavalcante Agiani < [email protected]> wrote:

I run bundle install, assets:precompile and db:migrate using the .remote.sh feature, but mgirate always fails, it tries to rerun migrations and throws "IrreversibleMigration" exception, leaving the production schema inconsistent. If I run this command inside the machine, it runs correctly.

— Reply to this email directly or view it on GitHubhttps://github.com/arnoo/git-deliver/issues/56 .

arnoo avatar Apr 28 '14 20:04 arnoo

I'm running the commands inside a script.remote.sh using RAILS_ENV=production rake db:migrate

Why it could be an escaping problem?

thelinuxlich avatar Apr 28 '14 20:04 thelinuxlich

inside a .remote.sh script it can't be an escaping problem

I'd try looking at the output of "env" to compare it in both environments... maybe by adding something like this to your migration script :

env > /tmp/env.log

On Mon, Apr 28, 2014 at 10:20 PM, Alisson Cavalcante Agiani < [email protected]> wrote:

I'm running the commands inside a script.remote.sh using RAILS_ENV=production rake db:migrate

Why it could be an escaping problem?

— Reply to this email directly or view it on GitHubhttps://github.com/arnoo/git-deliver/issues/56#issuecomment-41608143 .

arnoo avatar Apr 28 '14 20:04 arnoo

I did it, tried using export RAILS_ENV=production in the beginning...it is crazy because rake db:migrate running with git-deliver is reverting the migrations!

thelinuxlich avatar Apr 28 '14 21:04 thelinuxlich

Found out the problem: git-deliver sets a VERSION variable, which rake db:migrate thinks it is the version it needs to run against, thus reverting...the solution is to run unset VERSION before it.

thelinuxlich avatar Apr 28 '14 21:04 thelinuxlich

Wow, that's confusing indeed ! Maybe I should to prefix all git-deliver environment variables to avoid this kind of conflict.

On Mon, Apr 28, 2014 at 11:34 PM, Alisson Cavalcante Agiani < [email protected]> wrote:

Found out the problem: git-deliver sets a VERSION variable, which rake db:migrate thinks it is the version it needs to run against, thus reverting...the solution is to run unset VERSION before it.

— Reply to this email directly or view it on GitHubhttps://github.com/arnoo/git-deliver/issues/56#issuecomment-41616639 .

arnoo avatar Apr 29 '14 07:04 arnoo