From cc2b22be6eac960cab71111e593e63e112669686 Mon Sep 17 00:00:00 2001 From: Tim Laszlo Date: Thu, 11 Oct 2012 20:01:29 -0500 Subject: migrate: switch to BatchFetch and bypass save() override --- tools/upgrade/1.3/migrate_dbstats.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools/upgrade') diff --git a/tools/upgrade/1.3/migrate_dbstats.py b/tools/upgrade/1.3/migrate_dbstats.py index d43aa18ad..3ebe764c5 100755 --- a/tools/upgrade/1.3/migrate_dbstats.py +++ b/tools/upgrade/1.3/migrate_dbstats.py @@ -12,6 +12,7 @@ from django.db import connection, transaction, backend from Bcfg2.Server.Admin.Reports import Reports from Bcfg2.Reporting import models as new_models +from Bcfg2.Reporting.utils import BatchFetch from Bcfg2.Server.Reports.reports import models as legacy_models logger = logging.getLogger(__name__) @@ -66,7 +67,7 @@ def _migrate_transaction(inter, entries): cache.set("PROFILE_UNKNOWN", unkown_profile) newint.profile = unkown_profile groups = [unkown_profile] - newint.save() + super(new_models.Interaction, newint).save() if bundles: newint.bundles.add(*bundles) if groups: @@ -222,7 +223,8 @@ def _restructure(): failures = [] int_count = legacy_models.Interaction.objects.count() int_ctr = 0 - for inter in legacy_models.Interaction.objects.select_related().all(): + for inter in BatchFetch(legacy_models.Interaction.objects.\ + select_related().all()): if int_ctr % 1000 == 0: logger.info("Migrated %s of %s interactions" % (int_ctr, int_count)) try: -- cgit v1.2.3-1-g7c22