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
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]>
63 lines
2.2 KiB
Python
63 lines
2.2 KiB
Python
"""Production companies, studios, networks, and distributors.
|
|
|
|
Modeled as a single `Company` table distinguished by `company_type` per the
|
|
spec (section 8), rather than a separate Network entity — a TV network and a
|
|
studio share the same shape (name, logo, country, parent company)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
from sqlalchemy import ForeignKey, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.models.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
from app.models.enums import CompanyType
|
|
|
|
|
|
class Company(Base, UUIDPrimaryKeyMixin, TimestampMixin):
|
|
__tablename__ = "companies"
|
|
|
|
name: Mapped[str] = mapped_column(String(300), nullable=False, index=True)
|
|
company_type: Mapped[CompanyType] = mapped_column(
|
|
default=CompanyType.PRODUCTION_COMPANY, nullable=False
|
|
)
|
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
country_code: Mapped[str | None] = mapped_column(
|
|
ForeignKey("countries.code"), nullable=True
|
|
)
|
|
headquarters: Mapped[str | None] = mapped_column(String(300), nullable=True)
|
|
homepage: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
|
parent_company_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
ForeignKey("companies.id", ondelete="SET NULL"), nullable=True
|
|
)
|
|
|
|
parent_company: Mapped[Company | None] = relationship(remote_side="Company.id")
|
|
|
|
|
|
class MovieCompany(Base):
|
|
__tablename__ = "movie_companies"
|
|
|
|
movie_id: Mapped[uuid.UUID] = mapped_column(
|
|
ForeignKey("movies.id", ondelete="CASCADE"), primary_key=True
|
|
)
|
|
company_id: Mapped[uuid.UUID] = mapped_column(
|
|
ForeignKey("companies.id", ondelete="CASCADE"), primary_key=True
|
|
)
|
|
role: Mapped[str | None] = mapped_column(String(50), nullable=True)
|
|
|
|
|
|
class SeriesCompany(Base):
|
|
__tablename__ = "series_companies"
|
|
|
|
series_id: Mapped[uuid.UUID] = mapped_column(
|
|
ForeignKey("series.id", ondelete="CASCADE"), primary_key=True
|
|
)
|
|
company_id: Mapped[uuid.UUID] = mapped_column(
|
|
ForeignKey("companies.id", ondelete="CASCADE"), primary_key=True
|
|
)
|
|
role: Mapped[str | None] = mapped_column(String(50), nullable=True)
|
|
|
|
|
|
__all__ = ["Company", "MovieCompany", "SeriesCompany"]
|