Sha256: 61edfc80bf135504b9a78b1b4a2d577aff112fc5322d5e0ec42fe7f480e71101

Contents?: true

Size: 1.34 KB

Versions: 18

Compression:

Stored size: 1.34 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

18 entries across 18 versions & 2 rubygems

Version Path
data_migrate-5.3.1 lib/capistrano/data_migrate/migrate.rb
data_migrate-5.3.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-5.2.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-5.1.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-5.0.2 lib/capistrano/data_migrate/migrate.rb
data_migrate-5.0.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-4.0.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.5.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.4.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.3.1 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.3.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.2.2 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.2.1 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.2.0 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.1.0 lib/capistrano/data_migrate/migrate.rb
salsify-data_migrate-3.1.0 lib/capistrano/data_migrate/migrate.rb
salsify-data_migrate-3.0.1 lib/capistrano/data_migrate/migrate.rb
data_migrate-3.0.1 lib/capistrano/data_migrate/migrate.rb