From 7d1153a8ebe34d5180bf872c1c3821a60878090e Mon Sep 17 00:00:00 2001 From: Adam Coddington Date: Tue, 11 Jun 2013 22:00:39 -0700 Subject: [PATCH] Use a predictable ordering. --- .../migrations/0015_rebuild_message_associations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_mailbox/migrations/0015_rebuild_message_associations.py b/django_mailbox/migrations/0015_rebuild_message_associations.py index 5d952bf..783cd9e 100644 --- a/django_mailbox/migrations/0015_rebuild_message_associations.py +++ b/django_mailbox/migrations/0015_rebuild_message_associations.py @@ -18,7 +18,7 @@ class Migration(SchemaMigration): attachments_without_messages = orm[ 'django_mailbox.messageattachment' - ].objects.filter(message=None) + ].objects.filter(message=None).order_by('id') if attachments_without_messages.count() < 1: return @@ -29,7 +29,7 @@ class Migration(SchemaMigration): md5.update(chunk) ATTACHMENT_HASH_MAP[md5.hexdigest()] = attachment.pk - for message_record in orm['django_mailbox.message'].objects.all(): + for message_record in orm['django_mailbox.message'].objects.all().order_by('id'): message = email.message_from_string(message_record.body) if message.is_multipart(): for part in message.walk():