-
Notifications
You must be signed in to change notification settings - Fork 1
/
knexfile.mysql.ts
44 lines (40 loc) · 1021 Bytes
/
knexfile.mysql.ts
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
import dotenv from 'dotenv';
if (process.env.NODE_ENV === 'test') {
dotenv.config({path: '.env.testing'});
} else {
dotenv.config({path: '.env.dev'});
}
const {
MYSQL_DB_HOST,
MYSQL_DB_DATABASE,
MYSQL_DB_USER,
MYSQL_DB_PASSWORD,
MYSQL_DB_POOL_MAX
} = process.env;
const common = {
client: 'mysql2',
connection: {
host: MYSQL_DB_HOST,
database: MYSQL_DB_DATABASE,
user: MYSQL_DB_USER,
password: MYSQL_DB_PASSWORD,
timezone: '+00:00'
},
pool: {
min: 0,
max: MYSQL_DB_POOL_MAX ? parseInt(MYSQL_DB_POOL_MAX, 10) : 15,
afterCreate: (connection: any, callback: any) => {
connection.query('SET time_zone = "+00:00"', (err: any) => {
callback(err, connection);
});
}
},
migrations: {directory: __dirname + '/db/migrations'},
seeds: {directory: __dirname + '/db/seeds'}
};
export const development = {
...common
};
export const test = {
...common
};