File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,11 +13,16 @@ function Set-PgSqlTestEnvironment {
1313 $env: PGPASSWORD = ' Password12!'
1414
1515 if (-not (Test-Path pgsql_init)) {
16- Set -Service - Name " postgresql-x64-14 " - StartupType manual - WarningAction SilentlyContinue - ErrorAction SilentlyContinue
17- Start-Service - Name " postgresql-x64-14 " - WarningAction SilentlyContinue - ErrorAction SilentlyContinue
18- $service = Get-Service - Name " postgresql-x64-14 " - ErrorAction SilentlyContinue
16+ $service = Get -Service - Name " postgresql-x64-* " - ErrorAction SilentlyContinue |
17+ Sort-Object - Property @ { Expression = { if ( $_ . Name -match ' ^ postgresql-x64-(\d+)$ ' ) { [ int ] $Matches [ 1 ] } else { 0 } } } - Descending |
18+ Select-Object - First 1
1919 if ($service ) {
20+ Write-Host " Using PostgreSQL service $ ( $service.Name ) ."
21+ Set-Service - Name $service.Name - StartupType manual - WarningAction SilentlyContinue - ErrorAction SilentlyContinue
22+ Start-Service - Name $service.Name - WarningAction SilentlyContinue - ErrorAction SilentlyContinue
2023 $service.WaitForStatus (' Running' , [TimeSpan ]::FromSeconds(60 ))
24+ } else {
25+ Write-Warning " No PostgreSQL service matching postgresql-x64-* was found."
2126 }
2227 Set-Content - Path pgsql_init - Value " initialized" - Encoding ASCII
2328 }
You can’t perform that action at this time.
0 commit comments