fix: add explicit foreign_keys to all branching model relationships

SQLAlchemy can't resolve ambiguous FK paths when tables have
multiple cross-references. All relationships now specify foreign_keys.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-24 15:20:46 +00:00
parent 9813c96ca2
commit cb758ad4fd
3 changed files with 6 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ class SessionHandoff(Base):
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))
# Relationships
session: Mapped["AISession"] = relationship("AISession")
session: Mapped["AISession"] = relationship("AISession", foreign_keys=[session_id])
handed_off_by_user: Mapped["User"] = relationship("User", foreign_keys=[handed_off_by])
source_branch: Mapped[Optional["SessionBranch"]] = relationship("SessionBranch")
source_branch: Mapped[Optional["SessionBranch"]] = relationship("SessionBranch", foreign_keys=[source_branch_id])
claimed_by_user: Mapped[Optional["User"]] = relationship("User", foreign_keys=[claimed_by])