Files
NixReaperandClaude Sonnet 5 c20df1c503
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
Initial Aurora Core 0.1 implementation
Production-grade media metadata backend per docs/aurora-core-spec.md:
Aurora-owned UUIDv7 identity system, normalized movie/TV/people/credits
schema, provider abstraction with a TMDb adapter, an idempotent async
ingestion pipeline (normalize -> match -> upsert -> provenance), a
Postgres FTS/trigram search layer, a stateless FastAPI v1 API with
Redis caching/rate-limiting, arq workers, dev/prod Docker Compose
topologies, unit + integration + load tests, CI, and architecture/
database/API/ERD documentation.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
2026-09-04 17:34:03 -05:00

51 lines
1.8 KiB
Python

"""Flexible, normalized credit system (section 7).
A `Credit` links a `Person` to any media entity (movie, series, episode)
with a department/job/character, instead of duplicating cast/crew as text
blobs on the media tables.
"""
from __future__ import annotations
import uuid
from sqlalchemy import ForeignKey, Index, Integer, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
from app.models.person import Person
from app.models.provider import Provider
class Credit(Base, UUIDPrimaryKeyMixin, TimestampMixin):
__tablename__ = "credits"
__table_args__ = (Index("ix_credits_entity", "entity_type", "entity_id"),)
person_id: Mapped[uuid.UUID] = mapped_column(
ForeignKey("people.id", ondelete="CASCADE"), nullable=False
)
# Polymorphic target: "movie", "series", "episode".
entity_type: Mapped[str] = mapped_column(String(30), nullable=False)
entity_id: Mapped[uuid.UUID] = mapped_column(nullable=False)
# "Acting", "Directing", "Writing", "Production", "Camera", "Sound",
# "Editing", "Art", "Costume & Make-Up", "Crew", "Creator", ...
department: Mapped[str] = mapped_column(String(100), nullable=False)
job: Mapped[str | None] = mapped_column(String(150), nullable=True)
character: Mapped[str | None] = mapped_column(String(300), nullable=True)
billing_order: Mapped[int | None] = mapped_column(Integer, nullable=True)
is_guest: Mapped[bool] = mapped_column(default=False, nullable=False)
episode_count: Mapped[int | None] = mapped_column(Integer, nullable=True)
provider_id: Mapped[uuid.UUID | None] = mapped_column(
ForeignKey("providers.id", ondelete="SET NULL"), nullable=True
)
person: Mapped[Person] = relationship()
provider: Mapped[Provider | None] = relationship()
__all__ = ["Credit"]