src/Console/Controllers/BaseMigrateController.php
protected function migrateToVersion(RequestApplicationInterface $app, $version)
    {
        $originalVersion = $version;

        return $this->getNewMigrations()->then(
            function($migrations) use ($app, $version) {
                foreach ($migrations as $i => $migration) {
                    if (strpos($migration, $version) === 0) {
                        return $this->actionUp($app, $i + 1);
                    }
                }
                return reject(null);
            }
        )->then(null, function() use ($app, $version, $originalVersion) {
            return $this->getMigrationHistory(null)
                ->then(function($migrations) use ($app, $version, $originalVersion) {
                    $migrations = array_keys($migrations);
                    foreach ($migrations as $i => $migration) {
                        if (strpos($migration, $version, $originalVersion) === 0) {
                            if ($i === 0) {
                                $this->stdout("Already at '$originalVersion'. Nothing needs to be done.\n", Console::FG_YELLOW);
                            } else {
                                $this->actionDown($app, $i);
                            }

                            return resolve(true);
                        }
                    }
                    throw new Exception("Unable to find the version '$originalVersion'.");
                });
        });
    }
protected function migrateToVersion(RequestApplicationInterface $app, $version)
    {
        $originalVersion = $version;

        return $this->getNewMigrations()->then(
            function($migrations) use ($app, $version) {
                foreach ($migrations as $i => $migration) {
                    if (strpos($migration, $version) === 0) {
                        return $this->actionUp($app, $i + 1);
                    }
                }
                return reject(null);
            }
        )->then(null, function() use ($app, $version, $originalVersion) {
            return $this->getMigrationHistory(null)
                ->then(function($migrations) use ($app, $version, $originalVersion) {
                    $migrations = array_keys($migrations);
                    foreach ($migrations as $i => $migration) {
                        if (strpos($migration, $version, $originalVersion) === 0) {
                            if ($i === 0) {
                                $this->stdout("Already at '$originalVersion'. Nothing needs to be done.\n", Console::FG_YELLOW);
                            } else {
                                $this->actionDown($app, $i);
                            }

                            return resolve(true);
                        }
                    }
                    throw new Exception("Unable to find the version '$originalVersion'.");
                });
        });
    }
Migrates to the certain version.
@param RequestApplicationInterface $app
@param string                      $version name in the full format.
@return ExtendedPromiseInterface
@throws Exception if the provided version cannot be found.