diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2012-10-11 20:01:29 -0500 |
---|---|---|
committer | Tim Laszlo <tim.laszlo@gmail.com> | 2012-10-11 20:01:29 -0500 |
commit | cc2b22be6eac960cab71111e593e63e112669686 (patch) | |
tree | a45b1058e30b5b9c5c0b35bb1943354b5d49b6c1 /tools/upgrade/1.3/migrate_dbstats.py | |
parent | aa77983b6384f0f4ec84e4918a9d10b1df99b4e7 (diff) | |
download | bcfg2-cc2b22be6eac960cab71111e593e63e112669686.tar.gz bcfg2-cc2b22be6eac960cab71111e593e63e112669686.tar.bz2 bcfg2-cc2b22be6eac960cab71111e593e63e112669686.zip |
migrate: switch to BatchFetch and bypass save() override
Diffstat (limited to 'tools/upgrade/1.3/migrate_dbstats.py')
-rwxr-xr-x | tools/upgrade/1.3/migrate_dbstats.py | 6 |
1 files changed, 4 insertions, 2 deletions
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: |