From e7464d1b1493817122834dfed970a5d43aa98ea5 Mon Sep 17 00:00:00 2001 From: "brecht.vermeersch" Date: Wed, 8 May 2024 11:50:45 +0200 Subject: [PATCH 1/3] Add status code to pending option --- .../Database/Console/Migrations/StatusCommand.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 9c4513b37716..0aa246b9bef1 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -63,7 +63,7 @@ public function handle() $batches = $this->migrator->getRepository()->getMigrationBatches(); $migrations = $this->getStatusFor($ran, $batches) - ->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) { + ->when($this->hasOption('pending'), fn ($collection) => $collection->filter(function ($migration) { return str($migration[1])->contains('Pending'); })); @@ -78,11 +78,15 @@ public function handle() ); $this->newLine(); - } elseif ($this->option('pending')) { + } elseif ($this->hasOption('pending')) { $this->components->info('No pending migrations'); } else { $this->components->info('No migrations found'); } + + if($this->option('pending') && $migrations->some(fn ($m) => str($m[1])->contains('Pending'))) { + return $this->option('pending'); + } }); } @@ -130,7 +134,7 @@ protected function getOptions() { return [ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'], - ['pending', null, InputOption::VALUE_NONE, 'Only list pending migrations'], + ['pending', null, InputOption::VALUE_OPTIONAL, 'Only list pending migrations'], ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to use'], ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'], ]; From fc7f86d861e696e0db45ef211b4e68c5b45e5cf8 Mon Sep 17 00:00:00 2001 From: "brecht.vermeersch" Date: Wed, 8 May 2024 13:36:04 +0200 Subject: [PATCH 2/3] Add default false --- .../Database/Console/Migrations/StatusCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 0aa246b9bef1..1ff26cadb6a8 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -63,7 +63,7 @@ public function handle() $batches = $this->migrator->getRepository()->getMigrationBatches(); $migrations = $this->getStatusFor($ran, $batches) - ->when($this->hasOption('pending'), fn ($collection) => $collection->filter(function ($migration) { + ->when($this->option('pending') !== false, fn ($collection) => $collection->filter(function ($migration) { return str($migration[1])->contains('Pending'); })); @@ -78,7 +78,7 @@ public function handle() ); $this->newLine(); - } elseif ($this->hasOption('pending')) { + } elseif ($this->option('pending') !== false) { $this->components->info('No pending migrations'); } else { $this->components->info('No migrations found'); @@ -134,7 +134,7 @@ protected function getOptions() { return [ ['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'], - ['pending', null, InputOption::VALUE_OPTIONAL, 'Only list pending migrations'], + ['pending', null, InputOption::VALUE_OPTIONAL, 'Only list pending migrations', false], ['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to use'], ['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'], ]; From 87adf5d3ef513212d24d9b41593972319b8ed97d Mon Sep 17 00:00:00 2001 From: "brecht.vermeersch" Date: Wed, 8 May 2024 13:40:16 +0200 Subject: [PATCH 3/3] Fix styling --- src/Illuminate/Database/Console/Migrations/StatusCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Console/Migrations/StatusCommand.php b/src/Illuminate/Database/Console/Migrations/StatusCommand.php index 1ff26cadb6a8..8b8131dd2757 100644 --- a/src/Illuminate/Database/Console/Migrations/StatusCommand.php +++ b/src/Illuminate/Database/Console/Migrations/StatusCommand.php @@ -84,7 +84,7 @@ public function handle() $this->components->info('No migrations found'); } - if($this->option('pending') && $migrations->some(fn ($m) => str($m[1])->contains('Pending'))) { + if ($this->option('pending') && $migrations->some(fn ($m) => str($m[1])->contains('Pending'))) { return $this->option('pending'); } });