From e65f2deb2bf03fe88e88f494111979c4e1ea205b Mon Sep 17 00:00:00 2001 From: Mathias Behrle Date: Fri, 30 Jan 2015 03:27:09 +0100 Subject: [PATCH] Don't try to migrate defective documents. This change hardens the migration to not fail on documents without doucument version from a failed import ('Uninitialized document'). --- .../documents/south_migrations/0027_move_filename_to_label.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mayan/apps/documents/south_migrations/0027_move_filename_to_label.py b/mayan/apps/documents/south_migrations/0027_move_filename_to_label.py index 5d42cb11b3..8d8b810982 100644 --- a/mayan/apps/documents/south_migrations/0027_move_filename_to_label.py +++ b/mayan/apps/documents/south_migrations/0027_move_filename_to_label.py @@ -15,7 +15,8 @@ class Migration(DataMigration): # NOTE: This migration take a while. Maybe the use of F objects could # improve it. for document in orm.Document.objects.all(): - document.label = document.versions.order_by('timestamp').last().filename + if document.versions.order_by('timestamp').last(): + document.label = document.versions.order_by('timestamp').last().filename document.save() def backwards(self, orm):