From 0655ff8a03d5a5057cb8c854ae322f81b5f606e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Wed, 30 Mar 2022 17:54:34 +0200 Subject: [PATCH] wip --- src/Commands/Migrate.php | 7 ++++++- src/Commands/MigrateFresh.php | 2 +- src/Commands/Rollback.php | 2 +- src/Concerns/ExtendsLaravelCommand.php | 11 ++++------- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Commands/Migrate.php b/src/Commands/Migrate.php index f14bb49c..c67d3598 100644 --- a/src/Commands/Migrate.php +++ b/src/Commands/Migrate.php @@ -19,11 +19,16 @@ class Migrate extends MigrateCommand protected $description = 'Run migrations for tenant(s)'; + protected static function getTenantCommandName(): string + { + return 'tenants:migrate'; + } + public function __construct(Migrator $migrator, Dispatcher $dispatcher) { parent::__construct($migrator, $dispatcher); - $this->specifyTenantSignature(); + $this->specifyParameters(); } /** diff --git a/src/Commands/MigrateFresh.php b/src/Commands/MigrateFresh.php index 4d003db0..283d70b0 100644 --- a/src/Commands/MigrateFresh.php +++ b/src/Commands/MigrateFresh.php @@ -23,7 +23,7 @@ final class MigrateFresh extends Command public function __construct() { parent::__construct(); - + $this->addOption('--drop-views', null, InputOption::VALUE_NONE, 'Drop views along with tenant tables.', null); $this->setName('tenants:migrate-fresh'); diff --git a/src/Commands/Rollback.php b/src/Commands/Rollback.php index d00a0c4f..e60d974b 100644 --- a/src/Commands/Rollback.php +++ b/src/Commands/Rollback.php @@ -16,7 +16,7 @@ class Rollback extends RollbackCommand { use HasATenantsOption, DealsWithMigrations, ExtendsLaravelCommand; - protected static function getTenantCommandName() + protected static function getTenantCommandName(): string { return 'tenants:rollback'; } diff --git a/src/Concerns/ExtendsLaravelCommand.php b/src/Concerns/ExtendsLaravelCommand.php index f40c85f7..bdafc8f7 100644 --- a/src/Concerns/ExtendsLaravelCommand.php +++ b/src/Concerns/ExtendsLaravelCommand.php @@ -6,21 +6,18 @@ trait ExtendsLaravelCommand { protected function specifyTenantSignature(): void { - $this->setName('tenants:migrate'); $this->specifyParameters(); } public function getName(): ?string { - return static::getDefaultName(); + return static::getTenantCommandName(); } public static function getDefaultName(): ?string { - if (method_exists(static::class, 'getTenantCommandName')) { - return static::getTenantCommandName(); - } - - return 'tenants:' . parent::getDefaultName(); + return static::getTenantCommandName(); } + + abstract protected static function getTenantCommandName(): string; }