Moved sqlite3 override rules to db connection lib

- We have an already established location for special rules based on db client
- Removes the need to require config inside of overrides
This commit is contained in:
Hannah Wolfe 2021-01-28 15:10:34 +00:00
parent f6a7abdf5a
commit 256b77b0e4
2 changed files with 5 additions and 11 deletions

View File

@ -12,7 +12,12 @@ function configure(dbConfig) {
const client = dbConfig.client;
if (client === 'sqlite3') {
// Backwards compatibility with old knex behaviour
dbConfig.useNullAsDefault = Object.prototype.hasOwnProperty.call(dbConfig, 'useNullAsDefault') ? dbConfig.useNullAsDefault : true;
// Force bthreads to use child_process backend until a worker_thread-compatible version of sqlite3 is published
// https://github.com/mapbox/node-sqlite3/issues/1386
process.env.BTHREADS_BACKEND = 'child_process';
}
if (client === 'mysql') {

View File

@ -1,5 +1,3 @@
const config = require('../shared/config');
/**
* If we enable bluebird debug logs we see a huge memory usage.
* You can reproduce by removing this line and import a big database export into Ghost.
@ -7,15 +5,6 @@ const config = require('../shared/config');
*/
process.env.BLUEBIRD_DEBUG = 0;
/**
* Force bthreads to use child_process backend until a worker_thread-compatible version of sqlite3 is published
* https://github.com/mapbox/node-sqlite3/issues/1386
*/
const isSQLite = config.get('database:client') === 'sqlite3';
if (isSQLite) {
process.env.BTHREADS_BACKEND = 'child_process';
}
const moment = require('moment-timezone');
/**