Skip to main content

base

Shared building blocks for versioned cache types.

Each cache type lives in its own types/<name>/v<N>/ package with a local SQLAlchemy DeclarativeBase (its own MetaData). This is deliberate: a single shared Base cannot hold two versions of the same table (both map the same __tablename__ and SQLAlchemy rejects duplicate table names within one MetaData). Keeping each version's metadata separate lets v1 and v2 of a type coexist in the same process.

This module holds only the cross-version infrastructure that must be shared without reintroducing a global metadata:

  • the type_versions tracking table — infrastructure (not itself a versioned type) recording the physical version each type's table has been migrated to. It lives on its own dedicated MetaData so it never collides with a type's metadata.

Note the shared tags column is intentionally NOT centralised here. A single shared declarative base would force one MetaData, and the registry imports every v* package, so v1 and v2 of the same type would both map __tablename__ and collide. Instead each version's schema.py declares its own Base(DeclarativeBase) carrying the tags column and its ORM classes inherit it — isolated metadata, single inheritance, no shared base.