mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 22:34:03 +00:00
TenantDatabaseManagerTest fully passes now
This commit is contained in:
parent
5e9b421aa6
commit
524530c8d5
8 changed files with 28 additions and 24 deletions
|
|
@ -10,6 +10,7 @@ use Stancl\Tenancy\Contracts\TenantDatabaseManager;
|
|||
use Stancl\Tenancy\Exceptions\DatabaseManagerNotRegisteredException;
|
||||
use Stancl\Tenancy\Exceptions\TenantDatabaseAlreadyExistsException;
|
||||
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseCreator;
|
||||
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseDeleter;
|
||||
|
||||
class DatabaseManager
|
||||
{
|
||||
|
|
@ -108,7 +109,7 @@ class DatabaseManager
|
|||
$manager = $this->getTenantDatabaseManager($tenant);
|
||||
|
||||
if ($this->app['config']['tenancy.queue_database_creation'] ?? false) {
|
||||
QueuedTenantDatabaseCreator::dispatch($manager, $database, 'create');
|
||||
QueuedTenantDatabaseCreator::dispatch($manager, $database);
|
||||
} else {
|
||||
return $manager->createDatabase($database);
|
||||
}
|
||||
|
|
@ -119,8 +120,8 @@ class DatabaseManager
|
|||
$database = $tenant->getDatabaseName();
|
||||
$manager = $this->getTenantDatabaseManager($tenant);
|
||||
|
||||
if ($this->app['config']['tenancy.queue_database_creation'] ?? false) {
|
||||
QueuedTenantDatabaseCreator::dispatch($manager, $database, 'delete');
|
||||
if ($this->app['config']['tenancy.queue_database_deletion'] ?? false) {
|
||||
QueuedTenantDatabaseDeleter::dispatch($manager, $database);
|
||||
} else {
|
||||
return $manager->deleteDatabase($database);
|
||||
}
|
||||
|
|
@ -128,6 +129,7 @@ class DatabaseManager
|
|||
|
||||
protected function getTenantDatabaseManager(Tenant $tenant): TenantDatabaseManager
|
||||
{
|
||||
// todo this shouldn't have to create a connection
|
||||
$this->createTenantConnection($tenant->getDatabaseName(), $tenant->getConnectionName());
|
||||
$driver = $this->getDriver($tenant->getConnectionName());
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Facades;
|
|||
use Illuminate\Support\Facades\Facade;
|
||||
use Stancl\Tenancy\Tenant as Tenant;
|
||||
|
||||
// todo rename to CurrentTenant?
|
||||
class TenantFacade extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ class Tenant implements ArrayAccess
|
|||
public function delete(): self
|
||||
{
|
||||
if ($this->persisted) {
|
||||
$this->tenantManager->deleteTenant($this);
|
||||
$this->manager->deleteTenant($this);
|
||||
$this->persisted = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -253,6 +253,11 @@ class TenantManager
|
|||
return $this->app['config']['tenancy.migrate_after_creation'] ?? false;
|
||||
}
|
||||
|
||||
public function shouldDeleteDatabase(): bool
|
||||
{
|
||||
return $this->app['config']['tenancy.delete_database_after_tenant_deletion'] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an event listener.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue