From 9de7ad5430d645b69632c13778d85d13e8e02e2c Mon Sep 17 00:00:00 2001 From: Andrew Liu Date: Mon, 15 Apr 2024 06:31:54 +0000 Subject: [PATCH] delete emails --- server/models/thread.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/models/thread.py b/server/models/thread.py index 3504526e4..ddecc8008 100644 --- a/server/models/thread.py +++ b/server/models/thread.py @@ -29,7 +29,12 @@ class Thread(db.Model): resolved: Mapped[bool] = mapped_column(nullable=False, default=False) last_email: Mapped[int] = mapped_column(nullable=False) - emails: Mapped[List[Email]] = relationship("Email", back_populates="thread") + emails: Mapped[List[Email]] = relationship( + "Email", + back_populates="thread", + default_factory=list, + cascade="all, delete-orphan", + ) @hybrid_property def first_sender(self):