mirror of
https://github.com/archtechx/tenancy.git
synced 2026-08-06 06:54:03 +00:00
Reference the DB_URL env var instead of DATABASE_URL
The env var got renamed in Laravel 11 to `DB_URL`
This commit is contained in:
parent
f6d7ac13db
commit
c784a26cee
3 changed files with 4 additions and 4 deletions
|
|
@ -53,8 +53,8 @@ class DatabaseTenancyBootstrapper implements TenancyBootstrapper
|
||||||
{
|
{
|
||||||
/** @var TenantWithDatabase $tenant */
|
/** @var TenantWithDatabase $tenant */
|
||||||
if (data_get($tenant->database()->getTemplateConnection(), 'url')) {
|
if (data_get($tenant->database()->getTemplateConnection(), 'url')) {
|
||||||
// The package works with individual parts of the database connection config, so DATABASE_URL is not supported.
|
// The package works with individual parts of the database connection config, so DB_URL is not supported.
|
||||||
// When DATABASE_URL is set, this bootstrapper can silently fail i.e. keep using the template connection's database URL
|
// 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
|
// 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.
|
// 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.');
|
throw new Exception('The template connection must NOT have URL defined. Specify the connection using individual parts instead of a database URL.');
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ test('harden prevents tenants from using the database of another tenant', functi
|
||||||
'hardening disabled' => false,
|
'hardening disabled' => false,
|
||||||
])->with('db_managers');
|
])->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]]);
|
config(['tenancy.bootstrappers' => [DatabaseTenancyBootstrapper::class]]);
|
||||||
|
|
||||||
Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {
|
Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
'cache.stores.apc' => ['driver' => 'apc'],
|
'cache.stores.apc' => ['driver' => 'apc'],
|
||||||
'database.connections.central' => [
|
'database.connections.central' => [
|
||||||
'driver' => 'mysql',
|
'driver' => 'mysql',
|
||||||
'url' => env('DATABASE_URL'),
|
'url' => env('DB_URL'),
|
||||||
'host' => 'mysql',
|
'host' => 'mysql',
|
||||||
'port' => env('DB_PORT', '3306'),
|
'port' => env('DB_PORT', '3306'),
|
||||||
'database' => 'main',
|
'database' => 'main',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue