forked from energywebfoundation/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ormconfig.ts
30 lines (27 loc) · 917 Bytes
/
ormconfig.ts
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
import { ConnectionOptions } from 'typeorm';
const getDBConnectionOptions = (): ConnectionOptions => {
return process.env.DATABASE_URL
? {
type: 'postgres',
url: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
}
: {
type: 'postgres',
host: process.env.DB_HOST ?? 'localhost',
port: Number(process.env.DB_PORT) ?? 5432,
username: process.env.DB_USERNAME ?? 'postgres',
password: process.env.DB_PASSWORD ?? 'postgres',
database: process.env.DB_DATABASE ?? 'origin'
};
};
const config: ConnectionOptions = {
...getDBConnectionOptions(),
synchronize: false,
migrationsRun: true,
migrations: [`${__dirname}/migrations/*.js`],
migrationsTableName: 'migrations_backend'
};
export = config;