-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathormconfig.ts
50 lines (46 loc) · 1.75 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/** @format */
//#region Imports NPM
import { resolve } from 'path';
//#endregion
//#region Imports Local
import { WinstonModule } from 'nest-winston';
import { winstonOptions } from '@back/shared/logger.options';
import { TypeOrmLogger } from '@back/shared/typeorm.logger';
import { ConfigService } from '@app/config/config.service';
import { Group } from '@back/group/group.entity';
import { Profile } from '@back/profile/profile.entity';
import { User } from '@back/user/user.entity';
import { News } from '@back/news/news.entity';
//#endregion
const entities = [Group, Profile, User, News];
// const entities = ['apps/portal/src/**/*.entity.ts'];
// const entities = ['./.next/nest/**/*.entity.js'];
// const migrations = dev ? ['src/migrations/*.migration.ts'] : ['.nest/migrations/*.migration.js'];
const configService = new ConfigService(resolve('./.local/.env'));
const logger = WinstonModule.createLogger(winstonOptions());
export default {
name: 'default',
type: 'postgres',
replication: {
master: { url: configService.get('DATABASE_URI') },
slaves: [{ url: configService.get('DATABASE_URI_RD') }],
},
url: configService.get('DATABASE_URI'),
port: configService.get('DATABASE_PORT'),
username: configService.get('DATABASE_USERNAME'),
password: configService.get('DATABASE_PASSWORD'),
database: configService.get('DATABASE_DATABASE'),
schema: configService.get('DATABASE_SCHEMA'),
uuidExtension: 'pgcrypto',
synchronize: configService.get('DATABASE_SYNCHRONIZE'),
dropSchema: configService.get('DATABASE_DROP_SCHEMA'),
logging: 'all',
logger: new TypeOrmLogger(logger),
entities,
migrationsRun: configService.get('DATABASE_MIGRATIONS_RUN'),
cache: false,
// migrations,
// cli: {
// migrationsDir: 'migration',
// },
};