From 256b77b0e4b3a83cb742940f6717843e34611751 Mon Sep 17 00:00:00 2001 From: Hannah Wolfe Date: Thu, 28 Jan 2021 15:10:34 +0000 Subject: [PATCH] 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 --- core/server/data/db/connection.js | 5 +++++ core/server/overrides.js | 11 ----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/core/server/data/db/connection.js b/core/server/data/db/connection.js index 8f082486ef..f9b60c94e1 100644 --- a/core/server/data/db/connection.js +++ b/core/server/data/db/connection.js @@ -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') { diff --git a/core/server/overrides.js b/core/server/overrides.js index 60234c9e8b..7b22177c6d 100644 --- a/core/server/overrides.js +++ b/core/server/overrides.js @@ -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'); /**