src/Console/Controllers/BaseMigrateController.php
public function actionUp(RequestApplicationInterface $app, $limit = 0)
    {
        return $this->getNewMigrations()->then(
            function($migrations) use ($limit) {
                if (empty($migrations)) {
                    $this->stdout("No new migrations found. Your system is up-to-date.\n", Console::FG_GREEN);

                    return true;
                }

                $total = count($migrations);
                $limit = (int)$limit;
                if ($limit > 0) {
                    $migrations = array_slice($migrations, 0, $limit);
                }

                $n = count($migrations);
                if ($n === $total) {
                    $this->stdout("Total $n new " . ($n === 1 ? 'migration' : 'migrations') . " to be applied:\n", Console::FG_YELLOW);
                } else {
                    $this->stdout("Total $n out of $total new " . ($total === 1 ? 'migration' : 'migrations') . " to be applied:\n", Console::FG_YELLOW);
                }

                foreach ($migrations as $migration) {
                    $nameLimit = $this->getMigrationNameLimit();
                    if ($nameLimit !== null && strlen($migration) > $nameLimit) {
                        $message = "The migration name '$migration' is too long. Its not possible to apply this migration.";
                        $this->stdout("\n$message\n", Console::FG_RED);
                        throw new Exception($message);
                    }
                    $this->stdout("\t$migration\n");
                }
                $this->stdout("\n");

                $applied = 0;
                return $this->confirm('Apply the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')->then(
                    function() use ($migrations, $n, &$applied) {
                        $promises = [];
                        foreach ($migrations as $migration) {
                            $promises[] = $this->migrateUp($migration)->thenLazy(
                                function() use (&$applied) {
                                    $applied++;
                                    return true;
                                },
                                function($error = null) use ($applied, $n) {
                                    $this->stdout("\n$applied from $n " . ($applied === 1 ? 'migration was' : 'migrations were') . " applied.\n", Console::FG_RED);
                                    $this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED);
                                    $prevException = $error instanceof \Throwable ? $error : null;
                                    $exception = new Exception("Migration failed. The rest of the migrations are canceled", 0, $prevException);
                                    return reject($exception);
                                }
                            );
                        }

                        return allInOrder($promises)->then(
                            function() use ($n) {
                                $this->stdout("\n$n " . ($n === 1 ? 'migration was' : 'migrations were') . " applied.\n", Console::FG_GREEN);
                                $this->stdout("\nMigrated up successfully.\n", Console::FG_GREEN);
                                return true;
                            }
                        );
                    }
                );
            }
        );
    }
public function actionUp(RequestApplicationInterface $app, $limit = 0)
    {
        return $this->getNewMigrations()->then(
            function($migrations) use ($limit) {
                if (empty($migrations)) {
                    $this->stdout("No new migrations found. Your system is up-to-date.\n", Console::FG_GREEN);

                    return true;
                }

                $total = count($migrations);
                $limit = (int)$limit;
                if ($limit > 0) {
                    $migrations = array_slice($migrations, 0, $limit);
                }

                $n = count($migrations);
                if ($n === $total) {
                    $this->stdout("Total $n new " . ($n === 1 ? 'migration' : 'migrations') . " to be applied:\n", Console::FG_YELLOW);
                } else {
                    $this->stdout("Total $n out of $total new " . ($total === 1 ? 'migration' : 'migrations') . " to be applied:\n", Console::FG_YELLOW);
                }

                foreach ($migrations as $migration) {
                    $nameLimit = $this->getMigrationNameLimit();
                    if ($nameLimit !== null && strlen($migration) > $nameLimit) {
                        $message = "The migration name '$migration' is too long. Its not possible to apply this migration.";
                        $this->stdout("\n$message\n", Console::FG_RED);
                        throw new Exception($message);
                    }
                    $this->stdout("\t$migration\n");
                }
                $this->stdout("\n");

                $applied = 0;
                return $this->confirm('Apply the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')->then(
                    function() use ($migrations, $n, &$applied) {
                        $promises = [];
                        foreach ($migrations as $migration) {
                            $promises[] = $this->migrateUp($migration)->thenLazy(
                                function() use (&$applied) {
                                    $applied++;
                                    return true;
                                },
                                function($error = null) use ($applied, $n) {
                                    $this->stdout("\n$applied from $n " . ($applied === 1 ? 'migration was' : 'migrations were') . " applied.\n", Console::FG_RED);
                                    $this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED);
                                    $prevException = $error instanceof \Throwable ? $error : null;
                                    $exception = new Exception("Migration failed. The rest of the migrations are canceled", 0, $prevException);
                                    return reject($exception);
                                }
                            );
                        }

                        return allInOrder($promises)->then(
                            function() use ($n) {
                                $this->stdout("\n$n " . ($n === 1 ? 'migration was' : 'migrations were') . " applied.\n", Console::FG_GREEN);
                                $this->stdout("\nMigrated up successfully.\n", Console::FG_GREEN);
                                return true;
                            }
                        );
                    }
                );
            }
        );
    }
Upgrades the application by applying new migrations.

For example,

```
console migrate     # apply all new migrations
console migrate 3   # apply the first 3 new migrations
```

@param RequestApplicationInterface $app
@param int                         $limit the number of new migrations to be applied. If 0, it means
applying all available new migrations.

@return ExtendedPromiseInterface