console\controllers\MigrateController::migrateToVersion PHP Метод

migrateToVersion() защищенный Метод

Migrates to the certain version.
protected migrateToVersion ( string $version )
$version string name in the full format.
    protected function migrateToVersion($version)
    {
        $originalVersion = $version;
        // try migrate up
        $migrations = $this->getNewMigrations();
        $i = 0;
        foreach ($migrations as $migration => $alias) {
            if (strpos($migration, $version . '_') === 0) {
                $this->actionUp($i + 1);
                return;
            }
            $i++;
        }
        // try migrate down
        $migrations = array_keys($this->getMigrationHistory(-1));
        foreach ($migrations as $i => $migration) {
            if (strpos($migration, $version . '_') === 0) {
                if ($i === 0) {
                    echo "Already at '{$originalVersion}'. Nothing needs to be done.\n";
                } else {
                    $this->actionDown($i);
                }
                return;
            }
        }
        throw new Exception("Unable to find the version '{$originalVersion}'.");
    }