Capistrano: disable db: migrate

How to disable db: migrate when executing cap deploy:cold with Capistrano?

In config / deploy.rb, only the comment on deploy:migrate commented out, but it is still trying to do:

 bundle exec rake RAILS_ENV=production db:migrate 
+4
source share
3 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 
+3
source

I had the same problem. That is why I redefine it in a Rakefile. Like this:

 namespace :db do desc "db:migration fakes" task :migrate => :environment do p 'No. We will not migrate!' end end 

Here you can add more logic if you want. For example, you can initiate real migration in certain environments.

0
source

When overriding a task in Capistrano v2, the original task was replaced. However, the Rake DSL on which Capistrano v3 is built is additive. According to the documentation . In most cases, you just want to use clear_actions, which removes the behavior of the specified tasks, but does not change its dependencies or comments:

 namespace :deploy do Rake::Task["migrate"].clear_actions task :migrate do puts "no migration" end end 
0
source

Source: https://habr.com/ru/post/1486305/


All Articles