sync
[Pman.Core] / mysql / core_notify_trigger_after_delete.sql
diff --git a/mysql/core_notify_trigger_after_delete.sql b/mysql/core_notify_trigger_after_delete.sql
new file mode 100644 (file)
index 0000000..400a4e4
--- /dev/null
@@ -0,0 +1,20 @@
+
+
+-- can not delete 'sent' notifications -- trick is to 'null the sent before deleting...
+
+DROP TRIGGER IF EXISTS core_notify_trigger_after_delete;
+
+DELIMITER $$
+CREATE TRIGGER core_notify_trigger_after_delete AFTER DELETE on core_notify
+    FOR EACH ROW
+        BEGIN
+            if old.sent is not null THEN 
+                UPDATE `Error: Can not delete core_notify after it is sent` SET x = 1;
+            END IF;
+        END;
+
+$$
+
+DELIMITER ;