-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknexfile.js
38 lines (32 loc) · 960 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
38
const path = require('path');
const fs = require('fs');
const pathToDb = path.resolve(__dirname, 'data', 'db');
let client = 'sqlite3';
let connection = {
filename: path.join(pathToDb, 'database.sqlite')
};
if (String(process.env.USE_AZURE_SQL).toLowerCase() === 'true') {
client = 'mssql';
connection = {
server : `${process.env.SQL_SERVER}.database.windows.net`,
user : process.env.SQL_USERNAME,
password : process.env.SQL_PASSWORD,
database : process.env.SQL_DATABASE,
options: {
port: 1433,
encrypt: true
}
};
}
else if (!fs.existsSync(pathToDb)) fs.mkdirSync(pathToDb, { recursive: true });
module.exports = {
client,
connection,
migrations: {
directory: path.resolve(__dirname, 'src', 'database', 'migrations')
},
seeds: {
directory: path.resolve(__dirname, 'src', 'database', 'seeds')
},
useNullAsDefault: true
};