summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvangelos Foutras <foutrelis@gmail.com>2010-02-01 05:52:57 +0200
committerDan McGee <dan@archlinux.org>2010-02-05 17:04:36 -0600
commitb8976f60fd306483071a7f3c50df6226936ba2ee (patch)
tree516afa6d7989b5afbe08912fb641f8d8514d8f26
parentb2f33457f646c9340059d4ab02b5b7280dbeff9d (diff)
Make the maintainer migration less stupidrelease_2010-02-07
Why issue lots of UPDATE queries when you can only issue one? My fail. Signed-off-by: Evangelos Foutras <foutrelis@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--main/migrations/0003_migrate_maintainer.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/main/migrations/0003_migrate_maintainer.py b/main/migrations/0003_migrate_maintainer.py
index ec70b895..8d759271 100644
--- a/main/migrations/0003_migrate_maintainer.py
+++ b/main/migrations/0003_migrate_maintainer.py
@@ -8,17 +8,13 @@ class Migration:
no_dry_run = True
def forwards(self, orm):
- for pkg in Package.objects.all():
- if pkg.maintainer_id == 0:
- pkg.maintainer = None
- pkg.save()
+ Package.objects.filter(maintainer=0).update(maintainer=None)
def backwards(self, orm):
- for pkg in Package.objects.all():
- if not pkg.maintainer:
- pkg.maintainer_id = 0
- pkg.save()
+ # This will fail if foreign keys are in effect. Let's hope we'll
+ # never have to go backwards. :P
+ Package.objects.filter(maintainer=None).update(maintainer=0)
models = {