-
Notifications
You must be signed in to change notification settings - Fork 0
/
knexfile.js
executable file
·34 lines (30 loc) · 1.01 KB
/
knexfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* eslint-disable @typescript-eslint/no-require-imports */
const dotenv = require('dotenv').config().parsed;
const path = require('path');
const fs = require('fs');
let migrationFolder = path.join(__dirname, 'src', 'modules', 'database', 'migrations');
if (!fs.existsSync(migrationFolder)) {
migrationFolder = path.join(__dirname, 'bin', 'modules', 'database', 'migrations');
}
const commonSettings = {
client: 'postgres',
connection: {
host: process.env.DATABASE_HOST || dotenv.DATABASE_HOST,
database: process.env.DATABASE_DB || dotenv.DATABASE_DB,
user: process.env.DATABASE_USER || dotenv.DATABASE_USER,
password: process.env.DATABASE_PASSWORD || dotenv.DATABASE_PASSWORD,
port: process.env.DATABASE_PORT || dotenv.DATABASE_PORT
},
migrations: {
tableName: 'knex_migrations',
directory: migrationFolder
},
seeds: {
directory: path.join(migrationFolder, 'seeds')
},
debug: false
};
module.exports = {
development: { ...commonSettings },
production: { ...commonSettings }
};