delete users and tasks when session was deleted

This commit is contained in:
Анатолий Богомолов 2024-02-01 19:08:48 +10:00
parent f2d29a9523
commit 1d7f87a7a0
1 changed files with 2 additions and 2 deletions

View File

@ -10,9 +10,9 @@ class Session(db.Model):
name: Mapped[str] = mapped_column(unique=True)
authorized: Mapped[bool]
users: Mapped[List[User]] = relationship("User", back_populates="session")
users: Mapped[List[User]] = relationship("User", cascade="all, delete-orphan", back_populates="session")
tasks: Mapped[List[Task]] = relationship("Task", back_populates="session")
tasks: Mapped[List[Task]] = relationship("Task", cascade="all, delete-orphan", back_populates="session")
def has_depending_tasks(self):
tasks = Task.query \