1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 15:54:03 +00:00

Revert "Get rid of TenantDatabaseDoesNotExist exception"

This reverts commit fe52a3c4ea.
This commit is contained in:
Samuel Štancl 2020-06-29 12:14:58 +02:00
parent 9ed46bbc35
commit 41aead5da2
6 changed files with 27 additions and 3 deletions

View file

@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Bootstrappers;
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Database\DatabaseManager;
use Stancl\Tenancy\Exceptions\TenantDatabaseDoesNotExistException;
class DatabaseTenancyBootstrapper implements TenancyBootstrapper
{
@ -20,6 +21,12 @@ 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);
}
$this->database->connectToTenant($tenant);
}