diff --git a/migrations/README.md b/migrations/README.md index cba7f099d..243eacc91 100644 --- a/migrations/README.md +++ b/migrations/README.md @@ -2,7 +2,7 @@ If you modify the database models (e.g. tables or indexes), you must create a migration for the changes. We use `Alembic` (via `flask-migrate`) which compares our database models with the running database to generate a suggested migration. -This document explains how to generate new database migration. +This document explains how to generate new database migration. ## Steps for Generating Migrations @@ -22,7 +22,7 @@ Edit the `models.py` file to reflect the changes you need. This might include: - Modifying existing fields - Deleting tables or columns -### 3. Create a new migration +### 3. Create a new migration To create the migration, pick **one of the following options**. This will create a migration in the folder `migrations/versions`. @@ -46,13 +46,12 @@ docker exec dds_backend flask db migrate -m ### 4. Review the Generated Migration File -Now, a new migration will have been generated in the `migrations/versions` directory. **Review this file carefully** to ensure it correctly represents your intended changes. If not, change the `upgrade` and `downgrade` functions as needed. - -> **NB!** Keep an eye out for changes to the `apscheduler` tables and indexes, and **make sure they are not included in the migration**. -> Apscheduler is no longer used for the cronjobs, but are listed in the requirements still. This note will be removed once we have removed `apscheduler` all together. +Now, a new migration will have been generated in the `migrations/versions` directory. **Review this file carefully** to ensure it correctly represents your intended changes. If not, change the `upgrade` and `downgrade` functions as needed. -For reference on available operations and customization options, check the [Alembic Documentation](https://alembic.sqlalchemy.org/en/latest/ops.html). +> **NB!** Keep an eye out for changes to the `apscheduler` tables and indexes, and **make sure they are not included in the migration**. +> Apscheduler is no longer used for the cronjobs, but are listed in the requirements still. This note will be removed once we have removed `apscheduler` all together. +For reference on available operations and customization options, check the [Alembic Documentation](https://alembic.sqlalchemy.org/en/latest/ops.html). ### 5. Test the migration @@ -66,7 +65,7 @@ docker exec -it dds_backend /bin/sh # 2. Run the database upgrade flask db upgrade -``` +``` #### Option B @@ -78,8 +77,7 @@ docker exec dds_backend flask db upgrade ### 6. Commit the Migration File -Finally, commit the migration file to git. - +Finally, commit the migration file to git. ## How to start over @@ -87,11 +85,11 @@ If you want to start over, e.g. if something went wrong when following the steps 1. Restore the content of `migrations/versions`: - a) Remove the new migrations file(s) - b) Run `git restore` on the `migrations/versions` folder + a) Remove the new migrations file(s) + b) Run `git restore` on the `migrations/versions` folder 2. Reset the container: `docker compose down` -3. Remove `flask init-db $$DB_TYPE &&` in the `docker-compose.yml` file. This will prevent the population of the database and instead allow the install of the old schema. +3. Remove `flask init-db $$DB_TYPE &&` in the `docker-compose.yml` file. This will prevent the population of the database and instead allow the install of the old schema. 4. Start the container again: `docker-compose up` 5. Follow the [Steps for Generating Migrations](#steps-for-generating-migrations) section