From 2f18ef5f44da9ccb52cf7b69eab36519354d2556 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Mon, 27 Jan 2025 14:28:34 +0000 Subject: [PATCH] Cascade deleted tracks to playlist_rows and playdates --- app/dbtables.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/dbtables.py b/app/dbtables.py index 1d31e4f..808c301 100644 --- a/app/dbtables.py +++ b/app/dbtables.py @@ -147,12 +147,15 @@ class TracksTable(Model): title: Mapped[str] = mapped_column(String(256), index=True) playlistrows: Mapped[list[PlaylistRowsTable]] = relationship( - "PlaylistRowsTable", back_populates="track" + "PlaylistRowsTable", + back_populates="track", + cascade="all, delete-orphan", ) playlists = association_proxy("playlistrows", "playlist") playdates: Mapped[list[PlaydatesTable]] = relationship( "PlaydatesTable", back_populates="track", + cascade="all, delete-orphan", lazy="joined", )