Files
FabledCurator/backend/app/models/credential.py
T
bvandeusen d6a156dcd2 feat: define unified schema (Artist, Source, Post, ImageRecord, etc.) and initial migration
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>
2026-05-14 07:34:29 -04:00

25 lines
1009 B
Python

"""Credential — encrypted blob (cookies/token/oauth) scoped per-platform,
not per-source. One Patreon credential serves every Patreon source.
"""
from datetime import datetime
from sqlalchemy import DateTime, Integer, LargeBinary, String, func
from sqlalchemy.orm import Mapped, mapped_column
from .base import Base
class Credential(Base):
__tablename__ = "credential"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
platform: Mapped[str] = mapped_column(String(64), nullable=False, unique=True)
kind: Mapped[str] = mapped_column(String(32), nullable=False) # cookies|token|oauth
encrypted_blob: Mapped[bytes] = mapped_column(LargeBinary, nullable=False)
status: Mapped[str] = mapped_column(String(32), nullable=False, default="active")
captured_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, server_default=func.now()
)
expires_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)