Skip to content

Commit 098abcb

Browse files
author
hirsch88
committed
Add migration docu and config
1 parent b3a4fbe commit 098abcb

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ DB_PASSWORD=""
2929
DB_DATABASE="my_database"
3030
DB_SYNCHRONIZE=false
3131
DB_LOGGING=false
32+
DB_ENTITIES="src/api/**/*Models.ts"
33+
DB_MIGRATIONS="src/database/migrations/*.ts"
34+
DB_MIGRATIONS_DIR="src/database/migrations"
3235

3336
#
3437
# Swagger

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ All script are defined in the package.json file, but the most important ones are
124124
- Run `nps build` to generated all JavaScript files from the TypeScript sources (There is also a vscode task for this called `build`).
125125
- To start the builded app located in `dist` use `npm start`.
126126

127+
### Database
128+
129+
- Run `./node_modules/.bin/typeorm create -n <migration-file-name>` to create a new migration file.
130+
- To migrate your database run `nps migrate`.
131+
- To revert your latest migration run `nps migrate.revert`.
132+
127133
## Using the debugger in VS Code
128134

129135
Just set a breakpoint and hit `F5` in your Visual Studio Code.

ormconfig.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
2-
"type": "mysql",
3-
"host": "localhost",
4-
"port": 3306,
5-
"username": "root",
6-
"password": "",
7-
"database": "my_database",
8-
"entities": [
9-
"dist/api/**/*Models.js"
10-
],
11-
"migrations": [
12-
"dist/database/migrations/*.js"
13-
],
14-
"cli": {
15-
"migrationsDir": "dist/database/migrations"
16-
}
2+
"type": "mysql",
3+
"host": "localhost",
4+
"port": 3306,
5+
"username": "root",
6+
"password": "",
7+
"database": "my_database",
8+
"entities": [
9+
"src/api/**/*Models.ts"
10+
],
11+
"migrations": [
12+
"src/database/migrations/*.ts"
13+
],
14+
"cli": {
15+
"migrationsDir": "src/database/migrations"
16+
}
1717
}

0 commit comments

Comments
 (0)