Class: Pcrd::Preflight
- Inherits:
-
Object
- Object
- Pcrd::Preflight
- Defined in:
- lib/pcrd/preflight.rb
Overview
Runs all pre-migration safety checks and generates the target DDL.
Checks are grouped and run top-to-bottom. Connection failures are hard stops (subsequent checks that need a connection are skipped). All table checks run even when earlier tables fail, so the operator sees all problems at once.
Returns a Result that includes all check items and a DDL map for display.
Defined Under Namespace
Constant Summary collapse
- HARD_FAIL =
ddl_map: Hash<table_name, String> — generated CREATE TABLE SQL per table row_counts: Hash<table_name, Integer> — estimated row counts
:fail
Instance Method Summary collapse
-
#initialize(config, options = {}) ⇒ Preflight
constructor
any :fail in items means Result#passed = false.
- #run ⇒ Object
Constructor Details
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pcrd/preflight.rb', line 32 def run @source_pool = open_pool(@config.source) @target_pool = @config.target ? open_pool(@config.target) : nil check_source_connection check_target_connection check_wal_level check_replication_slots check_replication_objects (@config.migrate&.tables || []).each { |t| check_table(t) } Result.new( passed: @items.none? { |i| i.status == :fail }, items: @items, ddl_map: @ddl_map, row_counts: @row_counts ) ensure @source_pool&.close @target_pool&.close end |