Skip to content

Commit

Permalink
[10.x] Fix empty table not shown with --pending option (#48019)
Browse files Browse the repository at this point in the history
* Fix "No migrations found" not shown with --pending

* Improve message for no pending migrations

* Fix StyleCI issues

* Update StatusCommand.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
TheBlckbird and taylorotwell committed Aug 10, 2023
1 parent fba827a commit 746ad0e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Illuminate/Database/Console/Migrations/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,24 @@ public function handle()

$batches = $this->migrator->getRepository()->getMigrationBatches();

if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) {
$migrations = $this->getStatusFor($ran, $batches)
->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) {
return str($migration[1])->contains('Pending');
}));

if (count($migrations) > 0) {
$this->newLine();

$this->components->twoColumnDetail('<fg=gray>Migration name</>', '<fg=gray>Batch / Status</>');

$migrations
->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) {
return str($migration[1])->contains('Pending');
}))
->each(
fn ($migration) => $this->components->twoColumnDetail($migration[0], $migration[1])
);

$this->newLine();
} elseif ($this->option('pending')) {
$this->components->info('No pending migrations');
} else {
$this->components->info('No migrations found');
}
Expand Down

0 comments on commit 746ad0e

Please sign in to comment.