yii\console\controllers\BaseMigrateController::actionHistory PHP Method

actionHistory() public method

This command will show the list of migrations that have been applied so far. For example, yii migrate/history # showing the last 10 migrations yii migrate/history 5 # showing the last 5 migrations yii migrate/history all # showing the whole history
public actionHistory ( integer $limit = 10 )
$limit integer the maximum number of migrations to be displayed. If it is "all", the whole migration history will be displayed.
    public function actionHistory($limit = 10)
    {
        if ($limit === 'all') {
            $limit = null;
        } else {
            $limit = (int) $limit;
            if ($limit < 1) {
                throw new Exception('The limit must be greater than 0.');
            }
        }
        $migrations = $this->getMigrationHistory($limit);
        if (empty($migrations)) {
            $this->stdout("No migration has been done before.\n", Console::FG_YELLOW);
        } else {
            $n = count($migrations);
            if ($limit > 0) {
                $this->stdout("Showing the last {$n} applied " . ($n === 1 ? 'migration' : 'migrations') . ":\n", Console::FG_YELLOW);
            } else {
                $this->stdout("Total {$n} " . ($n === 1 ? 'migration has' : 'migrations have') . " been applied before:\n", Console::FG_YELLOW);
            }
            foreach ($migrations as $version => $time) {
                $this->stdout("\t(" . date('Y-m-d H:i:s', $time) . ') ' . $version . "\n");
            }
        }
    }