feat: Able to select different postgres database

This commit is contained in:
Andras Bacsai
2024-08-16 15:33:55 +02:00
parent f106e6e37b
commit d2eaf4f2e3
4 changed files with 115 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ function generate_database_name(string $type): string
return $type.'-database-'.$cuid;
}
function create_standalone_postgresql($environmentId, $destinationUuid, ?array $otherData = null): StandalonePostgresql
function create_standalone_postgresql($environmentId, $destinationUuid, ?array $otherData = null, string $databaseImage = 'postgres:16-alpine'): StandalonePostgresql
{
$destination = StandaloneDocker::where('uuid', $destinationUuid)->first();
if (! $destination) {
@@ -27,6 +27,7 @@ function create_standalone_postgresql($environmentId, $destinationUuid, ?array $
}
$database = new StandalonePostgresql;
$database->name = generate_database_name('postgresql');
$database->image = $databaseImage;
$database->postgres_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
$database->environment_id = $environmentId;
$database->destination_id = $destination->id;