mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 14:14:04 +00:00
[4.x] Use --database in tenants:migrate as the template connection (#1386)
* Make the `--database` option passed to `tenants:migrate` use the passed connection as the tenant connection template * Reset template connection regardless of process count --------- Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
parent
d9f3525700
commit
3b42c9e20c
2 changed files with 71 additions and 5 deletions
|
|
@ -51,13 +51,24 @@ class Migrate extends MigrateCommand
|
|||
return 1;
|
||||
}
|
||||
|
||||
if ($this->getProcesses() > 1) {
|
||||
return $this->runConcurrently($this->getTenantChunks()->map(function ($chunk) {
|
||||
return $this->getTenants($chunk);
|
||||
}));
|
||||
$originalTemplateConnection = config('tenancy.database.template_tenant_connection');
|
||||
|
||||
if ($database = $this->input->getOption('database')) {
|
||||
config(['tenancy.database.template_tenant_connection' => $database]);
|
||||
}
|
||||
|
||||
return $this->migrateTenants($this->getTenants()) ? 0 : 1;
|
||||
if ($this->getProcesses() > 1) {
|
||||
$code = $this->runConcurrently($this->getTenantChunks()->map(function ($chunk) {
|
||||
return $this->getTenants($chunk);
|
||||
}));
|
||||
} else {
|
||||
$code = $this->migrateTenants($this->getTenants()) ? 0 : 1;
|
||||
}
|
||||
|
||||
// Reset the template tenant connection to the original one
|
||||
config(['tenancy.database.template_tenant_connection' => $originalTemplateConnection]);
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
protected function childHandle(mixed ...$args): bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue