init
This commit is contained in:
29
app/models/hackathon.py
Normal file
29
app/models/hackathon.py
Normal file
@@ -0,0 +1,29 @@
|
||||
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"},
|
||||
)
|
||||
Reference in New Issue
Block a user