Class: Ridgepole::ReplaceDbTask::Executor
- Inherits:
-
Object
- Object
- Ridgepole::ReplaceDbTask::Executor
- Defined in:
- lib/ridgepole/replace_db_task/executor.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.call(env:, spec_name:, block:, other_options: [], dry_run: true) ⇒ Object
7 8 9 |
# File 'lib/ridgepole/replace_db_task/executor.rb', line 7 def call(env:, spec_name:, block:, other_options: [], dry_run: true) new(env, spec_name, block, , dry_run).call end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/ridgepole/replace_db_task/executor.rb', line 12 def call raise 'config.database_yml_path is required.' if Ridgepole::ReplaceDbTask.config.database_yml_path.blank? raise 'config.schema_file_path is required.' if spec_config.schema_file_path.blank? = .dup << "--config #{Ridgepole::ReplaceDbTask.config.database_yml_path}" << "--file #{spec_config.schema_file_path}" << "--env #{env}" << "--apply" << "--dry-run" if dry_run << "--spec-name #{spec_name}" if spec_name.present? command = "#{Ridgepole::ReplaceDbTask.config.ridgepole} #{options.join(' ')}" puts command out = [] is_success = Open3.popen2e(command) do |stdin, stdout_and_stderr, wait_thr| stdin.close stdout_and_stderr.each_line do |line| out << line @block.call(line) end wait_thr.value.success? end out.join("\n") exit(1) unless is_success end |