mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 21:54:03 +00:00
[2.1.0] Fix queue race conditions (#178)
* Add TenantDoesNotExist exception, fix queued migrator serialization * wip * Apply fixes from StyleCI * Use only one config for queueing * Apply fixes from StyleCI * rename test * rename test
This commit is contained in:
parent
e98db460ec
commit
3e78410d8a
8 changed files with 78 additions and 28 deletions
|
|
@ -126,17 +126,21 @@ class DatabaseManager
|
|||
* Create a database for a tenant.
|
||||
*
|
||||
* @param Tenant $tenant
|
||||
* @param \Illuminate\Contracts\Queue\ShouldQueue[]|callable[] $afterCreating
|
||||
* @return void
|
||||
*/
|
||||
public function createDatabase(Tenant $tenant)
|
||||
public function createDatabase(Tenant $tenant, array $afterCreating = [])
|
||||
{
|
||||
$database = $tenant->getDatabaseName();
|
||||
$manager = $this->getTenantDatabaseManager($tenant);
|
||||
|
||||
if ($this->app['config']['tenancy.queue_database_creation'] ?? false) {
|
||||
QueuedTenantDatabaseCreator::dispatch($manager, $database);
|
||||
QueuedTenantDatabaseCreator::withChain($afterCreating)->dispatch($manager, $database);
|
||||
} else {
|
||||
$manager->createDatabase($database);
|
||||
foreach ($afterCreating as $callback) {
|
||||
$callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue