Skip to content

Commit 9f57e8c

Browse files
Add --flush option to ImportCommand (#937)
* Add `--flush` option to ImportCommand Adds the `--flush` flag to `artisan scout:import` which if passed in, will flush the index out before importing * Update ImportCommand.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 14ebad0 commit 9f57e8c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Console/ImportCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class ImportCommand extends Command
1717
*/
1818
protected $signature = 'scout:import
1919
{model : Class name of model to bulk import}
20+
{--fresh : Flush the index before importing}
2021
{--c|chunk= : The number of records to import at a time (Defaults to configuration value: `scout.chunk.searchable`)}';
2122

2223
/**
@@ -44,6 +45,10 @@ public function handle(Dispatcher $events)
4445
$this->line('<comment>Imported ['.$class.'] models up to ID:</comment> '.$key);
4546
});
4647

48+
if ($this->option('fresh')) {
49+
$model::removeAllFromSearch();
50+
}
51+
4752
$model::makeAllSearchable($this->option('chunk'));
4853

4954
$events->forget(ModelsImported::class);

0 commit comments

Comments
 (0)