github-actions[bot]
Automated Deploy: 0d5b759d8eca219a25b3ab717925e73a66bbf4a4
2756f0f
Raw History Blame Contribute Delete
780 Bytes
import uuid
from sqlalchemy import CheckConstraint, ForeignKey, String
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from app.common.base_model import Base, IdMixin, TimestampMixin
class Team(IdMixin, TimestampMixin, Base):
"""One team per coach. The coach's display name is accounts.name."""
__tablename__ = "teams"
__table_args__ = (CheckConstraint("coaching IN ('h', 'p', 'both')", name="coaching"),)
code: Mapped[str] = mapped_column(String(8), unique=True)
name: Mapped[str] = mapped_column(String(60))
coach_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), ForeignKey("accounts.id", ondelete="CASCADE"), unique=True
)
coaching: Mapped[str] = mapped_column(String(4))