Class: EY::Serverside::Slug::Migrator

Inherits:
Object
  • Object
show all
Includes:
Result::DSL, Runner
Defined in:
lib/engineyard-serverside/slug/migrator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Runner

#run, #run_and_output, #run_and_success?, #runner

Methods included from Result::DSL

#Failure, #Success

Constructor Details

#initialize(config, shell) ⇒ Migrator

Returns a new instance of Migrator.


13
14
15
16
# File 'lib/engineyard-serverside/slug/migrator.rb', line 13

def initialize(config, shell)
  @config = config
  @shell = shell
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


11
12
13
# File 'lib/engineyard-serverside/slug/migrator.rb', line 11

def config
  @config
end

#shellObject (readonly)

Returns the value of attribute shell


11
12
13
# File 'lib/engineyard-serverside/slug/migrator.rb', line 11

def shell
  @shell
end

Instance Method Details

#call(data = {}) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/engineyard-serverside/slug/migrator.rb', line 18

def call(data = {})
  return Success(data) unless config.migrate?

  cmd = "PATH=#{paths.binstubs}:$PATH #{config.framework_envs} #{config.migration_command}"

  return Failure(
    data.merge(:error => "Could not migrate database")
  ) unless Dir.chdir(paths.active_release) {run_and_success?(cmd)}

  Success(data.merge(:migrated => true))
end