mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 17:54:03 +00:00
Use only one config for queueing
This commit is contained in:
parent
74fbd816c2
commit
cc5611b24d
4 changed files with 28 additions and 27 deletions
|
|
@ -126,14 +126,14 @@ class DatabaseManager
|
|||
* Create a database for a tenant.
|
||||
*
|
||||
* @param Tenant $tenant
|
||||
* @param ShouldQueue[]|callable[] $afterCreating
|
||||
* @param \Illuminate\Contracts\Queue\ShouldQueue[]|callable[] $afterCreating
|
||||
* @return void
|
||||
*/
|
||||
public function createDatabase(Tenant $tenant, array $afterCreating = [])
|
||||
{
|
||||
$database = $tenant->getDatabaseName();
|
||||
$manager = $this->getTenantDatabaseManager($tenant);
|
||||
|
||||
|
||||
if ($this->app['config']['tenancy.queue_database_creation'] ?? false) {
|
||||
QueuedTenantDatabaseCreator::withChain($afterCreating)->dispatch($manager, $database);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -63,21 +63,19 @@ class TenantManager
|
|||
|
||||
$this->storage->createTenant($tenant);
|
||||
|
||||
/** @var \Illuminate\Contracts\Queue\ShouldQueue[]|callable[] $afterCreating */
|
||||
$afterCreating = [];
|
||||
|
||||
if ($this->shouldMigrateAfterCreation()) {
|
||||
if ($this->shouldQueueMigration()) {
|
||||
$afterCreating = [
|
||||
new QueuedTenantDatabaseMigrator($tenant),
|
||||
];
|
||||
} else {
|
||||
$afterCreating = [
|
||||
function () use ($tenant) {
|
||||
$this->artisan->call('tenants:migrate', [
|
||||
'--tenants' => [$tenant['id']],
|
||||
]);
|
||||
},
|
||||
];
|
||||
}
|
||||
$afterCreating += $this->databaseCreationQueued() ? [
|
||||
new QueuedTenantDatabaseMigrator($tenant),
|
||||
] : [
|
||||
function () use ($tenant) {
|
||||
$this->artisan->call('tenants:migrate', [
|
||||
'--tenants' => [$tenant['id']],
|
||||
]);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
$this->database->createDatabase($tenant, $afterCreating);
|
||||
|
|
@ -323,9 +321,9 @@ class TenantManager
|
|||
return $this->app['config']['tenancy.migrate_after_creation'] ?? false;
|
||||
}
|
||||
|
||||
public function shouldQueueMigration(): bool
|
||||
public function databaseCreationQueued(): bool
|
||||
{
|
||||
return $this->app['config']['tenancy.queue_automatic_migration'] ?? false;
|
||||
return $this->app['config']['tenancy.queue_database_creation'] ?? false;
|
||||
}
|
||||
|
||||
public function shouldDeleteDatabase(): bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue