console\controllers\MigrateController::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 0 # showing the whole history ~~~
public actionHistory ( integer $limit = 10 )
$limit integer the maximum number of migrations to be displayed. If it is 0, the whole migration history will be displayed.
    public function actionHistory($limit = 10)
    {
        $limit = (int) $limit;
        $migrations = $this->getMigrationHistory($limit);
        if (empty($migrations)) {
            echo "No migration has been done before.\n";
        } else {
            $n = count($migrations);
            if ($limit > 0) {
                echo "Showing the last {$n} applied " . ($n === 1 ? 'migration' : 'migrations') . ":\n";
            } else {
                echo "Total {$n} " . ($n === 1 ? 'migration has' : 'migrations have') . " been applied before:\n";
            }
            foreach ($migrations as $version => $info) {
                echo "    (" . date('Y-m-d H:i:s', $info['apply_time']) . ') ' . $version . "\n";
            }
        }
    }