You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
980 B

  1. from django.core.management.base import BaseCommand
  2. from django.db import connection
  3. def _pg(cursor):
  4. cursor.execute("""
  5. DROP TRIGGER IF EXISTS update_alert_after ON api_check;
  6. """)
  7. def _mysql(cursor):
  8. cursor.execute("""
  9. DROP TRIGGER IF EXISTS update_alert_after;
  10. """)
  11. def _sqlite(cursor):
  12. cursor.execute("""
  13. DROP TRIGGER IF EXISTS update_alert_after;
  14. """)
  15. class Command(BaseCommand):
  16. help = 'Drops the `update_alert_after` trigger'
  17. requires_system_checks = False
  18. def handle(self, *args, **options):
  19. with connection.cursor() as cursor:
  20. if connection.vendor == "postgresql":
  21. _pg(cursor)
  22. return "Dropped PostgreSQL trigger"
  23. if connection.vendor == "mysql":
  24. _mysql(cursor)
  25. return "Dropped MySQL trigger"
  26. if connection.vendor == "sqlite":
  27. _sqlite(cursor)
  28. return "Dropped SQLite trigger"