30 lines
921 B
Python
30 lines
921 B
Python
from datetime import datetime
|
|
|
|
from sqlmodel import SQLModel, Field, Relationship
|
|
|
|
|
|
class Hackathon(SQLModel, table=True):
|
|
__tablename__ = "hackathons"
|
|
|
|
id: int | None = Field(default=None, primary_key=True)
|
|
title: str = Field(max_length=200)
|
|
description: str
|
|
start_date: datetime
|
|
end_date: datetime
|
|
organizer_id: int = Field(foreign_key="users.id")
|
|
|
|
# Relationships
|
|
organizer: "User" = Relationship(back_populates="organized_hackathons")
|
|
participants: list["HackathonParticipant"] = Relationship(
|
|
back_populates="hackathon",
|
|
sa_relationship_kwargs={"cascade": "all, delete"},
|
|
)
|
|
teams: list["Team"] = Relationship(
|
|
back_populates="hackathon",
|
|
sa_relationship_kwargs={"cascade": "all, delete"},
|
|
)
|
|
tasks: list["Task"] = Relationship(
|
|
back_populates="hackathon",
|
|
sa_relationship_kwargs={"cascade": "all, delete"},
|
|
)
|