-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.js
42 lines (39 loc) · 831 Bytes
/
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
const dbConfig = {
syncronize: false,
migrations: [
'migrations/*.js'
],
cli: {
migrationsDir: 'migrations',
}
};
switch (process.env.NODE_ENV) {
case 'development':
Object.assign(dbConfig, {
type: 'sqlite',
database: 'db.sqlite',
entities: ['**/*.entity.js'],
});
break;
case 'test':
Object.assign(dbConfig, {
type: 'sqlite',
database: 'test.sqlite',
entities: ['**/*.entity.ts'],
migrationsRun: true
});
break;
case 'production':
Object.assign(dbConfig, {
type: 'postgres',
url: process.env.DATABASE_URL,
migrationsRun: true,
entities: ['**/*.entity.ts'],
ssl: {
rejectUnauthorized: false,
}
});
default:
throw new Error('unknown environment');
};
module.exports = dbConfig;