mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 19:54:04 +00:00
parallel commands: core # autodetect, bugfixes, improved output
This commit is contained in:
parent
b4a055315b
commit
39bcbda5d0
6 changed files with 138 additions and 19 deletions
|
|
@ -38,7 +38,7 @@ class MigrateFresh extends BaseCommand
|
|||
|
||||
if ($this->getProcesses() > 1) {
|
||||
return $this->runConcurrently($this->getTenantChunks()->map(function ($chunk) {
|
||||
return $this->getTenants($chunk->all());
|
||||
return $this->getTenants($chunk);
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
@ -81,6 +81,8 @@ class MigrateFresh extends BaseCommand
|
|||
}
|
||||
|
||||
/**
|
||||
* Only used when running concurrently.
|
||||
*
|
||||
* @param LazyCollection<covariant int|string, \Stancl\Tenancy\Contracts\Tenant&\Illuminate\Database\Eloquent\Model> $tenants
|
||||
*/
|
||||
protected function migrateFreshTenants(LazyCollection $tenants): bool
|
||||
|
|
@ -89,6 +91,8 @@ class MigrateFresh extends BaseCommand
|
|||
|
||||
foreach ($tenants as $tenant) {
|
||||
try {
|
||||
$this->components->info("Migrating (fresh) tenant {$tenant->getTenantKey()}");
|
||||
|
||||
$tenant->run(function ($tenant) use (&$success) {
|
||||
$this->components->info("Wiping database of tenant {$tenant->getTenantKey()}", OI::VERBOSITY_VERY_VERBOSE);
|
||||
if ($this->wipeDB()) {
|
||||
|
|
@ -105,6 +109,8 @@ class MigrateFresh extends BaseCommand
|
|||
$success = false;
|
||||
$this->components->error("Migrating database of tenant {$tenant->getTenantKey()} failed!");
|
||||
}
|
||||
|
||||
$this->components->success("Migrated (fresh) tenant {$tenant->getTenantKey()}");
|
||||
});
|
||||
} catch (TenantDatabaseDoesNotExistException|QueryException $e) {
|
||||
$this->components->error("Migration failed for tenant {$tenant->getTenantKey()}: {$e->getMessage()}");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue