mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
use options obj
This commit is contained in:
parent
7894ddda7d
commit
cad07cc6ec
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
const knex = require('knex');
|
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({
|
const db = knex({
|
||||||
client: 'pg',
|
client: 'pg',
|
||||||
connection: databaseConnection,
|
connection: databaseUri,
|
||||||
pool: { min: 2, max: 20 },
|
pool: { min: poolMin, max: poolMax },
|
||||||
searchPath: schema,
|
searchPath: databaseSchema,
|
||||||
});
|
});
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
|
@ -9,7 +9,7 @@ const ClientMetricsStore = require('./client-metrics-store');
|
|||||||
const ClientStrategyStore = require('./client-strategy-store');
|
const ClientStrategyStore = require('./client-strategy-store');
|
||||||
|
|
||||||
module.exports.createStores = (config) => {
|
module.exports.createStores = (config) => {
|
||||||
const db = createDb(config.databaseUri, config.databaseSchema);
|
const db = createDb(config);
|
||||||
const eventStore = new EventStore(db);
|
const eventStore = new EventStore(db);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
11
migrator.js
11
migrator.js
@ -1,13 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const DBMigrate = require('db-migrate');
|
const { getInstance } = require('db-migrate');
|
||||||
const path = require('path');
|
|
||||||
const parseDbUrl = require('parse-database-url');
|
const parseDbUrl = require('parse-database-url');
|
||||||
|
|
||||||
function migrateDb (dbUrl, schema = "public") {
|
function migrateDb ({ databaseUri, databaseSchema = 'public' }) {
|
||||||
const custom = parseDbUrl(dbUrl);
|
const custom = parseDbUrl(databaseUri);
|
||||||
custom.schema = schema;
|
custom.schema = databaseSchema;
|
||||||
const dbmigrate = DBMigrate.getInstance(true, {
|
const dbmigrate = getInstance(true, {
|
||||||
cwd: __dirname,
|
cwd: __dirname,
|
||||||
config: { custom },
|
config: { custom },
|
||||||
env: 'custom' }
|
env: 'custom' }
|
||||||
|
Loading…
Reference in New Issue
Block a user