Sha256: 8cbec2cc3de3bf37fc134e718ec1f9c86fcdd2f54d69b3f6c4be41e670950514

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

load File.expand_path("../set_rails_env.rake", __FILE__)

namespace :deploy do

  desc 'Runs rake db:migrate if migrations are set'
  task :migrate => [:set_rails_env] do
    migration_servers = fetch(:multiple_migration_servers) ? roles(fetch(:migration_role)) : primary(fetch(:migration_role))
    on migration_servers do
      conditionally_migrate = fetch(:conditionally_migrate)
      info '[deploy:migrate] Checking changes in /db/migrate' if conditionally_migrate
      if conditionally_migrate && test("diff -q #{release_path}/db/migrate #{current_path}/db/migrate")
        info '[deploy:migrate] Skip `deploy:migrate` (nothing changed in db/migrate)'
      else
        info '[deploy:migrate] Run `rake db:migrate`'
        within release_path do
          with rails_env: fetch(:rails_env) do
            execute :rake, "db:migrate"
          end
        end
      end
    end
  end

  after 'deploy:updated', 'deploy:migrate'
end

namespace :load do
  task :defaults do
    set :conditionally_migrate, fetch(:conditionally_migrate, false)
    set :migration_role, fetch(:migration_role, :db)
    set :multiple_migration_servers, fetch(:multiple_migration_servers, false)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-rails-multiple-db-1.1.3 lib/capistrano/tasks/migrations.rake