mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 23:54:04 +00:00
Added support for migration parameters (#243)
This commit is contained in:
parent
609b6f12cf
commit
5145b1f13e
3 changed files with 17 additions and 4 deletions
|
|
@ -19,9 +19,13 @@ class QueuedTenantDatabaseMigrator implements ShouldQueue
|
|||
/** @var string */
|
||||
protected $tenantId;
|
||||
|
||||
public function __construct(Tenant $tenant)
|
||||
/** @var array */
|
||||
protected $migrationParameters = [];
|
||||
|
||||
public function __construct(Tenant $tenant, $migrationParameters = [])
|
||||
{
|
||||
$this->tenantId = $tenant->id;
|
||||
$this->migrationParameters = $migrationParameters;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -33,6 +37,6 @@ class QueuedTenantDatabaseMigrator implements ShouldQueue
|
|||
{
|
||||
Artisan::call('tenants:migrate', [
|
||||
'--tenants' => [$this->tenantId],
|
||||
]);
|
||||
] + $this->migrationParameters);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ class TenantManager
|
|||
|
||||
if ($this->shouldMigrateAfterCreation()) {
|
||||
$afterCreating[] = $this->databaseCreationQueued()
|
||||
? new QueuedTenantDatabaseMigrator($tenant)
|
||||
? new QueuedTenantDatabaseMigrator($tenant, $this->getMigrationParameters())
|
||||
: function () use ($tenant) {
|
||||
$this->artisan->call('tenants:migrate', [
|
||||
'--tenants' => [$tenant['id']],
|
||||
]);
|
||||
] + $this->getMigrationParameters());
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -401,6 +401,11 @@ class TenantManager
|
|||
return $this->app['config']['tenancy.seeder_parameters'] ?? [];
|
||||
}
|
||||
|
||||
public function getMigrationParameters()
|
||||
{
|
||||
return $this->app['config']['tenancy.migration_parameters'] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an event listener.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue