File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -413,7 +413,7 @@ function logToFile(sql, isData) {
413413 }
414414}
415415
416- function createSchema ( runSQL = true , logFile = true ) {
416+ async function createSchema ( runSQL = true , logFile = true ) {
417417 let { sql, sqlData } = sqlSchemaWithData ( ) ;
418418
419419 if ( runSQL ) {
@@ -422,28 +422,19 @@ function createSchema(runSQL = true, logFile = true) {
422422 dbConfig . idleTimeoutMillis = 30000 ; // max client idle time before being closed
423423 const pool = new pg . Pool ( dbConfig ) ;
424424
425+ // - Create schema and tables
425426 if ( logFile ) {
426427 logToFile ( sql , false ) ;
427428 }
428- pool . connect ( function ( err , client , done ) {
429- // - Create schema and tables
430- client . query ( sql , function ( err , data ) {
431- if ( err ) {
432- done ( ) ;
433- throw err ;
434- }
435- // - Populate tables
436- if ( logFile ) {
437- logToFile ( sqlData , true ) ;
438- }
439- client . query ( sqlData , function ( err , data ) {
440- done ( ) ;
441- if ( err ) {
442- throw err ;
443- }
444- } ) ;
445- } ) ;
446- } ) ;
429+ const client = await pool . connect ( ) ;
430+ await client . query ( sql ) ;
431+ // - Populate tables
432+ if ( logFile ) {
433+ logToFile ( sqlData , true ) ;
434+ }
435+ await client . query ( sqlData ) ;
436+ // - close connection
437+ client . release ( true ) ;
447438 }
448439}
449440
You can’t perform that action at this time.
0 commit comments