github-actions[bot]
Automated Deploy: 3ea2037ab7d55d5b498f7e2ea0336818fc24f725
fe40b87
Raw History Blame Contribute Delete
1.51 kB
import uuid
from datetime import date
from sqlalchemy import CheckConstraint, Date, ForeignKey, Index, SmallInteger, String, text
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from app.common.base_model import Base, CreatedAtMixin, IdMixin
def _owner() -> Mapped[uuid.UUID]:
return mapped_column(UUID(as_uuid=True), ForeignKey("accounts.id", ondelete="CASCADE"))
class ArmOuting(IdMixin, CreatedAtMixin, Base):
"""A game pitch count the player logged. local_date is the player's calendar day."""
__tablename__ = "arm_outings"
__table_args__ = (
CheckConstraint("pitches BETWEEN 1 AND 200", name="pitches"),
CheckConstraint("source IN ('game')", name="source"),
Index("ix_arm_outings_owner_id_local_date", "owner_id", text("local_date DESC")),
)
owner_id: Mapped[uuid.UUID] = _owner()
local_date: Mapped[date] = mapped_column(Date)
pitches: Mapped[int] = mapped_column(SmallInteger)
source: Mapped[str] = mapped_column(String(8), server_default="game")
class ArmFeel(IdMixin, CreatedAtMixin, Base):
"""Arm-feel reports; the newest one is the current feel."""
__tablename__ = "arm_feel_events"
__table_args__ = (
CheckConstraint("feel IN ('sore', 'tight', 'good')", name="feel"),
Index("ix_arm_feel_events_owner_id_created_at", "owner_id", text("created_at DESC")),
)
owner_id: Mapped[uuid.UUID] = _owner()
feel: Mapped[str] = mapped_column(String(8))