@@ -181,28 +181,30 @@ export const HETERO_PINNED_ICU_COLLATION = "und-x-icu";
181181// PG17 worker singleton mirroring getWorkerPostgresContainer. PG17 supports the ICU cluster locale
182182// provider (PG14 does not - it arrived in PG15), so only this side sets the cluster locale; the real
183183// cross-version guarantee is the per-column COLLATE in the proof test.
184+ async function bootstrapPg17TemplateContainer (
185+ pushSchema : ( databaseUrl : string ) => Promise < unknown >
186+ ) : Promise < StartedPostgreSqlContainer > {
187+ const container = await withCiResourceLimits ( new PostgreSqlContainer ( "docker.io/postgres:17" ) )
188+ . withCommand ( [ "-c" , "listen_addresses=*" , "-c" , "wal_level=logical" ] )
189+ . withEnvironment ( {
190+ POSTGRES_INITDB_ARGS : "--locale-provider=icu --icu-locale=en-US --encoding=UTF8" ,
191+ } )
192+ . start ( ) ;
193+ const admin = new PrismaClient ( {
194+ datasources : {
195+ db : { url : postgresUriWithDatabase ( container . getConnectionUri ( ) , "postgres" ) } ,
196+ } ,
197+ } ) ;
198+ await admin . $executeRawUnsafe ( `CREATE DATABASE "${ POSTGRES_TEMPLATE_DB } "` ) ;
199+ await admin . $disconnect ( ) ;
200+ await pushSchema ( postgresUriWithDatabase ( container . getConnectionUri ( ) , POSTGRES_TEMPLATE_DB ) ) ;
201+ return container ;
202+ }
203+
184204let workerPostgresContainer17 : Promise < StartedPostgreSqlContainer > | undefined ;
185205const getWorkerPostgresContainer17 = ( ) => {
186206 if ( ! workerPostgresContainer17 ) {
187- workerPostgresContainer17 = ( async ( ) => {
188- const container = await withCiResourceLimits ( new PostgreSqlContainer ( "docker.io/postgres:17" ) )
189- . withCommand ( [ "-c" , "listen_addresses=*" , "-c" , "wal_level=logical" ] )
190- . withEnvironment ( {
191- POSTGRES_INITDB_ARGS : "--locale-provider=icu --icu-locale=en-US --encoding=UTF8" ,
192- } )
193- . start ( ) ;
194- const admin = new PrismaClient ( {
195- datasources : {
196- db : { url : postgresUriWithDatabase ( container . getConnectionUri ( ) , "postgres" ) } ,
197- } ,
198- } ) ;
199- await admin . $executeRawUnsafe ( `CREATE DATABASE "${ POSTGRES_TEMPLATE_DB } "` ) ;
200- await admin . $disconnect ( ) ;
201- await pushDatabaseSchema (
202- postgresUriWithDatabase ( container . getConnectionUri ( ) , POSTGRES_TEMPLATE_DB )
203- ) ;
204- return container ;
205- } ) ( ) ;
207+ workerPostgresContainer17 = bootstrapPg17TemplateContainer ( pushDatabaseSchema ) ;
206208 }
207209 return workerPostgresContainer17 ;
208210} ;
@@ -214,25 +216,7 @@ const getWorkerPostgresContainer17 = () => {
214216let runOpsWorkerPostgresContainer17 : Promise < StartedPostgreSqlContainer > | undefined ;
215217const getRunOpsWorkerPostgresContainer17 = ( ) => {
216218 if ( ! runOpsWorkerPostgresContainer17 ) {
217- runOpsWorkerPostgresContainer17 = ( async ( ) => {
218- const container = await withCiResourceLimits ( new PostgreSqlContainer ( "docker.io/postgres:17" ) )
219- . withCommand ( [ "-c" , "listen_addresses=*" , "-c" , "wal_level=logical" ] )
220- . withEnvironment ( {
221- POSTGRES_INITDB_ARGS : "--locale-provider=icu --icu-locale=en-US --encoding=UTF8" ,
222- } )
223- . start ( ) ;
224- const admin = new PrismaClient ( {
225- datasources : {
226- db : { url : postgresUriWithDatabase ( container . getConnectionUri ( ) , "postgres" ) } ,
227- } ,
228- } ) ;
229- await admin . $executeRawUnsafe ( `CREATE DATABASE "${ POSTGRES_TEMPLATE_DB } "` ) ;
230- await admin . $disconnect ( ) ;
231- await pushRunOpsSchema (
232- postgresUriWithDatabase ( container . getConnectionUri ( ) , POSTGRES_TEMPLATE_DB )
233- ) ;
234- return container ;
235- } ) ( ) ;
219+ runOpsWorkerPostgresContainer17 = bootstrapPg17TemplateContainer ( pushRunOpsSchema ) ;
236220 }
237221 return runOpsWorkerPostgresContainer17 ;
238222} ;
0 commit comments