diff --git a/database/knex.js b/database/knex.js deleted file mode 100644 index a1b848d..0000000 --- a/database/knex.js +++ /dev/null @@ -1,26 +0,0 @@ -require('dotenv').config(); -const expect = require('expect-runtime'); -const knex = require('knex'); -const log = require('loglevel'); -const connection = require('../config/config').connectionString; - -expect(connection).to.match(/^postgresql:\//); - -const knexConfig = { - client: 'pg', - debug: process.env.NODE_LOG_LEVEL === 'debug', - connection, - pool: { - min: 0, - max: 100, - }, -}; - -log.debug(process.env.DATABASE_SCHEMA); -if (process.env.DATABASE_SCHEMA) { - log.info('setting a schema'); - knexConfig.searchPath = [process.env.DATABASE_SCHEMA]; -} -log.debug(knexConfig.searchPath); - -module.exports = knex(knexConfig); diff --git a/server/database/knex.js b/server/database/knex.js index 6011f01..be6fe85 100644 --- a/server/database/knex.js +++ b/server/database/knex.js @@ -1,19 +1,26 @@ +require('dotenv').config(); +const expect = require('expect-runtime'); +const knex = require('knex'); const log = require('loglevel'); +const connection = require('../../config/config').connectionString; + +expect(connection).to.match(/^postgresql:\//); const knexConfig = { client: 'pg', debug: process.env.NODE_LOG_LEVEL === 'debug', - connection: process.env.DATABASE_URL, - pool: { min: 0, max: 100 }, + connection, + pool: { + min: 0, + max: 100, + }, }; log.debug(process.env.DATABASE_SCHEMA); if (process.env.DATABASE_SCHEMA) { log.info('setting a schema'); - knexConfig.searchPath = [process.env.DATABASE_SCHEMA, 'public']; + knexConfig.searchPath = [process.env.DATABASE_SCHEMA]; } log.debug(knexConfig.searchPath); -const knex = require('knex')(knexConfig); - -module.exports = knex; +module.exports = knex(knexConfig);