Skip to content

Commit 18107ff

Browse files
committed
typeorm migration file added
1 parent 5eece27 commit 18107ff

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ DB_PASSWORD = dbpassword;
7878

7979
If you want to change or update any code you can just make the change and from the console you will see that the server is getting updated.
8080

81+
82+
### Run migration in docker
83+
84+
```sh
85+
docker-compose exec comm-tool-api npm run migration:create src/database/migration/user
86+
```
87+
8188
### Run without docker
8289

8390
If you don't use Docker then you will get an exception specifying you don't have any database.

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"prepare": "husky install",
1515
"test:dev": "jest --runInBand --watchAll --no-cache",
1616
"test": "jest --runInBand --no-cache",
17+
"typeorm": "typeorm-ts-node-commonjs -d ./src/DataSource.ts",
18+
"migration:generate": "npm run typeorm migration:generate",
19+
"migration:show": "npm run typeorm migration:show",
20+
"migration:run": "npm run typeorm migration:run",
21+
"migration:revert": "npm run typeorm migration:revert",
22+
"migration:create": "typeorm-ts-node-commonjs migration:create",
1723
"pre-commit": "lint-staged"
1824
},
1925
"jest": {

src/DataSource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ const config: DataSourceOptions = {
1616

1717
const AppDataSource = new DataSource(config);
1818

19-
export { AppDataSource, config };
19+
export default AppDataSource;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ErrorHandler from './middlewares/ErrorHandler';
22
import Config from './config/Config';
33
import http from 'http';
44
import { AppLogger } from './utils/Logger';
5-
import { AppDataSource } from './DataSource';
5+
import AppDataSource from './DataSource';
66
import { app } from './app';
77
const PORT = Config.port || 4000;
88

src/tests/integration/auth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import request from 'supertest';
22
import { app } from '../../app';
33
import { User } from '../../entity/User';
4-
import { AppDataSource } from '../../DataSource';
4+
import AppDataSource from '../../DataSource';
55

66
const userRepo = AppDataSource.getRepository(User);
77

0 commit comments

Comments
 (0)