d6a156dcd2
Implements the data model from spec §3 in one go so FC-2/FC-3 don't need schema-adding migrations of their own. Artist is the unified entity for both gallery 'artist:' tags and GallerySubscriber Subscriptions (is_subscription flag). ImageProvenance is many-to-one, enabling the enrich-on-duplicate rule for downloaded content that pHash-matches an existing record. The SigLIP embedding column uses pgvector(1152) for SigLIP-so400m; swapping models in FC-2 will require a column-width migration. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
"""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")
|