1
0
Fork 0
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:
Samuel Štancl 2019-08-17 15:25:39 +02:00
parent 824d299dcd
commit be077ae73c
3 changed files with 25 additions and 14 deletions

View file

@ -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();