-
Notifications
You must be signed in to change notification settings - Fork 15
/
ormconfig.js
45 lines (42 loc) · 1.27 KB
/
ormconfig.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
39
40
41
42
43
44
45
const ConnectionString = require('connection-string').ConnectionString;
const config = require('dotenv').config;
const path = require('path');
config();
const connectionString = new ConnectionString(process.env.DATABASE_URL);
if (connectionString.protocol === 'sqlite') {
module.exports = {
type: 'sqlite',
database: './' + connectionString.host + (connectionString.segments.length ? '/' + connectionString.segments[0] : ''),
entities: [
'src/**/entities/**/*.entity.ts',
],
migrations: [
'src/**/migrations/**/*.ts'
],
subscribers: [
'src/**/subscribers/**/*.ts'
],
logging: 'all',
synchronize: false,
}
} else {
module.exports = {
type: connectionString.protocol,
host: connectionString.host,
port: +connectionString.port,
username: connectionString.user,
password: connectionString.password,
database: connectionString.segments[0],
entities: [
'src/**/entities/**/*.entity.ts',
],
migrations: [
'src/**/migrations/**/*.ts'
],
subscribers: [
'src/**/subscribers/**/*.ts'
],
logging: 'all',
synchronize: false,
}
}