-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknexfile.js
37 lines (31 loc) · 905 Bytes
/
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
35
36
37
// Update with your config settings.
require('dotenv').config();
const databaseConnection = {
useNullAsDefault: true,
connection: {},
migrations: {
directory: './data/migrations'
},
seeds: {
directory: './data/seeds'
}
};
if (process.env.DB_TYPE === 'sqlite') {
databaseConnection.client = 'sqlite3';
databaseConnection.connection.filename = './mydb.sqlite';
databaseConnection.pool = {
afterCreate: (conn, cb) => {
conn.run('PRAGMA foreign_keys = ON', cb);
}
};
}
if (process.env.DB_TYPE === 'postgres') {
databaseConnection.client = 'pg';
databaseConnection.connection.host = process.env.DB_HOST;
databaseConnection.connection.user = process.env.DB_USER;
databaseConnection.connection.password = process.env.DB_PASSWORD;
databaseConnection.connection.database = process.env.DB_DATABASE;
}
module.exports = {
development: databaseConnection
};