From aee6f6d34198218fb9bd1da6d71f2bffb592449c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 4 Aug 2017 15:14:48 -0500 Subject: [PATCH] Auto-delete child objects when deleting Client or Probe object although if there are a lot of readings, this will still suck... --- rattail_tempmon/db/model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rattail_tempmon/db/model.py b/rattail_tempmon/db/model.py index 485e665..ba7e63a 100644 --- a/rattail_tempmon/db/model.py +++ b/rattail_tempmon/db/model.py @@ -91,6 +91,7 @@ class Probe(Base): """, backref=orm.backref( 'probes', + cascade='all, delete-orphan', doc=""" List of probes connected to this client. """)) @@ -141,7 +142,10 @@ class Reading(Base): Probe, doc=""" Reference to the tempmon probe which took this reading. - """) + """, + backref=orm.backref( + 'readings', + cascade='all, delete-orphan')) taken = sa.Column(sa.DateTime(), nullable=False, default=datetime.datetime.utcnow) degrees_f = sa.Column(sa.Numeric(precision=7, scale=4), nullable=False)