1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-06 02:44:02 +00:00

Queued post-creation automigration

This commit is contained in:
Samuel Štancl 2019-10-03 22:29:02 +02:00
parent 40f8fa346e
commit 071cc6f950
4 changed files with 52 additions and 3 deletions

View file

@ -9,6 +9,7 @@ use Illuminate\Foundation\Application;
use Illuminate\Support\Collection;
use Stancl\Tenancy\Contracts\TenantCannotBeCreatedException;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedException;
use Stancl\Tenancy\Jobs\QueuedTenantDatabaseMigrator;
/**
* @internal Class is subject to breaking changes in minor and patch versions.
@ -64,9 +65,13 @@ class TenantManager
$this->database->createDatabase($tenant);
if ($this->shouldMigrateAfterCreation()) {
$this->artisan->call('tenants:migrate', [
'--tenants' => [$tenant['id']],
]);
if ($this->shouldQueueMigration()) {
QueuedTenantDatabaseMigrator::dispatch($tenant);
} else {
$this->artisan->call('tenants:migrate', [
'--tenants' => [$tenant['id']],
]);
}
}
return $this;