1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 12:04:03 +00:00

Make sure central connections aren't ever purged

This commit is contained in:
Samuel Štancl 2019-10-19 22:41:40 +02:00
parent c8a0a58df6
commit 93283d39ed

View file

@ -39,6 +39,7 @@ class DatabaseManager
public function connect(Tenant $tenant) public function connect(Tenant $tenant)
{ {
$this->createTenantConnection($tenant->getDatabaseName(), $tenant->getConnectionName()); $this->createTenantConnection($tenant->getDatabaseName(), $tenant->getConnectionName());
$this->setDefaultConnection($tenant->getConnectionName());
$this->switchConnection($tenant->getConnectionName()); $this->switchConnection($tenant->getConnectionName());
} }
@ -49,7 +50,10 @@ class DatabaseManager
*/ */
public function reconnect() public function reconnect()
{ {
// Opposite order to connect() because we don't
// want to ever purge the central connection
$this->switchConnection($this->originalDefaultConnectionName); $this->switchConnection($this->originalDefaultConnectionName);
$this->setDefaultConnection($this->originalDefaultConnectionName);
} }
/** /**