from __future__ import annotations

from datetime import date

from sqlalchemy import Boolean, Date, Integer, String
from sqlalchemy.orm import Mapped, mapped_column

from .base import Base


class Tenure(Base):
    """SQLAlchemy ORM model for Tenures"""

    __tablename__ = "Tenures"

    # Composite Primary Key
    Player: Mapped[str] = mapped_column(String, primary_key=True)
    Team: Mapped[str] = mapped_column(String, primary_key=True)
    DateJoin: Mapped[date] = mapped_column(Date, primary_key=True)

    # Date Information
    DateLeave: Mapped[date | None] = mapped_column(Date, default=None)
    Duration: Mapped[int | None] = mapped_column(Integer, default=None)

    # Contract Information
    ContractEnd: Mapped[str | None] = mapped_column(String, default=None)

    # Roster Change References
    RosterChangeIdJoin: Mapped[str | None] = mapped_column(String, default=None)
    RosterChangeIdLeave: Mapped[str | None] = mapped_column(String, default=None)

    # Player Status at Leave
    ResidencyLeave: Mapped[str | None] = mapped_column(String, default=None)
    NameLeave: Mapped[str | None] = mapped_column(String, default=None)

    # Next Team Information
    NextTeam: Mapped[str | None] = mapped_column(String, default=None)
    NextIsRetired: Mapped[bool | None] = mapped_column(Boolean, default=None)
    NextIsWildrift: Mapped[bool | None] = mapped_column(Boolean, default=None)
    NextIsDeceased: Mapped[bool | None] = mapped_column(Boolean, default=None)

    # Status
    IsCurrent: Mapped[bool | None] = mapped_column(Boolean, default=None)
