From e65f2deb2bf03fe88e88f494111979c4e1ea205b Mon Sep 17 00:00:00 2001 From: Mathias Behrle Date: Fri, 30 Jan 2015 03:27:09 +0100 Subject: [PATCH 1/2] 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): From 3076c0d8a57ee4f6175d1d95442633e8408d37e9 Mon Sep 17 00:00:00 2001 From: Mathias Behrle Date: Fri, 30 Jan 2015 04:14:06 +0100 Subject: [PATCH 2/2] Migrate actstream before deleting stale document types. (Issue #153) --- .../documents/south_migrations/0031_remove_orphan_documents.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mayan/apps/documents/south_migrations/0031_remove_orphan_documents.py b/mayan/apps/documents/south_migrations/0031_remove_orphan_documents.py index d1293e409f..7b2d4ed48e 100644 --- a/mayan/apps/documents/south_migrations/0031_remove_orphan_documents.py +++ b/mayan/apps/documents/south_migrations/0031_remove_orphan_documents.py @@ -5,6 +5,9 @@ from django.db import models class Migration(DataMigration): + depends_on = ( + ('actstream', '0007_auto__add_field_follow_started'), + ) def forwards(self, orm): "Write your forwards methods here."