diff options
Diffstat (limited to 'newspipe/models/article.py')
-rw-r--r-- | newspipe/models/article.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/newspipe/models/article.py b/newspipe/models/article.py index af190053..c26d2530 100644 --- a/newspipe/models/article.py +++ b/newspipe/models/article.py @@ -28,7 +28,7 @@ __license__ = "GPLv3" from datetime import datetime -from sqlalchemy import Index +from sqlalchemy import Index, ForeignKeyConstraint from sqlalchemy.ext.associationproxy import association_proxy from newspipe.bootstrap import db @@ -63,12 +63,18 @@ class Article(db.Model, RightMixin): ) tags = association_proxy("tag_objs", "text") - # indexes __table_args__ = ( - Index('user_id'), - Index('user_id', 'category_id'), - Index('user_id', 'feed_id'), - Index('ix_article_uid_fid_eid', user_id, feed_id, entry_id) + ForeignKeyConstraint([user_id], ['user.id'], ondelete='CASCADE'), + ForeignKeyConstraint([feed_id], ['feed.id'], ondelete='CASCADE'), + ForeignKeyConstraint([category_id], ['category.id'], + ondelete='CASCADE'), + Index('ix_article_eid_cid_uid', user_id, category_id, entry_id), + Index('ix_article_retrdate', retrieved_date), + + Index('user_id'), + Index('user_id', 'category_id'), + Index('user_id', 'feed_id'), + Index('ix_article_uid_fid_eid', user_id, feed_id, entry_id) ) # api whitelists |