From 8d0a2f2eafe2e0b0743be1daf19cd9032aa81b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Tue, 12 Sep 2017 12:05:58 +0300 Subject: [PATCH] Remove startup check for update_alert_after trigger, remove drop_triggers command. --- hc/api/management/commands/droptriggers.py | 37 ---------------------- hc/api/models.py | 23 -------------- 2 files changed, 60 deletions(-) delete mode 100644 hc/api/management/commands/droptriggers.py diff --git a/hc/api/management/commands/droptriggers.py b/hc/api/management/commands/droptriggers.py deleted file mode 100644 index a2ae64bf..00000000 --- a/hc/api/management/commands/droptriggers.py +++ /dev/null @@ -1,37 +0,0 @@ -from django.core.management.base import BaseCommand -from django.db import connection - - -def _pg(cursor): - cursor.execute(""" - DROP TRIGGER IF EXISTS update_alert_after ON api_check; - """) - - -def _mysql(cursor): - cursor.execute(""" - DROP TRIGGER IF EXISTS update_alert_after; - """) - - -def _sqlite(cursor): - cursor.execute(""" - DROP TRIGGER IF EXISTS update_alert_after; - """) - - -class Command(BaseCommand): - help = 'Drops the `update_alert_after` trigger' - requires_system_checks = False - - def handle(self, *args, **options): - with connection.cursor() as cursor: - if connection.vendor == "postgresql": - _pg(cursor) - return "Dropped PostgreSQL trigger" - if connection.vendor == "mysql": - _mysql(cursor) - return "Dropped MySQL trigger" - if connection.vendor == "sqlite": - _sqlite(cursor) - return "Dropped SQLite trigger" diff --git a/hc/api/models.py b/hc/api/models.py index 5c4084cb..a2d94912 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -186,29 +186,6 @@ class Check(models.Model): def has_confirmation_link(self): return "confirm" in self.last_ping_body.lower() - @classmethod - def check(cls, **kwargs): - errors = super(Check, cls).check(**kwargs) - - trigger_detected = False - try: - dummy = Check(last_ping=timezone.now()) - dummy.save() - dummy.refresh_from_db() - trigger_detected = bool(dummy.alert_after) - dummy.delete() - except: - pass - - if trigger_detected: - err = Warning( - "Obsolete 'update_alert_after' trigger exists in database.", - hint="Please remove the trigger with 'manage.py droptriggers'", - id="hc.api.E001") - errors.append(err) - - return errors - class Ping(models.Model): n = models.IntegerField(null=True)