From bba26593a3351d9a1cd20b2e182110e9d08329b0 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 7 Jul 2021 08:18:09 +0200 Subject: updated foreign_keys for bookmarfs in tag.py --- newspipe/models/bookmark.py | 3 +-- newspipe/models/feed.py | 4 +++- newspipe/models/tag.py | 6 ++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/newspipe/models/bookmark.py b/newspipe/models/bookmark.py index a008ff07..05c5da58 100644 --- a/newspipe/models/bookmark.py +++ b/newspipe/models/bookmark.py @@ -62,8 +62,7 @@ class Bookmark(db.Model, RightMixin): tags = db.relationship( "BookmarkTag", back_populates="bookmark", - cascade="all,delete-orphan", - lazy=False, + cascade="all, delete-orphan", foreign_keys="[BookmarkTag.bookmark_id]", ) tags_proxy = association_proxy("tags", "text") diff --git a/newspipe/models/feed.py b/newspipe/models/feed.py index 7e8d92ae..1d3893fb 100644 --- a/newspipe/models/feed.py +++ b/newspipe/models/feed.py @@ -60,10 +60,12 @@ class Feed(db.Model, RightMixin): last_error = db.Column(db.String(), default="") error_count = db.Column(db.Integer(), default=0) - # relationship + # foreign keys icon_url = db.Column(db.String(), db.ForeignKey("icon.url"), default=None) user_id = db.Column(db.Integer(), db.ForeignKey("user.id")) category_id = db.Column(db.Integer(), db.ForeignKey("category.id")) + + # relationship articles = db.relationship( Article, backref="source", diff --git a/newspipe/models/tag.py b/newspipe/models/tag.py index 02a6d29f..0c961830 100644 --- a/newspipe/models/tag.py +++ b/newspipe/models/tag.py @@ -33,10 +33,8 @@ class BookmarkTag(db.Model): text = db.Column(db.String, unique=False) # foreign keys - user_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="CASCADE")) - bookmark_id = db.Column( - db.Integer, db.ForeignKey("bookmark.id", ondelete="CASCADE") - ) + user_id = db.Column(db.Integer, db.ForeignKey("user.id")) + bookmark_id = db.Column(db.Integer, db.ForeignKey("bookmark.id")) # relationships bookmark = db.relationship( -- cgit