File size: 780 Bytes
2756f0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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))