zappyzep/knexfile.js

34 lines
738 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') {
return moment(field.string()).format('YYYY-MM-DD HH:mm:ss');
}
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
}
};