diff --git a/src/DatabaseManager.php b/src/DatabaseManager.php index 6d580c1a..4e81e5ec 100644 --- a/src/DatabaseManager.php +++ b/src/DatabaseManager.php @@ -182,7 +182,7 @@ class DatabaseManager * @param Tenant $tenant * @return TenantDatabaseManager */ - protected function getTenantDatabaseManager(Tenant $tenant): TenantDatabaseManager + public function getTenantDatabaseManager(Tenant $tenant): TenantDatabaseManager { $driver = $this->getDriver($this->getBaseConnection($tenant->getConnectionName())); diff --git a/src/Exceptions/TenantDatabaseDoesNotExistException.php b/src/Exceptions/TenantDatabaseDoesNotExistException.php new file mode 100644 index 00000000..8bd15fd3 --- /dev/null +++ b/src/Exceptions/TenantDatabaseDoesNotExistException.php @@ -0,0 +1,13 @@ +getDatabaseName(); + if (! $this->database->getTenantDatabaseManager($tenant)->databaseExists($database)) { + throw new TenantDatabaseDoesNotExistException($database); + } + $this->database->connect($tenant); }