Skip to main content

schema

Shared columns for every versioned cache record.

Base is the single place to add a column that every record's table should carry. Add a mapped_column here and every record — across every version — inherits it.

Why Base is a plain class and not a DeclarativeBase

Each versioned record declares its own local declarative base (its own MetaData) in its v<N>/schema.py, which inherits this Base for the shared columns. This split is load-bearing: a single shared declarative base would force one MetaData, and the record registry imports every v* package, so v1 and v2 of the same record would both map __tablename__ into that one MetaData and SQLAlchemy would raise on the duplicate table name.

Keeping Base free of a MetaData (a plain declarative-mixin class) lets the column definitions live in one place while each version still owns an isolated MetaData, so multiple versions of a record can coexist in one process.

Classes

Base

class Base():

Columns shared by every cache record's table — add cross-table fields here.

tags is a nullable JSON dict for arbitrary flat key-value metadata that does not warrant a dedicated column (e.g. {"laterality": "LEFT"} on an inference row). It is nullable with no default so an additive migration can add it to an existing table without a manual backfill.

Each version's declarative base inherits this class, so a column added here is mapped into every version's own isolated MetaData.

Variables

  • static tags : sqlalchemy.orm.base.Mapped[dict[str, typing.Any] | None]