This change applies the guided migration process recommended by
SQLAlchemy [1], up to step 4, to have declarative ORM models that better
support Python typing.
The change was tested by running `alembic check`, which does not find
any schema changes.
Errors reported by `mypy` go down to 170, from the original 223 in the
current `master` commit.
[1] https://docs.sqlalchemy.org/en/20/changelog/whatsnew_20.html#migrating-an-existing-mapping