Skip to content

Commit

Permalink
Merge pull request #84 from shawnhooper/customize-db-name
Browse files Browse the repository at this point in the history
Override database name w/ FORGE_DB_NAME environment variable
  • Loading branch information
mehrancodes authored Mar 16, 2024
2 parents 69d62d4 + 96afd7a commit 77ac83a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/Services/Forge/ForgeSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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'],
Expand Down
2 changes: 1 addition & 1 deletion app/Services/Forge/Pipeline/CreateDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
3 changes: 3 additions & 0 deletions config/forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down

0 comments on commit 77ac83a

Please sign in to comment.