]> BookStack Code Mirror - bookstack/blobdiff - app/Console/Commands/RegenerateSearch.php
Fixed model extending mis-use
[bookstack] / app / Console / Commands / RegenerateSearch.php
index ccc2a20e59896b7ed0166fa565a7830dfd1c106c..35ecd46c0817ddac6e201f161dec73068e9085d6 100644 (file)
@@ -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,13 @@ class RegenerateSearch extends Command
      */
     public function handle()
     {
+        $connection = \DB::getDefaultConnection();
+        if ($this->option('database') !== null) {
+            \DB::setDefaultConnection($this->option('database'));
+        }
+
         $this->searchService->indexAllEntities();
+        \DB::setDefaultConnection($connection);
+        $this->comment('Search index regenerated');
     }
 }