Sha256: 2c9ba997fd202e18a4481e5bb86a87666bf58727d3f737b78894eacf68d4378d

Contents?: true

Size: 1.32 KB

Versions: 49

Compression:

Stored size: 1.32 KB

Contents

namespace :deploy do

  desc 'Runs rake data:migrate if migrations are set'
  Rake::Task['deploy:migrate'].clear_actions
  task :migrate => [:set_rails_env] do
    on fetch(:migration_servers) do
      conditionally_migrate = fetch(:conditionally_migrate)
      info '[deploy:migrate] Checking changes in db/migrate or db/data' if conditionally_migrate

      if conditionally_migrate &&
         test("diff -q #{release_path}/db/migrate #{current_path}/db/migrate") &&
         test("diff -q #{release_path}/db/data #{current_path}/db/data")
        info '[deploy:migrate] Skip `deploy:migrate` (nothing changed in db/migrate or db/data)'
      else
        info '[deploy:migrate] Run `rake db:migrate:with_data`'
        invoke :'deploy:migrating_with_data'
      end
    end
  end

  desc 'Runs rake db:migrate:with_data'
  task migrating_with_data: [:set_rails_env] do
    on fetch(:migration_servers) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          execute :rake, 'db:migrate:with_data'
        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 :migration_servers, -> { primary(fetch(:migration_role)) }
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
data_migrate-11.2.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-11.1.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.1.3 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.1.2 lib/capistrano/data_migrate/migrate.rb
data_migrate-11.0.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-11.0.0.rc3 lib/capistrano/data_migrate/migrate.rb
data_migrate-11.0.0.rc lib/capistrano/data_migrate/migrate.rb
data_migrate-9.4.4 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.4.2 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.4.1 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.4.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.3.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.2.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.1.1 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.1.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-10.0.3.rc lib/capistrano/data_migrate/migrate.rb
data_migrate-10.0.0.rc1 lib/capistrano/data_migrate/migrate.rb
data_migrate-9.0.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-8.5.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-8.4.2 lib/capistrano/data_migrate/migrate.rb