# Adding DB changes to alembic

[Alembic](https://alembic.sqlalchemy.org/) manages database schema changes.

Having updated cdsdashboards/orm.py by adding some new fields, I activated a virtualenv with cdsdashboards installed.

Change to the cdsdashboards source code folder. Run JupyterHub in order to create an jupyterhub.sqlite file, 
or copy one you already have available. This DB must be based on the OLD schema.

```
cd /Users/dan/Dev/cdsdashboards
cp examples/sqlitedbs/local_process_spawner.sqlite jupyterhub.sqlite
```

The upgrade can be autogenerated:

```
python -m cdsdashboards.dbutil alembic revision --autogenerate -m "Added templates"                        
```

This created the file /cdsdashboards/cdsalembic/versions/f353692d88d5_added_templates.py

To start with, the upgrade and downgrade functions in that file also contained deletion of the alembic versions/version_num 
objects, so I removed those lines of the code (which is not version-controlled).
