fix(orm): disambiguate Chat<->Message relationships
All checks were successful
CI / test (push) Successful in 26s

- set explicit foreign_keys for Chat.messages and Message.chat

- resolve mapper initialization error after pinned_message_id fk
This commit is contained in:
2026-03-08 00:31:09 +03:00
parent e1d0375392
commit b5a7d733c6
2 changed files with 6 additions and 2 deletions

View File

@@ -49,7 +49,7 @@ class Message(Base):
nullable=False,
)
chat: Mapped["Chat"] = relationship(back_populates="messages")
chat: Mapped["Chat"] = relationship(back_populates="messages", foreign_keys=[chat_id])
sender: Mapped["User"] = relationship(back_populates="sent_messages")
attachments: Mapped[list["Attachment"]] = relationship(back_populates="message", cascade="all, delete-orphan")