From 2a6290be9c037a42480f0200cdc74f2594f18343 Mon Sep 17 00:00:00 2001 From: Abrar Ahmad Date: Fri, 23 Sep 2022 11:39:21 +0500 Subject: [PATCH] todo and comments --- src/Database/DatabaseConfig.php | 4 +++- tests/TenantDatabaseManagerTest.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Database/DatabaseConfig.php b/src/Database/DatabaseConfig.php index b6e9e358..418e4a91 100644 --- a/src/Database/DatabaseConfig.php +++ b/src/Database/DatabaseConfig.php @@ -205,7 +205,9 @@ class DatabaseConfig /** Get the TenantDatabaseManager for this tenant's connection. */ public function hostManager(): Contracts\TenantDatabaseManager { - $this->purgeHostConnection(); + // DB cache the previous connection configurations and changing the connection configuration does not work + // So we purge the previous host connection before changing it + $this->purgeHostConnection(); // todo come up with a better name $tenantHostConnectionName = $this->getTenantHostConnectionName(); config(["database.connections.{$tenantHostConnectionName}" => $this->hostConnection()]); diff --git a/tests/TenantDatabaseManagerTest.php b/tests/TenantDatabaseManagerTest.php index 17af589c..d4e38f13 100644 --- a/tests/TenantDatabaseManagerTest.php +++ b/tests/TenantDatabaseManagerTest.php @@ -100,6 +100,7 @@ test('the tenant connection is fully removed', function () { $tenant = Tenant::create(); + dd(array_keys(app('db')->getConnections())); expect(array_keys(app('db')->getConnections()))->not()->toContain('tenant'); pest()->assertArrayNotHasKey('tenant', config('database.connections'));