mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:24:03 +00:00
remove version checks
This commit is contained in:
parent
121370ea01
commit
fa09e3a083
3 changed files with 7 additions and 12 deletions
|
|
@ -62,14 +62,11 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
|
||||||
static::initializeTenancyForQueue($event->job->payload()['tenant_id'] ?? null);
|
static::initializeTenancyForQueue($event->job->payload()['tenant_id'] ?? null);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (version_compare(app()->version(), '8.64', '>=')) {
|
$dispatcher->listen(JobRetryRequested::class, function ($event) use (&$previousTenant) {
|
||||||
// JobRetryRequested only exists since Laravel 8.64
|
$previousTenant = tenant();
|
||||||
$dispatcher->listen(JobRetryRequested::class, function ($event) use (&$previousTenant) {
|
|
||||||
$previousTenant = tenant();
|
|
||||||
|
|
||||||
static::initializeTenancyForQueue($event->payload()['tenant_id'] ?? null);
|
static::initializeTenancyForQueue($event->payload()['tenant_id'] ?? null);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// If we're running tests, we make sure to clean up after any artisan('queue:work') calls
|
// If we're running tests, we make sure to clean up after any artisan('queue:work') calls
|
||||||
$revertToPreviousState = function ($event) use (&$previousTenant, $runningTests) {
|
$revertToPreviousState = function ($event) use (&$previousTenant, $runningTests) {
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ test('batch repository is set to tenant connection and reverted', function () {
|
||||||
|
|
||||||
tenancy()->end();
|
tenancy()->end();
|
||||||
expect(getBatchRepositoryConnectionName())->toBe('central');
|
expect(getBatchRepositoryConnectionName())->toBe('central');
|
||||||
})->skip(fn() => version_compare(app()->version(), '8.0', '<'), 'Job batches are only supported in Laravel 8+');
|
});
|
||||||
|
|
||||||
function getBatchRepositoryConnectionName()
|
function getBatchRepositoryConnectionName()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -154,9 +154,7 @@ test('schema manager uses schema to separate tenant dbs', function () {
|
||||||
]);
|
]);
|
||||||
tenancy()->initialize($tenant);
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
$schemaConfig = version_compare(app()->version(), '9.0', '>=') ?
|
$schemaConfig = config('database.connections.' . config('database.default') . '.search_path');
|
||||||
config('database.connections.' . config('database.default') . '.search_path') :
|
|
||||||
config('database.connections.' . config('database.default') . '.schema');
|
|
||||||
|
|
||||||
expect($schemaConfig)->toBe($tenant->database()->getName());
|
expect($schemaConfig)->toBe($tenant->database()->getName());
|
||||||
expect(config(['database.connections.pgsql.database']))->toBe($originalDatabaseName);
|
expect(config(['database.connections.pgsql.database']))->toBe($originalDatabaseName);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue