Rubioli
Rubioli

Reputation: 725

Prevent capistrano to run migration in deploy

I am using capistrano rails gem in my application. When I run cap production deploy it deploys my changes and at the same time it runs my db:migrate and runs all my pending migrations.

For a testing reason I don't want it to run db:migrate after it deploy.

How can I prevent capistrano to run deploy:migrate when deploying and more importantly how I can see my migrations status to see all my pending migrations capistrano will run.

For instnace in development ENV I can just run rake db:migrate:status and its shows me which migrations are up or down and which will/need to run.

Only namespace/function in my deploy.rb

namespace :deploy do

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
    end
  end

  desc "reload the database with seed data"
  task :seed do
    puts "\n=== Seeding Database ===\n"
    on primary :db do
      within current_path do
        with rails_env: fetch(:stage) do
          execute :rake, 'db:seed'
        end
      end
    end
  end
end

Rest of my deploy.rb has all usual things such as:

set :application, set :repo_url, set :passenger_restart_with_touch, set :deploy_to, set :bundle_binstubs, set :linked_files, set :linked_dirs

My versions:

Rails: 4.2.4

Capistrano: 3.5

Upvotes: 1

Views: 1078

Answers (1)

will_in_wi
will_in_wi

Reputation: 2653

You have two ways of initializing the Capistrano-Rails Gem. In your Capfile, you can add require 'capistrano/rails', which will generate assets and run migrations, or you can add require 'capistrano/rails/assets' and/or require 'capistrano/rails/migrations' which will do one or the other, or both if both are included.

So, to not run migrations, make sure that require 'capistrano/rails' and require 'capistrano/rails/migrations' are not in your Capfile.

Upvotes: 3

Related Questions