31 lines
1004 B
Python
31 lines
1004 B
Python
"""User watchlists -- section 17, additive (accounts/ratings/watchlist).
|
|||
|
|
|
||
|
|
Polymorphic across movie/series, same shape as Rating -- no value beyond
|
||
|
|
membership, so no extra columns beyond the timestamps."""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import uuid
|
||
|
|
|
||
|
|
from sqlalchemy import ForeignKey, Index, String, UniqueConstraint
|
||
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
||
|
|
|
||
|
|
from app.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
||
|
|
|
||
|
|
|
||
|
|
class WatchlistEntry(Base, UUIDPrimaryKeyMixin, TimestampMixin):
|
||
|
|
__tablename__ = "watchlist_entries"
|
||
|
|
__table_args__ = (
|
||
|
|
UniqueConstraint("user_id", "entity_type", "entity_id"),
|
||
|
|
Index("ix_watchlist_entries_user", "user_id", "entity_type"),
|
||
|
|
)
|
||
|
|
|
||
|
|
user_id: Mapped[uuid.UUID] = mapped_column(
|
||
|
|
ForeignKey("users.id", ondelete="CASCADE"), nullable=False
|
||
|
|
)
|
||
|
|
entity_type: Mapped[str] = mapped_column(String(30), nullable=False)
|
||
|
|
entity_id: Mapped[uuid.UUID] = mapped_column(nullable=False)
|
||
|
|
|
||
|
|
|
||
|
|
__all__ = ["WatchlistEntry"]
|