diff --git a/lib/db/index.js b/lib/db/index.js index 94ceb67efe..a1abd45c08 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -9,9 +9,9 @@ const ClientMetricsDb = require('./client-metrics-db'); const ClientMetricsStore = require('./client-metrics-store'); const ClientApplicationsStore = require('./client-applications-store'); -module.exports.createStores = (config, eventBus) => { +module.exports.createStores = (config, eventBus, dbPool) => { const getLogger = config.getLogger; - const db = createDb(config); + const db = dbPool || createDb(config); const eventStore = new EventStore(db, getLogger); const clientMetricsDb = new ClientMetricsDb(db, getLogger); diff --git a/test/e2e/helpers/database-init.js b/test/e2e/helpers/database-init.js index cc356eb99f..5662829173 100644 --- a/test/e2e/helpers/database-init.js +++ b/test/e2e/helpers/database-init.js @@ -64,8 +64,8 @@ module.exports = async function init(databaseSchema = 'test', getLogger) { await db.raw(`CREATE SCHEMA IF NOT EXISTS ${options.databaseSchema}`); await migrator(options); - await db.destroy(); - const stores = await createStores(options, eventBus); + // await db.destroy(); + const stores = await createStores(options, eventBus, db); await resetDatabase(stores); await setupDatabase(stores);