mirror of
https://github.com/sstent/AICyclingCoach.git
synced 2026-01-26 09:02:30 +00:00
15 lines
630 B
Python
15 lines
630 B
Python
from sqlalchemy import Column, Integer, ForeignKey
|
|
from sqlalchemy.dialects.postgresql import JSONB
|
|
from sqlalchemy.orm import relationship
|
|
from .base import BaseModel
|
|
|
|
class Plan(BaseModel):
|
|
__tablename__ = "plans"
|
|
|
|
jsonb_plan = Column(JSONB, nullable=False)
|
|
version = Column(Integer, nullable=False)
|
|
parent_plan_id = Column(Integer, ForeignKey('plans.id'), nullable=True)
|
|
|
|
parent_plan = relationship("Plan", remote_side="Plan.id", backref="child_plans")
|
|
analyses = relationship("Analysis", back_populates="plan")
|
|
workouts = relationship("Workout", back_populates="plan", cascade="all, delete-orphan") |