Skip to content

Commit 77ac83a

Browse files
authored
Merge pull request #84 from shawnhooper/customize-db-name
Override database name w/ FORGE_DB_NAME environment variable
2 parents 69d62d4 + 96afd7a commit 77ac83a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

app/Services/Forge/ForgeSetting.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class ForgeSetting
117117
*/
118118
public bool $dbCreationRequired;
119119

120+
/**
121+
* The name of the database to be created
122+
*/
123+
public ?string $dbName;
124+
120125
/**
121126
* Flag to auto-source environment variables in deployment.
122127
*/
@@ -196,6 +201,7 @@ class ForgeSetting
196201
'site_isolation_required' => ['boolean'],
197202
'job_scheduler_required' => ['boolean'],
198203
'db_creation_required' => ['boolean'],
204+
'db_name' => ['nullable', 'string'],
199205
'auto_source_required' => ['boolean'],
200206
'ssl_required' => ['boolean'],
201207
'wait_on_ssl' => ['boolean'],

app/Services/Forge/Pipeline/CreateDatabase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __invoke(ForgeService $service, Closure $next)
2929
}
3030

3131
$dbPassword = Str::random(16);
32-
$dbName = $service->getStandardizedBranchName();
32+
$dbName = $service->setting->dbName ?? $service->getStandardizedBranchName();
3333

3434
if (! $this->databaseExists($service, $dbName)) {
3535
$this->information('Creating database.');

config/forge.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
// Flag to enable Quick Deploy (default: true).
5656
'quick_deploy' => env('FORGE_QUICK_DEPLOY', false),
5757

58+
// Override default database and database username, if needed. Defaults to the site name.
59+
'db_name' => env('FORGE_DB_NAME', null),
60+
5861
// Flag to enable SSL certification (default: false).
5962
'ssl_required' => env('FORGE_SSL_REQUIRED', false),
6063

0 commit comments

Comments
 (0)