From 223558d480c6287c5bd605ee632626d254e0dcf1 Mon Sep 17 00:00:00 2001 From: Jesse Desjardins Date: Mon, 2 Feb 2026 17:58:39 -0500 Subject: [PATCH] Update README to include database migration instructions --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3806b5a..03cfbed 100644 --- a/README.md +++ b/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. +### 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= + +# 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 ```bash -# Set env variables +# Set env variables, which default to local infrastructure $ . ./set-env # development