From 6fe08cd68901e698f4a0741e177354a45c753b46 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 29 Mar 2011 17:39:59 -0500 Subject: Utilize Django 1.3 'on_delete' feature on several foreign keys The most important one here is PROTECT to keep people from making bone-headed plays and deleting an Arch or Repo and every package along with it. We can use this in a few other places, as well as some carefully placed SET_NULL indicators. Note that nothing here pushes deletion responsibilities down to the database, although that will probably happen in a future commit. Signed-off-by: Dan McGee --- mirrors/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mirrors') diff --git a/mirrors/models.py b/mirrors/models.py index dce17b5..80808e2 100644 --- a/mirrors/models.py +++ b/mirrors/models.py @@ -14,7 +14,7 @@ TIER_CHOICES = ( class Mirror(models.Model): name = models.CharField(max_length=255, unique=True) tier = models.SmallIntegerField(default=2, choices=TIER_CHOICES) - upstream = models.ForeignKey('self', null=True) + upstream = models.ForeignKey('self', null=True, on_delete=models.SET_NULL) country = models.CharField(max_length=255, db_index=True) admin_email = models.EmailField(max_length=255, blank=True) public = models.BooleanField(default=True) @@ -56,7 +56,7 @@ class MirrorProtocol(models.Model): class MirrorUrl(models.Model): url = models.CharField(max_length=255, unique=True) protocol = models.ForeignKey(MirrorProtocol, related_name="urls", - editable=False) + editable=False, on_delete=models.PROTECT) mirror = models.ForeignKey(Mirror, related_name="urls") has_ipv4 = models.BooleanField("IPv4 capable", default=True, editable=False) -- cgit v1.2.3-24-g4f1b