I don’t quite understand the trigger for auditing. Once I made the trigger, there is an error saying this trigger already existed?
Does it mean I should recreate the trigger on another sheet or what to do exactly?
I would love some help! Thank you
I don’t quite understand the trigger for auditing. Once I made the trigger, there is an error saying this trigger already existed?
Does it mean I should recreate the trigger on another sheet or what to do exactly?
I would love some help! Thank you
u need to drop trigger before recreating it.
DROP TRIGGER IF EXISTS payments_after_delete;
DELIMITER $$
CREATE TRIGGER payments_after_delete
AFTER DELETE ON PAYMENTS
FOR EACH ROW
BEGIN
UPDATE invoices
SET payment_total = payment_total - OLD.amount
WHERE invoice_id = OLD.invoice_id;
INSERT INTO payments_audit
VALUES (OLD.client_Id, OLD.date, OLD.amount, 'DELETE', CURDATE());
END $$
DELIMITER ;