1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

use options obj

This commit is contained in:
sveisvei 2016-11-13 15:15:33 +01:00 committed by Ivar Conradi Østhus
parent 7894ddda7d
commit cad07cc6ec
3 changed files with 11 additions and 12 deletions

View File

@ -2,12 +2,12 @@
const knex = require('knex');
module.exports.createDb = function (databaseConnection, schema = 'public') {
module.exports.createDb = function ({ databaseUri, poolMin = 2, poolMax = 20, databaseSchema = 'public' }) {
const db = knex({
client: 'pg',
connection: databaseConnection,
pool: { min: 2, max: 20 },
searchPath: schema,
connection: databaseUri,
pool: { min: poolMin, max: poolMax },
searchPath: databaseSchema,
});
return db;

View File

@ -9,7 +9,7 @@ const ClientMetricsStore = require('./client-metrics-store');
const ClientStrategyStore = require('./client-strategy-store');
module.exports.createStores = (config) => {
const db = createDb(config.databaseUri, config.databaseSchema);
const db = createDb(config);
const eventStore = new EventStore(db);
return {

View File

@ -1,13 +1,12 @@
'use strict';
const DBMigrate = require('db-migrate');
const path = require('path');
const { getInstance } = require('db-migrate');
const parseDbUrl = require('parse-database-url');
function migrateDb (dbUrl, schema = "public") {
const custom = parseDbUrl(dbUrl);
custom.schema = schema;
const dbmigrate = DBMigrate.getInstance(true, {
function migrateDb ({ databaseUri, databaseSchema = 'public' }) {
const custom = parseDbUrl(databaseUri);
custom.schema = databaseSchema;
const dbmigrate = getInstance(true, {
cwd: __dirname,
config: { custom },
env: 'custom' }
@ -15,4 +14,4 @@ function migrateDb (dbUrl, schema = "public") {
return dbmigrate.up();
}
module.exports = migrateDb;
module.exports = migrateDb;