Model/infrastructure/postgres/landlord_override_enums.py
2026-05-26 15:27:45 +00:00

35 lines
1.2 KiB
Python

"""Shared pgEnum definitions used by every ``landlord_*_overrides`` row class.
The ``override_source`` pgEnum is referenced by both
``landlord_property_type_overrides`` and ``landlord_wall_type_overrides``
(per the Drizzle schema -- see ``landlord_overrides.ts``). Defining it once
here and reusing the same SQLAlchemy ``Enum`` instance across both row
classes keeps SQLModel's metadata coherent: ``create_all`` emits exactly one
``CREATE TYPE override_source`` statement, not two parallel ones colliding
on the same pgEnum name.
"""
from __future__ import annotations
from sqlalchemy import Enum as SAEnum
class OverrideSource:
"""Mirror of the ``override_source`` pgEnum.
Drizzle defines this as ``('classifier', 'user')`` in
``landlord_overrides.ts``. Modelled here as string constants so callers
don't sprinkle magic strings; the column is constrained by Postgres,
and the only Python-side producer (the classifier path) writes the
literal ``OverrideSource.CLASSIFIER``.
"""
CLASSIFIER = "classifier"
USER = "user"
override_source_sa_enum = SAEnum(
OverrideSource.CLASSIFIER,
OverrideSource.USER,
name="override_source",
)