core (memory/sqla_mapping): delete-orphan in History:

add `cascade=delete-orphan` to History's `messages`, `subjects` and `thread`, to make
modification of those attributes easier.
This commit is contained in:
Goffi 2023-11-28 17:35:20 +01:00
commit 445d5c088e

View file

@ -299,10 +299,24 @@ class History(Base):
extra = Column(LegacyPickle)
profile = relationship("Profile")
messages = relationship("Message", backref="history", passive_deletes=True)
subjects = relationship("Subject", backref="history", passive_deletes=True)
messages = relationship(
"Message",
backref="history",
cascade="all, delete-orphan",
passive_deletes=True
)
subjects = relationship(
"Subject",
backref="history",
cascade="all, delete-orphan",
passive_deletes=True
)
thread = relationship(
"Thread", uselist=False, back_populates="history", passive_deletes=True
"Thread",
uselist=False,
back_populates="history",
cascade="all, delete-orphan",
passive_deletes=True
)
__mapper_args__ = {"version_id_col": version_id}