Draft: INVESTIGATION Add code to allow for automatic migrations
Proposal MR to activate automated migrations
By adding the declarative base & running a command like: alembic revision --autogenerate -m "test auto migration"
, alembic auto-generates migrations based on changes in the SQL models (with table=True)
Possible advantages
- Only need to define the table once. In this repo, the classes ViewPreset and WorkspacePreset ( SQLModel, table=True) will be used as bases to define the the tables
- If changes are made to these classes, you can run the
alembic revision --autogenerate -m "..."
command so the migration script is automatically generated - This saves "double" work, having to make changes in both
models.py
and writing the migratoin script
How to test
- Make sure alembic works/is enabled in your repo
- Make a change change to one of the SQLModels (ViewPreset and/or WorkspacePreset) in
models.py
: add a dummy field, change type etc. - Run the alembic command to autogenerate a migration
- A new migration script should show up in the directory
migrations/versions
. The changes in this script should reflect the ones you made in themodels.py
file
Edited by Mizzi van der Ven