Skip to content

Commit

Permalink
Add better instructions for flask migrate (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
00willo authored Jul 12, 2023
1 parent a9314af commit 9372c3d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,29 @@ 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.

```
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
Expand Down
File renamed without changes.

0 comments on commit 9372c3d

Please sign in to comment.