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

actionUp() публичный Метод

For example, ~~~ yii migrate # apply all new migrations yii migrate 3 # apply the first 3 new migrations ~~~
public actionUp ( integer $limit )
$limit integer the number of new migrations to be applied. If 0, it means applying all available new migrations.
    public function actionUp($limit = 0)
    {
        $migrations = $this->getNewMigrations();
        if (empty($migrations)) {
            echo "No new migration found. Your system is up-to-date.\n";
            return;
        }
        $total = count($migrations);
        $limit = (int) $limit;
        if ($limit > 0) {
            $migrations = array_slice($migrations, 0, $limit);
        }
        $n = count($migrations);
        if ($n === $total) {
            echo "Total {$n} new " . ($n === 1 ? 'migration' : 'migrations') . " to be applied:\n";
        } else {
            echo "Total {$n} out of {$total} new " . ($total === 1 ? 'migration' : 'migrations') . " to be applied:\n";
        }
        echo "\nMigrations:\n";
        foreach ($migrations as $migration => $alias) {
            echo "    " . $migration . " (" . $alias . ")\n";
        }
        if ($this->confirm('Apply the above ' . ($n === 1 ? 'migration' : 'migrations') . "?")) {
            foreach ($migrations as $migration => $alias) {
                if (!$this->migrateUp($migration, $alias)) {
                    echo "\nMigration failed. The rest of the migrations are canceled.\n";
                    return;
                }
            }
            echo "\nMigrated up successfully.\n";
        }
    }