-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdata-source.ts
More file actions
39 lines (32 loc) · 1.12 KB
/
data-source.ts
File metadata and controls
39 lines (32 loc) · 1.12 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
import { DataSource, DataSourceOptions } from 'typeorm';
import 'reflect-metadata';
import envConfig from './config/envConfig';
// Make sure to set this to false in production
const syncDatabase = true;
const databaseConfig: DataSourceOptions = {
type: 'postgres',
host: envConfig.POSTGRES_HOST,
port: envConfig.POSTGRES_PORT,
username: envConfig.POSTGRES_USER,
password: envConfig.POSTGRES_PASSWORD,
database: envConfig.POSTGRES_DB,
synchronize: syncDatabase,
logging: false,
entities: syncDatabase ? ['src/entities/**/*.ts'] : ['dist/entities/**/*.js'],
migrations: syncDatabase ? ['src/migrations/**/*.ts'] : ['dist/migrations/**/*.js'],
subscribers: []
};
export const testDatabaseConfig: DataSourceOptions = {
type: 'postgres',
host: 'localhost',
port: 2345,
username: 'root',
database: 'test',
password: 'easypass',
synchronize: true,
dropSchema: true,
entities: syncDatabase ? ['src/entities/**/*.ts'] : ['dist/entities/**/*.js']
};
const AppDataSource = new DataSource(databaseConfig);
const TestDataSource = new DataSource(testDatabaseConfig);
export default { AppDataSource, TestDataSource };