Sha256: 1703243eca77f14c31f142bfb14eb70272dcc58bd1fc42ecc0cf56a55b13c5e2

Contents?: true

Size: 1000 Bytes

Versions: 2

Compression:

Stored size: 1000 Bytes

Contents

require "ridgepole/replace_db_task/executor"

namespace :db do
  desc 'db migrate use ridgepole'
  task migrate: :environment do
    ::Ridgepole::ReplaceDbTask.config.spec_configs.each do |spec_config|
      ENV['RAILS_ENV'] ||= 'development'
      apply(ENV['RAILS_ENV'], spec_config.spec_name, '--apply') { |line| puts line }

      envs = spec_config.multiple_migration_settings.dig(ENV['RAILS_ENV'].to_sym) || []
      envs.each do |env|
        apply(env, spec_config.spec_name, '--apply') { |line| puts line }
      end
    end
  end

  desc 'apply dry run'
  task apply_dry_run: :environment do
    ::Ridgepole::ReplaceDbTask.config.spec_configs.each do |spec_config|
      ENV['RAILS_ENV'] ||= 'development'

      apply(ENV['RAILS_ENV'], spec_config.spec_name, '--apply --dry-run') do |line|
        puts line
      end
    end
  end

  private

  def apply(rails_env, spec_name, options, &block)
    ::Ridgepole::ReplaceDbTask::Executor.call(rails_env, spec_name, options, block)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ridgepole-replace_db_task-0.6.1 lib/tasks/replaced_db.rake
ridgepole-replace_db_task-0.6.0 lib/tasks/replaced_db.rake