mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 18:01:36 +03:00
32a5982430
closes #5519, closes #6197 - default encoding is utf8mb4 instead of utf8 - support emojis - read here why: http://dev.mysql.com/doc/refman/5.7/en/innodb-restrictions.html - read here why: https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-conversion.html
29 lines
794 B
JavaScript
29 lines
794 B
JavaScript
var knex = require('knex'),
|
|
config = require('../../config'),
|
|
knexInstance;
|
|
|
|
// @TODO:
|
|
// - if you require this file before config file was loaded,
|
|
// - then this file is cached and you have no chance to connect to the db anymore
|
|
// - bring dynamic into this file (db.connect())
|
|
function configure(dbConfig) {
|
|
var client = dbConfig.client;
|
|
|
|
if (client === 'sqlite3') {
|
|
dbConfig.useNullAsDefault = dbConfig.useNullAsDefault || false;
|
|
}
|
|
|
|
if (client === 'mysql') {
|
|
dbConfig.connection.timezone = 'UTC';
|
|
dbConfig.connection.charset = 'utf8mb4';
|
|
}
|
|
|
|
return dbConfig;
|
|
}
|
|
|
|
if (!knexInstance && config.get('database') && config.get('database').client) {
|
|
knexInstance = knex(configure(config.get('database')));
|
|
}
|
|
|
|
module.exports = knexInstance;
|