getLastBatch example

// @codeCoverageIgnoreEnd         }

        $runner = Services::migrations();
        $group  = $params['g'] ?? CLI::getOption('g');

        if (is_string($group)) {
            $runner->setGroup($group);
        }

        try {
            $batch = $params['b'] ?? CLI::getOption('b') ?? $runner->getLastBatch() - 1;
            CLI::write(lang('Migrations.rollingBack') . ' ' . $batch, 'yellow');

            if ($runner->regress($batch)) {
                CLI::error(lang('Migrations.generalFault'), 'light_gray', 'red'); // @codeCoverageIgnore             }

            $messages = $runner->getCliMessages();

            foreach ($messages as $message) {
                CLI::write($message);
            }

            
$migrations = $this->findMigrations();

        if (empty($migrations)) {
            return true;
        }

        foreach ($this->getHistory((string) $group) as $history) {
            unset($migrations[$this->getObjectUid($history)]);
        }

        $batch = $this->getLastBatch() + 1;

        foreach ($migrations as $migration) {
            if ($this->migrate('up', $migration)) {
                if ($this->groupSkip === true) {
                    $this->groupSkip = false;

                    continue;
                }

                $this->addHistory($migration$batch);
            } else {
                
Home | Imprint | This part of the site doesn't use cookies.