mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 19:14:04 +00:00
Better solution for tenant DB exception
This commit is contained in:
parent
41aead5da2
commit
405a137ca1
5 changed files with 10 additions and 8 deletions
|
|
@ -22,9 +22,13 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper
|
|||
public function bootstrap(Tenant $tenant)
|
||||
{
|
||||
/** @var TenantWithDatabase $tenant */
|
||||
$database = $tenant->database()->getName();
|
||||
if (! $tenant->database()->manager()->databaseExists($database)) {
|
||||
throw new TenantDatabaseDoesNotExistException($database);
|
||||
|
||||
// Better debugging, but breaks cached lookup in prod
|
||||
if (app()->environment('local')) {
|
||||
$database = $tenant->database()->getName();
|
||||
if (! $tenant->database()->manager()->databaseExists($database)) {
|
||||
throw new TenantDatabaseDoesNotExistException($database);
|
||||
}
|
||||
}
|
||||
|
||||
$this->database->connectToTenant($tenant);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue