-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathknexfile.js
More file actions
55 lines (46 loc) · 1.27 KB
/
Copy pathknexfile.js
File metadata and controls
55 lines (46 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import dotenv from 'dotenv'
import { createRequire } from 'node:module'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { environment } from '#common/environment.js'
const require = createRequire(import.meta.url)
const { name, version } = require('./package.json')
dotenv.config()
const dirname = path.dirname(fileURLToPath(import.meta.url))
const baseConfig = {
client: 'pg',
connection: {
host: environment.pgHost,
user: environment.pgUser,
password: environment.pgPassword,
database: environment.pgDatabase,
port: environment.pgPort,
application_name:
process.env.AWS_LAMBDA_FUNCTION_NAME || `${name}/${version}`,
},
migrations: {
tableName: 'knex_migrations',
directory: path.join(dirname, 'db/migrations'),
},
seeds: {
directory: path.join(dirname, 'db/seeds'),
},
}
export default {
local: baseConfig,
test: {
...baseConfig,
// set pool size to 1 to detect db connection acquiring deadlock
// explained in https://github.com/Vincit/objection.js/issues/1137#issuecomment-561149456
pool: { min: 1, max: 1 },
acquireConnectionTimeout: 600000, // 10 minutes
},
development: baseConfig,
production: {
...baseConfig,
pool: {
min: 2,
max: 10,
},
},
}