Migrate SQLAlchemy mappings to 2.0 format
Background
In SQLAlchemy v2, we should utilize "out-of-the-box" support for typing.
Implementation
See https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#orm-declarative-models, and implement step 1-4 in "Migrate an existing mapping".
Note that there are currently many columns that are nullable, even though they shouldn't be. Types should be consistent with the database model, so ensure that Optional
or x | None
is used where appropriate. This can easily be checked by looking at the database schema with \d <tablename>
in psql.