Update README to include database migration instructions
This commit is contained in:
22
README.md
22
README.md
@@ -17,10 +17,30 @@ To simplify development, all local infrastructure is handled with Docker. The fo
|
|||||||
|
|
||||||
- `compose.yaml`: A Docker compose file that stands up a Postgres database and a pgAdmin instance to visualize.
|
- `compose.yaml`: A Docker compose file that stands up a Postgres database and a pgAdmin instance to visualize.
|
||||||
|
|
||||||
|
### Database Migrations
|
||||||
|
|
||||||
|
Any time a change is made to a `.entity.ts` file, a new migration will need to be generated and added to the `appDataSource.ts` file. This ensures the API is refencing the most up-to-date (and valid!) database schema. These are the migration commands:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# generate migration
|
||||||
|
$ npm run db:gen_migration
|
||||||
|
|
||||||
|
# generate migration with a custom name
|
||||||
|
$ npm run db:gen_migration_named --name=<any_name_here>
|
||||||
|
|
||||||
|
# show migrations
|
||||||
|
$ npm run db:show_migrations
|
||||||
|
|
||||||
|
# run migrations
|
||||||
|
$ npm run db:run_migrations
|
||||||
|
```
|
||||||
|
|
||||||
|
**NOTE ON MIGRATIONS IN TYPEORM**: In order for any new migration to be considered in the `db:show_migrations` or `db:run_migrations` commands, they'll need to be added to the `appDataSource.ts` file, under the `migrations: []` option.
|
||||||
|
|
||||||
## Compile and run the project
|
## Compile and run the project
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Set env variables
|
# Set env variables, which default to local infrastructure
|
||||||
$ . ./set-env
|
$ . ./set-env
|
||||||
|
|
||||||
# development
|
# development
|
||||||
|
|||||||
Reference in New Issue
Block a user