2020-02-18 23:55:06 -05:00
|
|
|
const config = require('config');
|
|
|
|
|
|
|
|
if (!config.has('database')) {
|
|
|
|
throw new Error('Database config does not exist! Please read the instructions: https://github.com/jc21/nginx-proxy-manager/blob/master/doc/INSTALL.md');
|
|
|
|
}
|
|
|
|
|
2020-07-19 10:43:01 -04:00
|
|
|
function generateDbConfig() {
|
|
|
|
if (config.database.engine === 'knex-native') {
|
|
|
|
return config.database.knex;
|
|
|
|
} else
|
|
|
|
return {
|
|
|
|
client: config.database.engine,
|
|
|
|
connection: {
|
|
|
|
host: config.database.host,
|
|
|
|
user: config.database.user,
|
|
|
|
password: config.database.password,
|
|
|
|
database: config.database.name,
|
|
|
|
port: config.database.port
|
|
|
|
},
|
|
|
|
migrations: {
|
|
|
|
tableName: 'migrations'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let data = generateDbConfig();
|
2020-02-18 23:55:06 -05:00
|
|
|
|
|
|
|
if (typeof config.database.version !== 'undefined') {
|
|
|
|
data.version = config.database.version;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = require('knex')(data);
|