X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/070d4aeb6ca9af987c551aede0e3b37688a0808e..refs/pull/524/head:/app/Console/Commands/RegenerateSearch.php diff --git a/app/Console/Commands/RegenerateSearch.php b/app/Console/Commands/RegenerateSearch.php index ccc2a20e5..1757911a7 100644 --- a/app/Console/Commands/RegenerateSearch.php +++ b/app/Console/Commands/RegenerateSearch.php @@ -12,7 +12,7 @@ class RegenerateSearch extends Command * * @var string */ - protected $signature = 'bookstack:regenerate-search'; + protected $signature = 'bookstack:regenerate-search {--database= : The database connection to use.}'; /** * The console command description. @@ -41,6 +41,14 @@ class RegenerateSearch extends Command */ public function handle() { + $connection = \DB::getDefaultConnection(); + if ($this->option('database') !== null) { + \DB::setDefaultConnection($this->option('database')); + $this->searchService->setConnection(\DB::connection($this->option('database'))); + } + $this->searchService->indexAllEntities(); + \DB::setDefaultConnection($connection); + $this->comment('Search index regenerated'); } }