-
Notifications
You must be signed in to change notification settings - Fork 1
/
knexfile.ts
62 lines (59 loc) · 1.79 KB
/
knexfile.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import './src/import-first'
import 'tsconfig-paths/register'
import { Config } from "@config/config";
import { Logger } from "@infrastructure/logger/logger";
import { Knex } from "knex";
const config = new Config();
const local: Knex.Config = {
client: "mysql2",
connection: {
host: config.get().db.host,
port: config.get().db.port,
user: config.get().db.user,
password: config.get().db.password,
database: config.get().db.database,
supportBigNumbers: true,
bigNumberStrings: true,
multipleStatements: true,
dateStrings: true
},
pool:{
afterCreate: function(connection: any, callback: any) {
connection.query(`SET time_zone = "${config.get().timezone}";`, function(err: unknown) {
if (err) {
Logger.warn(err, "failed to initialize mysql database connection");
} else {
Logger.debug("mysql database connected");
}
callback(err, connection);
});
},
min: config.get().db.pool.min,
max: config.get().db.pool.max
},
migrations: {
tableName: "migrations",
directory: `${__dirname}/db/migrations`
},
seeds: {
directory: `${__dirname}/db/seeds`
},
debug: config.get().db.debug
};
export default {
local,
test: {
...local,
connection: {
host: config.get().db.host,
port: config.get().db.port,
user: config.get().db.user,
password: config.get().db.password,
database: `${config.get().db.database}_test`,
supportBigNumbers: true,
bigNumberStrings: true,
multipleStatements: true,
dateStrings: true
}
}
};