DROP TRIGGER IF EXISTS `uuid_test_insert`;
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='';
DELIMITER //
CREATE TRIGGER `uuid_test_insert` BEFORE INSERT ON `uuid_test` FOR EACH ROW BEGIN
IF new.uuid is null or new.uuid = '' or length(new.uuid) != 36 THEN
set new.uuid=uuid();
END IF;
END//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;