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:
parent
3acb880fc5
commit
cd434b3a19
1 changed files with 10 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue