-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathknexfile.js
42 lines (39 loc) · 999 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
// Update with your config settings.
//
const dotenv = require('dotenv');
const PgError = require('pg-error');
dotenv.load();
function emitPgError(err) {
switch (err.severity) {
case 'ERROR':
case 'FATAL':
case 'PANIC':
return this.emit('error', err);
default:
return this.emit('notice', err);
}
}
module.exports = {
client: process.env.DB_CLIENT,
connection: {
host: process.env.NODE_ENV === 'production' ? 'db' : process.env.DB_HOST || 'localhost',
database: process.env.DB_NAME || 'postgres',
user: process.env.DB_USER || 'postgres',
password: process.env.DB_PASSWORD || 'postgres',
charset: 'utf8',
port: 5432
},
pool: {
min: 2,
max: 10,
afterCreate: (connection, done) => {
connection.connection.parseE = PgError.parse;
connection.connection.parseN = PgError.parse;
connection.connection.on('PgError', emitPgError);
done();
}
},
migrations: {
tableName: 'knex_migrations'
}
};