Class: EY::Serverside::Slug::Migrator
- Inherits:
-
Object
- Object
- EY::Serverside::Slug::Migrator
- Includes:
- Result::DSL, Runner
- Defined in:
- lib/engineyard-serverside/slug/migrator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
Instance Method Summary collapse
- #call(data = {}) ⇒ Object
-
#initialize(config, shell) ⇒ Migrator
constructor
A new instance of Migrator.
Methods included from Runner
#run, #run_and_output, #run_and_success?, #runner
Methods included from Result::DSL
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
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/engineyard-serverside/slug/migrator.rb', line 11 def config @config end |
#shell ⇒ Object (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 |