I am no expert on triggers.
But here is one I used in the past that worked.
DELIMITER $$
USE `pbackdate`$$
DROP TRIGGER /*!50032 IF EXISTS */ `trzero_tonull`$$
CREATE
/*!50017 DEFINER = 'root'@'localhost' */
TRIGGER `trzero_tonull` BEFORE INSERT ON `pets`
FOR EACH ROW BEGIN
IF NEW.ownerid = 0 THEN
SET NEW.ownerid = NULL;
END IF;
END;
$$
DELIMITER ;
But test yours in development to see if it works ok or not.