]> BookStack Code Mirror - bookstack/blobdiff - app/Console/Commands/RegeneratePermissions.php
Update search.js
[bookstack] / app / Console / Commands / RegeneratePermissions.php
index 60d5f4e455ac8b4bc64cffd25effc585e261a4e4..9cd577a17864b5c3c759f24ae2a07e7fdb6f4f44 100644 (file)
@@ -12,7 +12,7 @@ class RegeneratePermissions extends Command
      *
      * @var string
      */
-    protected $signature = 'permissions:regen';
+    protected $signature = 'bookstack:regenerate-permissions {--database= : The database connection to use.}';
 
     /**
      * The console command description.
@@ -46,6 +46,15 @@ class RegeneratePermissions extends Command
      */
     public function handle()
     {
+        $connection = \DB::getDefaultConnection();
+        if ($this->option('database') !== null) {
+            \DB::setDefaultConnection($this->option('database'));
+            $this->permissionService->setConnection(\DB::connection($this->option('database')));
+        }
+
         $this->permissionService->buildJointPermissions();
+
+        \DB::setDefaultConnection($connection);
+        $this->comment('Permissions regenerated');
     }
 }