fix(orm): disambiguate Chat<->Message relationships
All checks were successful
CI / test (push) Successful in 26s
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:
@@ -34,7 +34,11 @@ class Chat(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now(), nullable=False)
|
||||
|
||||
members: Mapped[list["ChatMember"]] = relationship(back_populates="chat", cascade="all, delete-orphan")
|
||||
messages: Mapped[list["Message"]] = relationship(back_populates="chat", cascade="all, delete-orphan")
|
||||
messages: Mapped[list["Message"]] = relationship(
|
||||
back_populates="chat",
|
||||
cascade="all, delete-orphan",
|
||||
foreign_keys="Message.chat_id",
|
||||
)
|
||||
|
||||
|
||||
class ChatMember(Base):
|
||||
|
||||
Reference in New Issue
Block a user