2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterUpdate`
|
|
|
|
AFTER UPDATE ON `client`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN
|
2024-04-17 11:21:27 +00:00
|
|
|
UPDATE `address` SET isDefaultAddress = FALSE
|
2024-01-15 11:31:03 +00:00
|
|
|
WHERE clientFk = NEW.id;
|
|
|
|
|
2024-04-17 11:21:27 +00:00
|
|
|
UPDATE `address` SET isDefaultAddress = TRUE
|
|
|
|
WHERE id = NEW.defaultAddressFk;
|
2024-01-15 11:31:03 +00:00
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|