protected function _initMigrations()
{
/** @var DboSource $db */
$db = ConnectionManager::getDataSource($this->connection);
if (!in_array($db->fullTableName('schema_migrations', false, false), $db->listSources())) {
$map = $this->_enumerateMigrations('migrations');
list($name, $class) = each($map[1]);
$migration = $this->getMigration($name, $class, 'Migrations');
$migration->run('up');
$this->setVersion(1, 'Migrations');
}
$mapping = $this->getMapping('Migrations');
if (count($mapping) > 1) {
end($mapping);
$this->run(array('version' => key($mapping), 'type' => 'Migrations'));
}
}