From be8291a608d4f58b80ad134f2a97bec876e28368 Mon Sep 17 00:00:00 2001 From: Graham Williamson Date: Thu, 13 Jul 2023 08:53:28 +1000 Subject: [PATCH] Add better instructions for flask migrate --- README.md | 17 ++++++++++++++++- backend/{README.MD => README.md} | 0 2 files changed, 16 insertions(+), 1 deletion(-) rename backend/{README.MD => README.md} (100%) diff --git a/README.md b/README.md index a3ae9482..7ac648af 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,17 @@ curl http://localhost:5000/connectors ## Database changes -If there any changes made to the model run the migrate command (example commment) +If there any changes made to the model first ensure that it is added to the list of imports in +`backend/app/__init_.py` before the following line + +``` +migrate = Migrate(app, db) +``` + +This allows alembic and flask migrate to see all the models in use so the migrations can be +generated correctly. + +Once that is done, then you need to run the migrate command (example commment) and if any changes were detected, update your local DB instance. ``` @@ -76,6 +86,11 @@ FLASK_APP=copilot.py flask db migrate -m "Add User model." FLASK_APP=copilot.py flask db upgrade ``` +Review the generated migration file to make sure the changes to the databse make sense in terms +of what is needed to upgrade from the previous state, and then to downgrade to remove this migration. + +Don't forget to commit the new migration file into git. + See https://flask-migrate.readthedocs.io/en/latest/ for further information # Deployment diff --git a/backend/README.MD b/backend/README.md similarity index 100% rename from backend/README.MD rename to backend/README.md