Skip to content

Commit c784a26

Browse files
committed
Reference the DB_URL env var instead of DATABASE_URL
The env var got renamed in Laravel 11 to `DB_URL`
1 parent f6d7ac1 commit c784a26

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Bootstrappers/DatabaseTenancyBootstrapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public function bootstrap(Tenant $tenant): void
5353
{
5454
/** @var TenantWithDatabase $tenant */
5555
if (data_get($tenant->database()->getTemplateConnection(), 'url')) {
56-
// The package works with individual parts of the database connection config, so DATABASE_URL is not supported.
57-
// When DATABASE_URL is set, this bootstrapper can silently fail i.e. keep using the template connection's database URL
56+
// The package works with individual parts of the database connection config, so DB_URL is not supported.
57+
// When DB_URL is set, this bootstrapper can silently fail i.e. keep using the template connection's database URL
5858
// which takes precedence over individual segments of the connection config. This issue can be hard to debug as it can be
5959
// production-specific. Therefore, we throw an exception (that effectively blocks all tenant pages) to prevent incorrect DB use.
6060
throw new Exception('The template connection must NOT have URL defined. Specify the connection using individual parts instead of a database URL.');

tests/Bootstrappers/DatabaseTenancyBootstrapperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
'hardening disabled' => false,
128128
])->with('db_managers');
129129

130-
test('database tenancy bootstrapper throws an exception if DATABASE_URL is set', function (string|null $databaseUrl) {
130+
test('database tenancy bootstrapper throws an exception if DB_URL is set', function (string|null $databaseUrl) {
131131
config(['tenancy.bootstrappers' => [DatabaseTenancyBootstrapper::class]]);
132132

133133
Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected function getEnvironmentSetUp($app)
131131
'cache.stores.apc' => ['driver' => 'apc'],
132132
'database.connections.central' => [
133133
'driver' => 'mysql',
134-
'url' => env('DATABASE_URL'),
134+
'url' => env('DB_URL'),
135135
'host' => 'mysql',
136136
'port' => env('DB_PORT', '3306'),
137137
'database' => 'main',

0 commit comments

Comments
 (0)