Class: Themigrator::Migrator
- Inherits:
-
Object
- Object
- Themigrator::Migrator
- Includes:
- Logger
- Defined in:
- lib/themigrator/migrator.rb
Constant Summary
Constants included from Logger
Instance Attribute Summary collapse
-
#run_id ⇒ Object
readonly
Returns the value of attribute run_id.
Instance Method Summary collapse
-
#initialize(dir) ⇒ Migrator
constructor
A new instance of Migrator.
- #migrate! ⇒ Object
Methods included from Logger
#close_logger, #init_logger, #log, #log_dir, #log_path, #logger, #main_log_path
Constructor Details
#initialize(dir) ⇒ Migrator
Returns a new instance of Migrator.
12 13 14 15 16 |
# File 'lib/themigrator/migrator.rb', line 12 def initialize(dir) @dir = dir @runned_roles = [] @run_id = Time.now.strftime("%Y-%m-%d-%H:%M:%S") end |
Instance Attribute Details
#run_id ⇒ Object (readonly)
Returns the value of attribute run_id.
10 11 12 |
# File 'lib/themigrator/migrator.rb', line 10 def run_id @run_id end |
Instance Method Details
#migrate! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/themigrator/migrator.rb', line 18 def migrate! @migration = Migration.new(@dir) @migration.analyze_project! init_logger(main_log_path(@dir, run_id)) log "start PID=#{$$}" log "roles: #{@migration.roles.join(" ")}" did_it_work = true each_action do |action| if !run_action_and_wait(action) did_it_work = false run_rollback_and_wait("rollback") return -1 end end close_logger did_it_work end |