3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00
zeppelin/knexfile.js

35 lines
784 B
JavaScript
Raw Normal View History

2018-07-01 03:35:51 +03:00
require('dotenv').config();
const moment = require('moment-timezone');
moment.tz.setDefault('UTC');
2018-07-01 03:35:51 +03:00
module.exports = {
client: 'mysql2',
2018-07-01 03:35:51 +03:00
connection: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
charset: 'utf8mb4',
timezone: 'UTC',
supportBigNumbers: true,
bigNumberStrings: true,
dateStrings: true,
typeCast(field, next) {
if (field.type === 'DATETIME') {
2018-08-05 00:45:54 +03:00
const val = field.string();
return val != null ? moment(val).format('YYYY-MM-DD HH:mm:ss') : null;
}
return next();
2018-07-09 03:12:49 +03:00
}
2018-08-02 17:53:03 +03:00
},
pool: {
afterCreate(conn, cb) {
conn.query('SET time_zone = "+00:00";', err => {
cb(err, conn);
});
}
2018-07-01 03:35:51 +03:00
}
};