-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathormconfig.ts
More file actions
40 lines (36 loc) · 1.13 KB
/
ormconfig.ts
File metadata and controls
40 lines (36 loc) · 1.13 KB
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
const path = require('path')
const ENVS = {
DEV: 'development',
TEST: 'test',
}
const rootDir = [ENVS.DEV, ENVS.TEST].includes(process.env.NODE_ENV) ? 'src' : 'dist/src'
if (process.env.NODE_ENV != ENVS.TEST) {
require(path.join('src', 'config', 'env'))
}
module.exports = [
{
name: 'default',
type: 'postgres',
url: process.env.DATABASE_URL,
logging: process.env.DEBUG === 'true',
entities: [path.join(rootDir, 'api/*/model/*.{js,ts}'), path.join(rootDir, 'interfaces/*/entities/*.{js,ts}')],
migrations: [path.join(rootDir, 'config/database/migrations/*.{js,ts}')],
cli: {
migrationsDir: path.join(rootDir, 'config/database/migrations'),
},
},
{
name: 'test',
type: 'postgres',
url: process.env.DATABASE_URL,
dropSchema: true,
logging: false,
synchronize: false,
migrationsRun: true,
entities: [path.join(rootDir, 'api/*/model/*.{js,ts}'), path.join(rootDir, 'interfaces/*/entities/*.{js,ts}')],
migrations: [path.join(rootDir, 'config/database/migrations/*.{js,ts}')],
cli: {
migrationsDir: path.join(rootDir, 'config/database/migrations'),
},
},
]