'Specify a batch to roll back to; e.g. "3" to return to batch #3 or "-2" to roll back twice', '-g' => 'Set database group', ]; /** * Runs all of the migrations in reverse order, until they have * all been un-applied. * * @param array $params */ public function run(array $params = []) { $runner = Services::migrations(); $group = $params['-g'] ?? CLI::getOption('g'); if (! is_null($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::write(lang('Migrations.generalFault'), 'red'); } $messages = $runner->getCliMessages(); foreach ($messages as $message) { CLI::write($message); } CLI::write('Done'); } catch (\Exception $e) { $this->showError($e); } } }