Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capistrano: disable db:migrate

Tags:

capistrano

How do you disable db:migrate when doing a cap deploy:cold with Capistrano?

In config/deploy.rb the only reference to deploy:migrate is commented out but it's still attempting to do:

bundle exec rake RAILS_ENV=production  db:migrate
like image 245
Snowcrash Avatar asked Jun 14 '13 19:06

Snowcrash


2 Answers

I got success by overriding the deploy:migrate method in my config/deploy.rb.

namespace :deploy do
  desc "No ActiveRecord override"
  task :migrate do
  end
end
like image 187
iHiD Avatar answered Nov 03 '22 04:11

iHiD


When re-defining a task in Capistrano v2, the original task was replaced. However the Rake DSL on which Capistrano v3 is built is additive. According to documentation. Under most circumstances, you will simply want to use clear_actions, which removes the specified task’s behaviour, but does not alter it’s dependencies or comments:

namespace :deploy do
  Rake::Task["migrate"].clear_actions
  task :migrate do
    puts "no migration"
  end
end
like image 2
Lei Wang Avatar answered Nov 03 '22 04:11

Lei Wang