Make User a proper SQLAlchemy model so kds_course_bumps FK resolves

kds_course_bumps.bumped_by_user_id references users.id — SQLAlchemy needs
the User model in Base.metadata to resolve this at startup. Route handlers
still receive a SimpleNamespace from auth.py at runtime.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-12 12:38:47 +00:00
parent 3acb880fc5
commit cd434b3a19

View file

@ -21,11 +21,13 @@ class Kitchen(Base):
)
class User:
"""Type stub for Depends(get_current_user) annotations — runtime is a SimpleNamespace."""
id: int
email: str
name: str
is_admin: bool
kitchen_id: int
caps: list
class User(Base):
"""Minimal SQLAlchemy model so FKs referencing users.id resolve at startup.
Route handlers receive a SimpleNamespace from auth.py at runtime, not instances
of this class this definition exists only for SQLAlchemy FK resolution."""
__tablename__ = "users"
id: Mapped[int] = mapped_column(primary_key=True, index=True)
email: Mapped[str] = mapped_column(String(255), nullable=False)
name: Mapped[str | None] = mapped_column(String(255), nullable=True)
is_admin: Mapped[bool] = mapped_column(default=False)