File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ public function revert(): void
9090 protected function verifyTenantCanUseDatabase (Tenant $ tenant ): void
9191 {
9292 /** @var \Stancl\Tenancy\Database\Models\Tenant&TenantWithDatabase $tenant */
93+
9394 $ tenantDbName = $ tenant ->database ()->getName ();
9495
9596 // Check that no other tenant uses this tenant's database
@@ -99,12 +100,13 @@ protected function verifyTenantCanUseDatabase(Tenant $tenant): void
99100 throw new RuntimeException ('Tenant cannot use a database of another tenant. ' );
100101 }
101102
102- // Check that the current database is not the central database
103103 $ centralDbName = DB ::connection (
104104 config ('tenancy.database.central_connection ' , 'central ' )
105105 )->getDatabaseName ();
106106
107107 if (DB ::getDatabaseName () === $ centralDbName ) {
108+ // Throw if the current database is central.
109+ // DB::getDatabaseName() is the current DB name, which should not be central at this point.
108110 throw new RuntimeException ('Tenant cannot use the central database. ' );
109111 }
110112 }
You can’t perform that action at this time.
0 commit comments