@cryptotaxi247 / CoPilot / commits / 9372c3d1

Add better instructions for flask migrate (#19)

Graham Williamson committed Jul 13, 2023 at 08:55 UTC 9372c3d18cdbe113076fdc283977fdf1a2bab0a1
2 files changed +16 -1
README.md
+16 -1
@@ -68,7 +68,17 @@ curl http://localhost:5000/connectors
68
69 ## Database changes
70
71 -If there any changes made to the model run the migrate command (example commment)
71 +If there any changes made to the model first ensure that it is added to the list of imports in
72 +`backend/app/__init_.py` before the following line
73 +
74 +```
75 +migrate = Migrate(app, db)
76 +```
77 +
78 +This allows alembic and flask migrate to see all the models in use so the migrations can be
79 +generated correctly.
80 +
81 +Once that is done, then you need to run the migrate command (example commment)
82 and if any changes were detected, update your local DB instance.
83
84 ```
@@ -76,6 +86,11 @@ FLASK_APP=copilot.py flask db migrate -m "Add User model."
86 FLASK_APP=copilot.py flask db upgrade
87 ```
88
89 +Review the generated migration file to make sure the changes to the databse make sense in terms
90 +of what is needed to upgrade from the previous state, and then to downgrade to remove this migration.
91 +
92 +Don't forget to commit the new migration file into git.
93 +
94 See https://flask-migrate.readthedocs.io/en/latest/ for further information
95
96 # Deployment
backend/README.md renamed