6d67e6e987
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
"""Source — a platform-specific URL owned by an Artist (e.g., a Patreon URL).
|
|
|
|
Multiple sources per artist support creators with cross-platform presence.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import JSON, Boolean, DateTime, ForeignKey, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from .base import Base
|
|
|
|
|
|
class Source(Base):
|
|
__tablename__ = "source"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
artist_id: Mapped[int] = mapped_column(
|
|
ForeignKey("artist.id", ondelete="CASCADE"), nullable=False, index=True
|
|
)
|
|
platform: Mapped[str] = mapped_column(String(64), nullable=False)
|
|
url: Mapped[str] = mapped_column(Text, nullable=False)
|
|
enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
|
|
|
config_overrides: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
|
|
|
last_checked_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
last_error: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
check_interval_override: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
consecutive_failures: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
|
|
|
|
artist = relationship("Artist", back_populates="sources")
|