Skip to content

Commit d4df356

Browse files
[9.x] Added --pending option to migrate:status (#46089)
* Added --pending option to migrate:status * Update StatusCommand.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 152e223 commit d4df356

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ public function handle()
6565

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

68-
$migrations->each(
69-
fn ($migration) => $this->components->twoColumnDetail($migration[0], $migration[1])
70-
);
68+
$migrations
69+
->when($this->option('pending'), fn ($collection) => $collection->filter(function ($migration) {
70+
return str($migration[1])->contains('Pending');
71+
}))
72+
->each(
73+
fn ($migration) => $this->components->twoColumnDetail($migration[0], $migration[1])
74+
);
7175

7276
$this->newLine();
7377
} else {
@@ -120,9 +124,8 @@ protected function getOptions()
120124
{
121125
return [
122126
['database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use'],
123-
127+
['pending', null, InputOption::VALUE_NONE, 'Only list pending migrations'],
124128
['path', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The path(s) to the migrations files to use'],
125-
126129
['realpath', null, InputOption::VALUE_NONE, 'Indicate any provided migration file paths are pre-resolved absolute paths'],
127130
];
128131
}

0 commit comments

Comments
 (0)