argument('name'); if (! Admin::extension()->has($name)) { throw new \InvalidArgumentException('Extension not found'); } $stopOnVersion = ltrim(($this->argument('ver') ?: null), 'v'); if ($stopOnVersion) { if (! Admin::extension()->versionManager()->hasDatabaseVersion($name, $stopOnVersion)) { throw new \InvalidArgumentException('Extension version not found'); } $confirmQuestion = 'Please confirm that you wish to revert the extension to version '.$stopOnVersion.'. This may result in changes to your database and potential data loss.'; } else { $confirmQuestion = 'Please confirm that you wish to completely rollback this extension. This may result in potential data loss.'; } if ($this->option('force') || $this->confirm($confirmQuestion)) { try { Admin::extension() ->updateManager() ->setOutPut($this->output) ->rollback($name, $stopOnVersion); } catch (\Throwable $exception) { $lastVersion = Admin::extension()->versionManager()->getCurrentVersion($name); $this->output->writeln(sprintf('An exception occurred during the rollback and the process has been stopped. The extension was rolled back to version v%s.', $lastVersion)); throw $exception; } } } }