-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathknexfile.js
49 lines (41 loc) · 922 Bytes
/
knexfile.js
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
const path = require('path')
const config = require('./server/config')
const migrations = {
directory: path.join(__dirname, './migrations')
}
const useNullAsDefault = true
const sqlite = {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, config.SQLITE_FILENAME)
}
}
const otherDatabase = {
client: config.DATABASE_TYPE,
connection: {
host: config.DATABASE_HOST,
port: config.DATABASE_PORT,
user: config.DATABASE_USER,
password: config.DATABASE_PASS,
database: config.DATABASE_NAME
}
}
const database = config.DATABASE_TYPE === 'sqlite' ? sqlite : otherDatabase
module.exports = {
test: {
...database,
migrations,
useNullAsDefault,
...(database === sqlite && { connection: ':memory:' })
},
development: {
...database,
migrations,
useNullAsDefault
},
production: {
...database,
migrations,
useNullAsDefault
}
}