Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions lib/Task/Db/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,55 @@ private function run_migrations($migrations, $target_method, $destination)
$obj = new $klass($this->_adapter);
$start = $this->start_timer();
try {
/*
* Run up or down, before transaction start
* This allows commands to run on both up and down to be set in one place.
*/
if(method_exists($obj, "setup")) {
$obj->setup();
}

/*
* Run up or down, before transaction
* This allows for commands that can't run in transactions
*/
$method = "pretransaction_" . $target_method;
if(method_exists($obj, $method)) {
$result = $obj->$method();
}

//start transaction
$this->_adapter->start_transaction();

//Run up or down, after transaction start
if(method_exists($obj, "transaction_setup")) {
$obj->transaction_setup();
}
$result = $obj->$target_method();
//successfully ran migration, update our version and commit
$this->_migrator_util->resolve_current_version($file['version'], $target_method);

//Run up or down, before transaction commit
if(method_exists($obj, "transaction_cleanup")) {
$obj->transaction_cleanup();
}

$this->_adapter->commit_transaction();

//Run up or down, after commit
$method = "postcommit_" . $target_method;
if(method_exists($obj, $method)) {
$result = $obj->$method();
}

/*
* Run up or down, after transaction end
* This allows commands to run on both up and down to be set in one place.
*/
if(method_exists($obj, "cleanup")) {
$obj->cleanup();
}

} catch (Ruckusing_Exception $e) {
$this->_adapter->rollback_transaction();
//wrap the caught exception in our own
Expand Down