MigrationVersion::_initMigrations PHP Method

_initMigrations() protected method

Initialize the migrations schema and keep it up-to-date
protected _initMigrations ( ) : void
return void
    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'));
        }
    }