Skip to content

Commit

Permalink
Merge pull request #29 from sombriks/develop
Browse files Browse the repository at this point in the history
fix connection pool issue
  • Loading branch information
sombriks committed Jun 9, 2024
2 parents f0c5f75 + 8b5be8d commit 5753fd6
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions service-node-koa/app/config/db/knexfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const _cfg = {
},
pool: {
min: 2,
max: 10,
afterCreate: (conn, cb) =>
conn.run('PRAGMA foreign_keys = ON', cb) // does not work with postgres
max: 10
},
migrations: {
directory: `${__dirname}/migrations`,
Expand All @@ -23,29 +21,33 @@ const _cfg = {
* @type { Object.<string, import('knex').Knex.Config> }
*/
module.exports = {
development: { ..._cfg },
development: {
..._cfg,
pool: {
..._cfg.pool,
afterCreate: (conn, cb) =>
conn.run('PRAGMA foreign_keys = ON', cb) // does not work with postgres
}
},
test: {
..._cfg,
connection: {
filename: ':memory:'
},
pool: {
..._cfg.pool,
afterCreate: (conn, cb) =>
conn.run('PRAGMA foreign_keys = ON', cb) // does not work with postgres
}
},
staging: {
..._cfg,
client: 'pg',
connection: process.env.PG_CONNECTION_URL,
pool: {
..._cfg.pool,
afterCreate: undefined
}
connection: process.env.PG_CONNECTION_URL
},
production: {
..._cfg,
client: 'pg',
connection: process.env.PG_CONNECTION_URL,
pool: {
..._cfg.pool,
afterCreate: undefined
}
connection: process.env.PG_CONNECTION_URL
}
}

0 comments on commit 5753fd6

Please sign in to comment.