/** * prepare to migrate * * @param string $destination The version desired * @param string $direction Up or Down * * @return void */ protected function _prepareToMigrate($destination, $direction) { $this->_logger->debug(__METHOD__ . ' Start'); $this->_logger->debug('Destination: ' . $destination . ' - direction: ' . $direction); try { $this->_return .= $this->_prefixText . "\tMigrating " . strtoupper($direction); if (!is_null($destination)) { $this->_return .= " to: {$destination}\n"; } else { $this->_return .= ":\n"; } $migrations = $this->_migratorUtil->getRunnableMigrations($this->_migrationDir, $direction, $destination); if (count($migrations) == 0) { $msg = 'No relevant migrations to run. Exiting...'; $this->_logger->info($msg); $this->_return .= $this->_prefixText . "\n" . trim($this->_prefixText . " {$msg}\n"); return; } $this->_runMigrations($migrations, $direction); } catch (Exception $ex) { $this->_logger->err('Exception: ' . $ex->getMessage()); throw $ex; } $this->_logger->debug(__METHOD__ . ' End'); }
public function testGetRunnableMigrationsGoingUp() { $versions = array(array('version' => 1, 'class' => 'CreateUsers', 'file' => '001_CreateUsers.php'), array('version' => 3, 'class' => 'AddIndexToBlogs', 'file' => '003_AddIndexToBlogs.php')); $this->_adapter->versions = $versions; $actualDownFiles = $this->object->getRunnableMigrations(PHIGRATE_MIGRATION_DIR, 'up', '20090122193325', false); $expectDownFiles = array(array('version' => '20090122193325', 'class' => 'AddNewTable', 'file' => '20090122193325_AddNewTable.php')); $this->assertEquals($expectDownFiles, $actualDownFiles); }