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').
This commit is contained in:
Mathias Behrle
2015-01-30 03:27:09 +01:00
parent 991017cf38
commit e65f2deb2b

View File

@@ -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):