Skip to content

Commit c806d25

Browse files
author
hirsch88
committed
♻️ Refactor typeorm config
1 parent 4682b5a commit c806d25

File tree

4 files changed

+3
-29
lines changed

4 files changed

+3
-29
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ typings/
2020

2121
# Dist #
2222
dist/
23-
ormconfig.json
2423
tsconfig.build.json
2524

2625
# IDE #

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ The swagger and the monitor route can be altered in the `.env` file.
228228
| **test/unit/** *.test.ts | Unit tests |
229229
| .env.example | Environment configurations |
230230
| .env.test | Test environment configurations |
231-
| ormconfig.json | TypeORM configuration for the database. Used by seeds and the migration. (generated file) |
232231
| mydb.sql | SQLite database for integration tests. Ignored by git and only available after integration tests |
233232

234233
![divider](./w3tec-divider.png)
@@ -390,7 +389,6 @@ npm start db.seed
390389
| `npm start "db.seed -L"` | Log database queries to the terminal |
391390
| `npm start "db.seed --factories <path>"` | Add a different path to your factories (Default: `src/database/`) |
392391
| `npm start "db.seed --seeds <path>"` | Add a different path to your seeds (Default: `src/database/seeds/`) |
393-
| `npm start "db.seed --config <file>"` | Path to your ormconfig.json file |
394392
395393
![divider](./w3tec-divider.png)
396394

src/lib/seed/cli.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as Chalk from 'chalk';
22
import * as commander from 'commander';
33
import * as path from 'path';
4+
import { createConnection, getConnectionOptions } from 'typeorm';
45

56
import { loadEntityFactories } from './';
6-
import { getConnection } from './connection';
77
import { loadSeeds } from './importer';
88
import { runSeed, setConnection } from './index';
99

@@ -60,7 +60,8 @@ const run = async () => {
6060
// Get database connection and pass it to the seeder
6161
let connection;
6262
try {
63-
connection = await getConnection();
63+
const connectionOptions = await getConnectionOptions();
64+
connection = await createConnection(connectionOptions);
6465
setConnection(connection);
6566
} catch (error) {
6667
return handleError(error);

src/lib/seed/connection.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)