diff --git a/app/Services/Forge/ForgeSetting.php b/app/Services/Forge/ForgeSetting.php index ec3ffbe..12b22f4 100644 --- a/app/Services/Forge/ForgeSetting.php +++ b/app/Services/Forge/ForgeSetting.php @@ -117,6 +117,11 @@ class ForgeSetting */ public bool $dbCreationRequired; + /** + * The name of the database to be created + */ + public ?string $dbName; + /** * Flag to auto-source environment variables in deployment. */ @@ -196,6 +201,7 @@ class ForgeSetting 'site_isolation_required' => ['boolean'], 'job_scheduler_required' => ['boolean'], 'db_creation_required' => ['boolean'], + 'db_name' => ['nullable', 'string'], 'auto_source_required' => ['boolean'], 'ssl_required' => ['boolean'], 'wait_on_ssl' => ['boolean'], diff --git a/app/Services/Forge/Pipeline/CreateDatabase.php b/app/Services/Forge/Pipeline/CreateDatabase.php index 917c024..85598b2 100644 --- a/app/Services/Forge/Pipeline/CreateDatabase.php +++ b/app/Services/Forge/Pipeline/CreateDatabase.php @@ -29,7 +29,7 @@ public function __invoke(ForgeService $service, Closure $next) } $dbPassword = Str::random(16); - $dbName = $service->getStandardizedBranchName(); + $dbName = $service->setting->dbName ?? $service->getStandardizedBranchName(); if (! $this->databaseExists($service, $dbName)) { $this->information('Creating database.'); diff --git a/config/forge.php b/config/forge.php index d423588..cb97ae2 100644 --- a/config/forge.php +++ b/config/forge.php @@ -55,6 +55,9 @@ // Flag to enable Quick Deploy (default: true). 'quick_deploy' => env('FORGE_QUICK_DEPLOY', false), + // Override default database and database username, if needed. Defaults to the site name. + 'db_name' => env('FORGE_DB_NAME', null), + // Flag to enable SSL certification (default: false). 'ssl_required' => env('FORGE_SSL_REQUIRED', false),