mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-13 07:14:04 +00:00
Add the option to specify connection in DatabaseManager
This commit is contained in:
parent
824d299dcd
commit
be077ae73c
3 changed files with 25 additions and 14 deletions
|
|
@ -47,11 +47,14 @@ class Migrate extends MigrateCommand
|
|||
return;
|
||||
}
|
||||
|
||||
$this->input->setOption('database', 'tenant');
|
||||
|
||||
tenant()->all($this->option('tenants'))->each(function ($tenant) {
|
||||
$this->line("Tenant: {$tenant['uuid']} ({$tenant['domain']})");
|
||||
$this->database->connectToTenant($tenant);
|
||||
|
||||
// See Illuminate\Database\Migrations\DatabaseMigrationRepository::getConnection.
|
||||
// Database connections are cached by Illuminate\Database\ConnectionResolver.
|
||||
$connectionName = "tenant{$tenant['uuid']}";
|
||||
$this->input->setOption('database', $connectionName);
|
||||
$this->database->connectToTenant($tenant, $connectionName);
|
||||
|
||||
// Migrate
|
||||
parent::handle();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue