"""Artist — unified entity that is both the gallery's ``artist:`` tag concept and GallerySubscriber's Subscription. ``is_subscription`` is True if any Sources are attached. """ from datetime import datetime from sqlalchemy import Boolean, DateTime, Integer, String, Text, func from sqlalchemy.orm import Mapped, mapped_column, relationship from .base import Base class Artist(Base): __tablename__ = "artist" id: Mapped[int] = mapped_column(Integer, primary_key=True) name: Mapped[str] = mapped_column(String(255), nullable=False, unique=True) slug: Mapped[str] = mapped_column(String(255), nullable=False, unique=True) notes: Mapped[str | None] = mapped_column(Text, nullable=True) # True once a Source is attached; flips false if all sources removed. is_subscription: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False) # Per-artist scheduling overrides; null means "use global default". auto_check: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True) check_interval_seconds: Mapped[int | None] = mapped_column(Integer, nullable=True) created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), nullable=False, server_default=func.now() ) sources = relationship("Source", back_populates="artist", cascade="all, delete-orphan")