| 58 | |
| 59 | // Method to connect locally on Windows |
| 60 | const connectWithTcp = credConfig => { |
| 61 | // Extract host and port from socket address |
| 62 | const dbSocketAddr = process.env.DB_HOST.split(':'); // e.g. '127.0.0.1:5432' |
| 63 | // Establish a connection to the database |
| 64 | return Knex({ |
| 65 | client: 'pg', |
| 66 | connection: { |
| 67 | user: credConfig.DB_USER, // e.g. 'my-user' |
| 68 | password: credConfig.DB_PASSWORD, // e.g. 'my-user-password' |
| 69 | database: credConfig.DB_NAME, // e.g. 'my-database' |
| 70 | host: dbSocketAddr[0], // e.g. '127.0.0.1' |
| 71 | port: dbSocketAddr[1], // e.g. '5432' |
| 72 | }, |
| 73 | ...config, |
| 74 | }); |
| 75 | }; |
| 76 | |
| 77 | /** |
| 78 | * Connect to the Cloud SQL instance through TCP or UNIX Sockets |