Skip to content

Commit 746ad0e

Browse files
[10.x] Fix empty table not shown with --pending option (#48019)
* 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 <[email protected]>
1 parent fba827a commit 746ad0e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Illuminate/Database/Console/Migrations/StatusCommand.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,24 @@ public function handle()
6060

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

63-
if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) {
63+
$migrations = $this->getStatusFor($ran, $batches)
64+
->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) {
65+
return str($migration[1])->contains('Pending');
66+
}));
67+
68+
if (count($migrations) > 0) {
6469
$this->newLine();
6570

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

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

7678
$this->newLine();
79+
} elseif ($this->option('pending')) {
80+
$this->components->info('No pending migrations');
7781
} else {
7882
$this->components->info('No migrations found');
7983
}

0 commit comments

Comments
 (0)