mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 18:04:03 +00:00
Make DB creation optional (#299)
This commit is contained in:
parent
5bb743f73d
commit
98ce0ee294
3 changed files with 47 additions and 1 deletions
|
|
@ -98,7 +98,9 @@ class TenantManager
|
|||
};
|
||||
}
|
||||
|
||||
$this->database->createDatabase($tenant, $afterCreating);
|
||||
if ($this->shouldCreateDatabase($tenant)) {
|
||||
$this->database->createDatabase($tenant, $afterCreating);
|
||||
}
|
||||
|
||||
$this->event('tenant.created', $tenant);
|
||||
|
||||
|
|
@ -378,6 +380,15 @@ class TenantManager
|
|||
return array_diff_key($this->app['config']['tenancy.bootstrappers'], array_flip($except));
|
||||
}
|
||||
|
||||
public function shouldCreateDatabase(Tenant $tenant): bool
|
||||
{
|
||||
if (array_key_exists('_tenancy_create_database', $tenant->data)) {
|
||||
return $tenant->data['_tenancy_create_database'];
|
||||
}
|
||||
|
||||
return $this->app['config']['tenancy.create_database'] ?? true;
|
||||
}
|
||||
|
||||
public function shouldMigrateAfterCreation(): bool
|
||||
{
|
||||
return $this->app['config']['tenancy.migrate_after_creation'] ?? false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue