From 63ce533f04727a43514678588c3ce157c31391e0 Mon Sep 17 00:00:00 2001
From: Ben Adida <ben@adida.net>
Date: Wed, 9 Mar 2011 14:52:42 -0800
Subject: [PATCH] tweaked migration to be more efficient

---
 .../0003_v3_1_election_specific_voters_with_passwords.py      | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/helios/migrations/0003_v3_1_election_specific_voters_with_passwords.py b/helios/migrations/0003_v3_1_election_specific_voters_with_passwords.py
index 518356d..008c9c6 100644
--- a/helios/migrations/0003_v3_1_election_specific_voters_with_passwords.py
+++ b/helios/migrations/0003_v3_1_election_specific_voters_with_passwords.py
@@ -16,7 +16,9 @@ class Migration(DataMigration):
             e.datatype = 'legacy/Election'
             e.save()
 
-        for v in orm.Voter.objects.all():
+        # use the .iterator() call to reduce caching and make this more efficient
+        # so as not to trigger a memory error
+        for v in orm.Voter.objects.all().iterator():
             user = orm['auth.User'].objects.get(user_type = v.voter_type, user_id = v.voter_id)
 
             if v.voter_type == 'password':
-- 
GitLab