diff --git a/thermal_events/strike_line_descriptor.py b/thermal_events/strike_line_descriptor.py index bc0ac33..bdedc8e 100644 --- a/thermal_events/strike_line_descriptor.py +++ b/thermal_events/strike_line_descriptor.py @@ -29,7 +29,9 @@ class StrikeLineDescriptor(Base): thermal_event_instance_id = Column( BigIntegerType, - ForeignKey("thermal_events_instances.id"), + ForeignKey( + "thermal_events_instances.id", onupdate="CASCADE", ondelete="CASCADE" + ), index=True, comment="The id of the thermal event instance described by the descriptor", ) @@ -56,6 +58,7 @@ class StrikeLineDescriptor(Base): instance = relationship( "ThermalEventInstance", lazy="subquery", + passive_deletes=True, back_populates="strike_line_descriptor", ) diff --git a/thermal_events/thermal_event_instance.py b/thermal_events/thermal_event_instance.py index a75b8f5..83073ab 100644 --- a/thermal_events/thermal_event_instance.py +++ b/thermal_events/thermal_event_instance.py @@ -256,7 +256,9 @@ class ThermalEventInstance(Base): ) strike_line_descriptor = relationship( - "StrikeLineDescriptor", back_populates="instance", cascade="all, delete-orphan" + "StrikeLineDescriptor", + back_populates="instance", + cascade="all, delete, delete-orphan", ) _buffer = None # image bugger used to draw polygons