Database Migration

We currently use Alembic to handle database versioning. All files related to migrations are located into src/bmapi/alembic. All revisions are located into the versions folder. We will go through the step to create a migration and also update your database to the latest revision.

Create a new migration

Note that your BRAUMEISTER_DB environment variable must be set to proceed. Also make sure that the database is currently running.

You can create a migration by running alembic revision and you can also specify –autogenerate. That way, alembic will generate the migration code for you but it doesn’t add code for data migration, only the schema. Review that revision after.

(venv) $ cd src/bmapi
(venv) $ alembic revision --autogenerate -m "my revision name"

Update to latest revision

Note that your BRAUMEISTER_DB environment variable must be set to proceed. Also make sure that the database is currently running.

You just need to run alembic upgrade head to apply all missing revisions to your database.

(venv) $ cd src/bmapi
(venv) $ alembic upgrade head