From 58ffa27bfbe2a44c9d3783eab6b1d7f27c235780 Mon Sep 17 00:00:00 2001 From: Clark Winkelmann Date: Sun, 11 Feb 2018 20:03:54 +0100 Subject: [PATCH] Rename to reset and make extension an option --- src/Console/Server.php | 4 ++-- .../{RollbackCommand.php => ResetCommand.php} | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) rename src/Database/Console/{RollbackCommand.php => ResetCommand.php} (69%) diff --git a/src/Console/Server.php b/src/Console/Server.php index 759a7efc6..c5a8d6b4d 100644 --- a/src/Console/Server.php +++ b/src/Console/Server.php @@ -14,7 +14,7 @@ namespace Flarum\Console; use Flarum\Console\Event\Configuring; use Flarum\Database\Console\GenerateMigrationCommand; use Flarum\Database\Console\MigrateCommand; -use Flarum\Database\Console\RollbackCommand; +use Flarum\Database\Console\ResetCommand; use Flarum\Foundation\Application; use Flarum\Foundation\Console\CacheClearCommand; use Flarum\Foundation\Console\InfoCommand; @@ -59,7 +59,7 @@ class Server $commands = [ InstallCommand::class, MigrateCommand::class, - RollbackCommand::class, + ResetCommand::class, GenerateMigrationCommand::class, ]; diff --git a/src/Database/Console/RollbackCommand.php b/src/Database/Console/ResetCommand.php similarity index 69% rename from src/Database/Console/RollbackCommand.php rename to src/Database/Console/ResetCommand.php index f2a48dc14..63eb3481c 100644 --- a/src/Database/Console/RollbackCommand.php +++ b/src/Database/Console/ResetCommand.php @@ -13,9 +13,9 @@ namespace Flarum\Database\Console; use Flarum\Console\AbstractCommand; use Flarum\Extension\ExtensionManager; -use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; -class RollbackCommand extends AbstractCommand +class ResetCommand extends AbstractCommand { /** * @var ExtensionManager @@ -38,12 +38,13 @@ class RollbackCommand extends AbstractCommand protected function configure() { $this - ->setName('migrate:rollback') - ->setDescription('Run rollback migrations for an extension') - ->addArgument( + ->setName('migrate:reset') + ->setDescription('Run all migrations down for an extension') + ->addOption( 'extension', - InputArgument::REQUIRED, - 'The name of the extension.' + null, + InputOption::VALUE_REQUIRED, + 'The extension to reset migrations for.' ); } @@ -52,7 +53,14 @@ class RollbackCommand extends AbstractCommand */ protected function fire() { - $extensionName = $this->input->getArgument('extension'); + $extensionName = $this->input->getOption('extension'); + + if (! $extensionName) { + $this->info('No extension specified. Please check command syntax.'); + + return; + } + $extension = $this->manager->getExtension($extensionName); if (! $extension) {