27 lines
902 B
Python
27 lines
902 B
Python
from sqlmodel import SQLModel, Field, Relationship
|
|
|
|
|
|
class User(SQLModel, table=True):
|
|
__tablename__ = "users"
|
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
|
name: str = Field(max_length=100)
|
|
email: str = Field(max_length=255, unique=True, index=True)
|
|
phone: str | None = Field(default=None, max_length=20)
|
|
hashed_password: str
|
|
is_organizer: bool = Field(default=False)
|
|
|
|
# Relationships
|
|
organized_hackathons: list["Hackathon"] = Relationship(
|
|
back_populates="organizer",
|
|
sa_relationship_kwargs={"cascade": "all, delete"},
|
|
)
|
|
registrations: list["HackathonParticipant"] = Relationship(
|
|
back_populates="user",
|
|
sa_relationship_kwargs={"cascade": "all, delete"},
|
|
)
|
|
team_memberships: list["TeamMember"] = Relationship(
|
|
back_populates="user",
|
|
sa_relationship_kwargs={"cascade": "all, delete"},
|
|
)
|