Add fail_error and fail_metadata fields to MediaEntry and relevant migration
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 13 Aug 2011 12:48:34 +0000 (07:48 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sat, 13 Aug 2011 12:48:34 +0000 (07:48 -0500)
mediagoblin/db/migrations.py
mediagoblin/db/models.py

index 171b5c8328fd8d2cc1eb21a7856526c68547d5a5..5456b248ed663151615171c31e1488a77172b21d 100644 (file)
@@ -75,3 +75,20 @@ def mediaentry_add_queued_task_id(database):
         {'queued_task_id': {'$exists': False}},
         {'$set': {'queued_task_id': None}},
         multi=True)
+
+
+@RegisterMigration(5)
+def mediaentry_add_fail_error_and_metadata(database):
+    """
+    Add 'fail_error' and 'fail_metadata' fields to media entries
+    """
+    collection = database['media_entries']
+    collection.update(
+        {'fail_error': {'$exists': False}},
+        {'$set': {'fail_error': None}},
+        multi=True)
+    
+    collection.update(
+        {'fail_metadata': {'$exists': False}},
+        {'$set': {'fail_metadata': {}}},
+        multi=True)
index 0dcb6ce888ff39006da10bcdf0c5685ae108c526..982883d758484c6f78aa2b909adb3cc4bc0f372c 100644 (file)
@@ -171,6 +171,9 @@ class MediaEntry(Document):
      - attachment_files: A list of "attachment" files, ones that aren't
        critical to this piece of media but may be usefully relevant to people
        viewing the work.  (currently unused.)
+
+     - fail_error: path to the exception raised 
+     - fail_metadata: 
     """
     __collection__ = 'media_entries'
 
@@ -197,7 +200,12 @@ class MediaEntry(Document):
 
         # The following should be lists of lists, in appropriate file
         # record form
-        'attachment_files': list}
+        'attachment_files': list,
+
+        # If things go badly in processing things, we'll store that
+        # data here
+        'fail_error': unicode,
+        'fail_metadata': dict}
 
     required_fields = [
         'uploader', 'created', 'media_type', 'slug']