diff --git a/backend/innercontext/models/health.py b/backend/innercontext/models/health.py index 2aac33d..419fb11 100644 --- a/backend/innercontext/models/health.py +++ b/backend/innercontext/models/health.py @@ -36,7 +36,10 @@ class MedicationEntry(SQLModel, table=True): ), ) - usage_history: list["MedicationUsage"] = Relationship(back_populates="medication") + usage_history: list["MedicationUsage"] = Relationship( + back_populates="medication", + sa_relationship_kwargs={"cascade": "all, delete-orphan"}, + ) class MedicationUsage(SQLModel, table=True): diff --git a/backend/innercontext/models/routine.py b/backend/innercontext/models/routine.py index d44a20a..cdd5796 100644 --- a/backend/innercontext/models/routine.py +++ b/backend/innercontext/models/routine.py @@ -38,7 +38,10 @@ class Routine(SQLModel, table=True): ), ) - steps: List["RoutineStep"] = Relationship(back_populates="routine") + steps: List["RoutineStep"] = Relationship( + back_populates="routine", + sa_relationship_kwargs={"cascade": "all, delete-orphan"}, + ) class GroomingSchedule(SQLModel, table=True):