Rename to reset and make extension an option

This commit is contained in:
Clark Winkelmann 2018-02-11 20:03:54 +01:00
parent 5561e28286
commit 58ffa27bfb
No known key found for this signature in database
GPG Key ID: AC336FBC86CCD80B
2 changed files with 18 additions and 10 deletions

View File

@ -14,7 +14,7 @@ namespace Flarum\Console;
use Flarum\Console\Event\Configuring; use Flarum\Console\Event\Configuring;
use Flarum\Database\Console\GenerateMigrationCommand; use Flarum\Database\Console\GenerateMigrationCommand;
use Flarum\Database\Console\MigrateCommand; use Flarum\Database\Console\MigrateCommand;
use Flarum\Database\Console\RollbackCommand; use Flarum\Database\Console\ResetCommand;
use Flarum\Foundation\Application; use Flarum\Foundation\Application;
use Flarum\Foundation\Console\CacheClearCommand; use Flarum\Foundation\Console\CacheClearCommand;
use Flarum\Foundation\Console\InfoCommand; use Flarum\Foundation\Console\InfoCommand;
@ -59,7 +59,7 @@ class Server
$commands = [ $commands = [
InstallCommand::class, InstallCommand::class,
MigrateCommand::class, MigrateCommand::class,
RollbackCommand::class, ResetCommand::class,
GenerateMigrationCommand::class, GenerateMigrationCommand::class,
]; ];

View File

@ -13,9 +13,9 @@ namespace Flarum\Database\Console;
use Flarum\Console\AbstractCommand; use Flarum\Console\AbstractCommand;
use Flarum\Extension\ExtensionManager; 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 * @var ExtensionManager
@ -38,12 +38,13 @@ class RollbackCommand extends AbstractCommand
protected function configure() protected function configure()
{ {
$this $this
->setName('migrate:rollback') ->setName('migrate:reset')
->setDescription('Run rollback migrations for an extension') ->setDescription('Run all migrations down for an extension')
->addArgument( ->addOption(
'extension', 'extension',
InputArgument::REQUIRED, null,
'The name of the extension.' InputOption::VALUE_REQUIRED,
'The extension to reset migrations for.'
); );
} }
@ -52,7 +53,14 @@ class RollbackCommand extends AbstractCommand
*/ */
protected function fire() 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); $extension = $this->manager->getExtension($extensionName);
if (! $extension) { if (! $extension) {