@@ -32,7 +32,7 @@ export async function execute(
3232 ) ;
3333 }
3434 let connector : Connector ;
35- let client : pg . Client ;
35+ let pool : pg . Pool ;
3636 switch ( user . type ) {
3737 case "CLOUD_IAM_USER" : {
3838 connector = new Connector ( {
@@ -43,7 +43,7 @@ export async function execute(
4343 ipType : IpAddressTypes . PUBLIC ,
4444 authType : AuthTypes . IAM ,
4545 } ) ;
46- client = new pg . Client ( {
46+ pool = new pg . Pool ( {
4747 ...clientOpts ,
4848 user : opts . username ,
4949 database : opts . databaseId ,
@@ -60,7 +60,7 @@ export async function execute(
6060 ipType : IpAddressTypes . PUBLIC ,
6161 authType : AuthTypes . IAM ,
6262 } ) ;
63- client = new pg . Client ( {
63+ pool = new pg . Pool ( {
6464 ...clientOpts ,
6565 user : opts . username ,
6666 database : opts . databaseId ,
@@ -79,7 +79,7 @@ export async function execute(
7979 instanceConnectionName : connectionName ,
8080 ipType : IpAddressTypes . PUBLIC ,
8181 } ) ;
82- client = new pg . Client ( {
82+ pool = new pg . Pool ( {
8383 ...clientOpts ,
8484 user : opts . username ,
8585 password : opts . password ,
@@ -89,17 +89,19 @@ export async function execute(
8989 }
9090 }
9191
92+ const conn = await pool . connect ( ) ;
9293 logFn ( `Logged in as ${ opts . username } ` ) ;
9394 for ( const s of sqlStatements ) {
9495 logFn ( `Executing: '${ s } '` ) ;
9596 try {
96- await client . query ( s ) ;
97+ await conn . query ( s ) ;
9798 } catch ( err ) {
9899 throw new FirebaseError ( `Error executing ${ err } ` ) ;
99100 }
100101 }
101102
102- await client . end ( ) ;
103+ conn . release ( ) ;
104+ await pool . end ( ) ;
103105 connector . close ( ) ;
104106}
105107
0 commit comments