feat: define all 8 SQLModel tables
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
31
app/models/workout_session.py
Normal file
31
app/models/workout_session.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""WorkoutSession model for tracking completed workout sessions.
|
||||
|
||||
Each session ties a user to a workout day on a specific date.
|
||||
"""
|
||||
|
||||
import datetime as dt
|
||||
from typing import Optional
|
||||
|
||||
from sqlmodel import Field, SQLModel
|
||||
|
||||
|
||||
class WorkoutSession(SQLModel, table=True):
|
||||
"""A completed workout session.
|
||||
|
||||
Attributes:
|
||||
id: Primary key, auto-incremented.
|
||||
user_id: FK to users table.
|
||||
workout_day_id: FK to workout_days table.
|
||||
date: The date the workout was performed.
|
||||
notes: Optional free-text notes about the session.
|
||||
created_at: Timestamp when the record was created.
|
||||
"""
|
||||
|
||||
__tablename__ = "workout_sessions"
|
||||
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
user_id: int = Field(foreign_key="users.id", index=True)
|
||||
workout_day_id: int = Field(foreign_key="workout_days.id")
|
||||
date: dt.date = Field(default_factory=dt.date.today)
|
||||
notes: Optional[str] = Field(default=None)
|
||||
created_at: dt.datetime = Field(default_factory=dt.datetime.utcnow)
|
||||
Reference in New Issue
Block a user