From c784a26ceea6076cce4279fd32f3f3a3b3513c80 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Tue, 30 Jun 2026 06:18:01 +0200 Subject: [PATCH] Reference the `DB_URL` env var instead of `DATABASE_URL` The env var got renamed in Laravel 11 to `DB_URL` --- src/Bootstrappers/DatabaseTenancyBootstrapper.php | 4 ++-- tests/Bootstrappers/DatabaseTenancyBootstrapperTest.php | 2 +- tests/TestCase.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bootstrappers/DatabaseTenancyBootstrapper.php b/src/Bootstrappers/DatabaseTenancyBootstrapper.php index 08b36f1d..175d8b56 100644 --- a/src/Bootstrappers/DatabaseTenancyBootstrapper.php +++ b/src/Bootstrappers/DatabaseTenancyBootstrapper.php @@ -53,8 +53,8 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper { /** @var TenantWithDatabase $tenant */ if (data_get($tenant->database()->getTemplateConnection(), 'url')) { - // The package works with individual parts of the database connection config, so DATABASE_URL is not supported. - // When DATABASE_URL is set, this bootstrapper can silently fail i.e. keep using the template connection's database URL + // The package works with individual parts of the database connection config, so DB_URL is not supported. + // When DB_URL is set, this bootstrapper can silently fail i.e. keep using the template connection's database URL // which takes precedence over individual segments of the connection config. This issue can be hard to debug as it can be // production-specific. Therefore, we throw an exception (that effectively blocks all tenant pages) to prevent incorrect DB use. throw new Exception('The template connection must NOT have URL defined. Specify the connection using individual parts instead of a database URL.'); diff --git a/tests/Bootstrappers/DatabaseTenancyBootstrapperTest.php b/tests/Bootstrappers/DatabaseTenancyBootstrapperTest.php index ca292933..c970accc 100644 --- a/tests/Bootstrappers/DatabaseTenancyBootstrapperTest.php +++ b/tests/Bootstrappers/DatabaseTenancyBootstrapperTest.php @@ -127,7 +127,7 @@ test('harden prevents tenants from using the database of another tenant', functi 'hardening disabled' => false, ])->with('db_managers'); -test('database tenancy bootstrapper throws an exception if DATABASE_URL is set', function (string|null $databaseUrl) { +test('database tenancy bootstrapper throws an exception if DB_URL is set', function (string|null $databaseUrl) { config(['tenancy.bootstrappers' => [DatabaseTenancyBootstrapper::class]]); Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) { diff --git a/tests/TestCase.php b/tests/TestCase.php index cbc6f57e..eb58a0d9 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -131,7 +131,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase 'cache.stores.apc' => ['driver' => 'apc'], 'database.connections.central' => [ 'driver' => 'mysql', - 'url' => env('DATABASE_URL'), + 'url' => env('DB_URL'), 'host' => 'mysql', 'port' => env('DB_PORT', '3306'), 'database' => 'main',