3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-17 07:05:03 +00:00

Switch from node-mariasql to mysql2

Node-mariasql returned dates in an incorrect timezone, and the project
doesn't seem to be actively maintained. Switching to mysql2 fixes the issue.
This commit is contained in:
Dragory 2018-08-02 00:48:48 +03:00
parent eb7efd9648
commit 3e5f182aaf
4 changed files with 124 additions and 34 deletions

View file

@ -1,19 +1,23 @@
require('dotenv').config();
const moment = require('moment-timezone');
moment.tz.setDefault('UTC');
module.exports = {
client: 'mariasql',
client: 'mysql2',
connection: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
db: process.env.DB_DATABASE,
charset: 'utf8mb4'
},
pool: {
afterCreate(connection, callback) {
connection.query("SET time_zone = '+0:00';", err => {
callback(err, connection);
});
database: process.env.DB_DATABASE,
charset: 'utf8mb4',
timezone: 'UTC',
typeCast(field, next) {
if (field.type === 'DATETIME') {
return moment(field.string()).format('YYYY-MM-DD HH:mm:ss');
}
return next();
}
}
};