@@ -176,28 +176,30 @@ export const HETERO_PINNED_ICU_COLLATION = "und-x-icu";
176176// PG17 worker singleton mirroring getWorkerPostgresContainer. PG17 supports the ICU cluster locale
177177// provider (PG14 does not - it arrived in PG15), so only this side sets the cluster locale; the real
178178// cross-version guarantee is the per-column COLLATE in the proof test.
179+ async function bootstrapPg17TemplateContainer (
180+ pushSchema : ( databaseUrl : string ) => Promise < unknown >
181+ ) : Promise < StartedPostgreSqlContainer > {
182+ const container = await withCiResourceLimits ( new PostgreSqlContainer ( "docker.io/postgres:17" ) )
183+ . withCommand ( [ "-c" , "listen_addresses=*" , "-c" , "wal_level=logical" ] )
184+ . withEnvironment ( {
185+ POSTGRES_INITDB_ARGS : "--locale-provider=icu --icu-locale=en-US --encoding=UTF8" ,
186+ } )
187+ . start ( ) ;
188+ const admin = new PrismaClient ( {
189+ datasources : {
190+ db : { url : postgresUriWithDatabase ( container . getConnectionUri ( ) , "postgres" ) } ,
191+ } ,
192+ } ) ;
193+ await admin . $executeRawUnsafe ( `CREATE DATABASE "${ POSTGRES_TEMPLATE_DB } "` ) ;
194+ await admin . $disconnect ( ) ;
195+ await pushSchema ( postgresUriWithDatabase ( container . getConnectionUri ( ) , POSTGRES_TEMPLATE_DB ) ) ;
196+ return container ;
197+ }
198+
179199let workerPostgresContainer17 : Promise < StartedPostgreSqlContainer > | undefined ;
180200const getWorkerPostgresContainer17 = ( ) => {
181201 if ( ! workerPostgresContainer17 ) {
182- workerPostgresContainer17 = ( async ( ) => {
183- const container = await withCiResourceLimits ( new PostgreSqlContainer ( "docker.io/postgres:17" ) )
184- . withCommand ( [ "-c" , "listen_addresses=*" , "-c" , "wal_level=logical" ] )
185- . withEnvironment ( {
186- POSTGRES_INITDB_ARGS : "--locale-provider=icu --icu-locale=en-US --encoding=UTF8" ,
187- } )
188- . start ( ) ;
189- const admin = new PrismaClient ( {
190- datasources : {
191- db : { url : postgresUriWithDatabase ( container . getConnectionUri ( ) , "postgres" ) } ,
192- } ,
193- } ) ;
194- await admin . $executeRawUnsafe ( `CREATE DATABASE "${ POSTGRES_TEMPLATE_DB } "` ) ;
195- await admin . $disconnect ( ) ;
196- await pushDatabaseSchema (
197- postgresUriWithDatabase ( container . getConnectionUri ( ) , POSTGRES_TEMPLATE_DB )
198- ) ;
199- return container ;
200- } ) ( ) ;
202+ workerPostgresContainer17 = bootstrapPg17TemplateContainer ( pushDatabaseSchema ) ;
201203 }
202204 return workerPostgresContainer17 ;
203205} ;
@@ -209,25 +211,7 @@ const getWorkerPostgresContainer17 = () => {
209211let runOpsWorkerPostgresContainer17 : Promise < StartedPostgreSqlContainer > | undefined ;
210212const getRunOpsWorkerPostgresContainer17 = ( ) => {
211213 if ( ! runOpsWorkerPostgresContainer17 ) {
212- runOpsWorkerPostgresContainer17 = ( async ( ) => {
213- const container = await withCiResourceLimits ( new PostgreSqlContainer ( "docker.io/postgres:17" ) )
214- . withCommand ( [ "-c" , "listen_addresses=*" , "-c" , "wal_level=logical" ] )
215- . withEnvironment ( {
216- POSTGRES_INITDB_ARGS : "--locale-provider=icu --icu-locale=en-US --encoding=UTF8" ,
217- } )
218- . start ( ) ;
219- const admin = new PrismaClient ( {
220- datasources : {
221- db : { url : postgresUriWithDatabase ( container . getConnectionUri ( ) , "postgres" ) } ,
222- } ,
223- } ) ;
224- await admin . $executeRawUnsafe ( `CREATE DATABASE "${ POSTGRES_TEMPLATE_DB } "` ) ;
225- await admin . $disconnect ( ) ;
226- await pushRunOpsSchema (
227- postgresUriWithDatabase ( container . getConnectionUri ( ) , POSTGRES_TEMPLATE_DB )
228- ) ;
229- return container ;
230- } ) ( ) ;
214+ runOpsWorkerPostgresContainer17 = bootstrapPg17TemplateContainer ( pushRunOpsSchema ) ;
231215 }
232216 return runOpsWorkerPostgresContainer17 ;
233217} ;
0 commit comments