forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata-source.ts
More file actions
26 lines (25 loc) · 1.06 KB
/
Copy pathdata-source.ts
File metadata and controls
26 lines (25 loc) · 1.06 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
import 'reflect-metadata';
import { DataSource } from 'typeorm';
import { entities } from '../common/entities/typeorm-entities';
/**
* TypeORM CLI DataSource — used only for `migration:generate`/`migration:run`/
* `migration:revert` (see package.json scripts). The running application
* connects via `TypeOrmModule.forRootAsync` in src/app.module.ts instead;
* the two are kept in sync by importing the same `entities` list.
*
* Before this, the app relied entirely on `synchronize` and had no migration
* history at all (#27) — every schema change (including the exactly-one-
* parent CHECK constraint this DataSource ships the first migration for)
* now goes through a reviewable, revertible migration file instead.
*/
export const AppDataSource = new DataSource({
type: 'postgres',
url:
process.env.DATABASE_URL ??
'postgresql://postgres:postgres@localhost:5432/mergefi',
entities,
migrations: [__dirname + '/migrations/*{.ts,.js}'],
migrationsTableName: 'migrations',
synchronize: false,
logging: process.env.DATABASE_LOGGING === 'true',
});