Class: Themigrator::Migrator

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/themigrator/migrator.rb

Constant Summary

Constants included from Logger

Logger::MAINLOGFILE

Instance Method Summary collapse

Methods included from Logger

#init_logger, #log, #log_dir, #log_path, #logger, #main_log_path

Constructor Details

#initialize(dir) ⇒ Migrator

Returns a new instance of Migrator.



11
12
13
14
# File 'lib/themigrator/migrator.rb', line 11

def initialize(dir)
  @dir = dir
  @runned_roles = []
end

Instance Method Details

#migrate!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/themigrator/migrator.rb', line 16

def migrate!
  @migration = Migration.new(@dir)
  @migration.analyze_project!

  init_logger(main_log_path(@dir, run_id))
  
  log "* [starting]"
  catch(:rollback) do
	each_action do |action|
	  log "[step #{action}]"
	  run_action_and_wait(action)
	end
	return true
  end
  run_rollback_and_wait
end

#run_idObject



33
34
35
# File 'lib/themigrator/migrator.rb', line 33

def run_id
  @run_id ||= Time.now.strftime("%Y-%m-%d-%H:%M:%S")
end