activities icon indicating copy to clipboard operation
activities copied to clipboard

How to extend the DB schema?

Open flopp opened this issue 5 years ago • 3 comments

For #42 the DB schema needs to be extended. How to do this in Sqlalchemy such that old DB files can still be loaded (and extended on the fly)?

flopp avatar Jul 12 '20 15:07 flopp

Sqlalchemy does it automatically

Djailla avatar Jul 12 '20 16:07 Djailla

Hm, I just added an average_heartrate column to the Activity class in db.py. Running the normal (non-reset) sync results in an exception sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: activities.average_heartrate...

-> Either I'm missing a required step, or DB migration is not done automatically...

But that's ok, since one could just use the --reset flag to regenerate the whole DB from scratch.

flopp avatar Jul 12 '20 18:07 flopp

In fact, it requires to use Alembic :

https://alembic.sqlalchemy.org/en/latest/

I will take a look

Djailla avatar Jul 15 '20 09:07 Djailla