Added cascade all, delete-orphan to ProcessingMetaData
authorJoar Wandborg <git@wandborg.com>
Thu, 27 Sep 2012 09:59:17 +0000 (11:59 +0200)
committerJoar Wandborg <git@wandborg.com>
Thu, 27 Sep 2012 09:59:17 +0000 (11:59 +0200)
mediagoblin/db/sql/models.py

index 01694725ff53a3d97289e6f5fd5877ab912c9130..b48c1fbea2ed0b854ba5d62fa04acdbe14841176 100644 (file)
@@ -22,10 +22,10 @@ TODO: indexes on foreignkeys, where useful.
 import datetime
 import sys
 
-from sqlalchemy import (
-    Column, Integer, Unicode, UnicodeText, DateTime, Boolean, ForeignKey,
-    UniqueConstraint, PrimaryKeyConstraint, SmallInteger)
-from sqlalchemy.orm import relationship
+from sqlalchemy import Column, Integer, Unicode, UnicodeText, DateTime, \
+        Boolean, ForeignKey, UniqueConstraint, PrimaryKeyConstraint, \
+        SmallInteger
+from sqlalchemy.orm import relationship, backref
 from sqlalchemy.orm.collections import attribute_mapped_collection
 from sqlalchemy.sql.expression import desc
 from sqlalchemy.ext.associationproxy import association_proxy
@@ -418,7 +418,9 @@ class ProcessingMetaData(Base):
     id = Column(Integer, primary_key=True)
     media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=False,
             index=True)
-    media_entry = relationship(MediaEntry, backref='processing_metadata')
+    media_entry = relationship(MediaEntry,
+            backref=backref('processing_metadata',
+                cascade='all, delete-orphan'))
     callback_url = Column(Unicode)
 
     @property