Auto-delete child objects when deleting Client or Probe object

although if there are a lot of readings, this will still suck...
This commit is contained in:
Lance Edgar 2017-08-04 15:14:48 -05:00
parent 7c7dc56f8d
commit aee6f6d341

View file

@ -91,6 +91,7 @@ class Probe(Base):
""", """,
backref=orm.backref( backref=orm.backref(
'probes', 'probes',
cascade='all, delete-orphan',
doc=""" doc="""
List of probes connected to this client. List of probes connected to this client.
""")) """))
@ -141,7 +142,10 @@ class Reading(Base):
Probe, Probe,
doc=""" doc="""
Reference to the tempmon probe which took this reading. 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) taken = sa.Column(sa.DateTime(), nullable=False, default=datetime.datetime.utcnow)
degrees_f = sa.Column(sa.Numeric(precision=7, scale=4), nullable=False) degrees_f = sa.Column(sa.Numeric(precision=7, scale=4), nullable=False)