21 lines
651 B
Python
21 lines
651 B
Python
from sqlmodel import SQLModel, Field, Relationship
|
|
|
|
|
|
class Team(SQLModel, table=True):
|
|
__tablename__ = "teams"
|
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
|
name: str = Field(max_length=100)
|
|
hackathon_id: int = Field(foreign_key="hackathons.id")
|
|
|
|
# Relationships
|
|
hackathon: "Hackathon" = Relationship(back_populates="teams")
|
|
members: list["TeamMember"] = Relationship(
|
|
back_populates="team",
|
|
sa_relationship_kwargs={"cascade": "all, delete"},
|
|
)
|
|
submissions: list["Submission"] = Relationship(
|
|
back_populates="team",
|
|
sa_relationship_kwargs={"cascade": "all, delete"},
|
|
)
|