13 lines
401 B
MySQL
13 lines
401 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`warehouse_afterUpdate`
|
||
|
AFTER UPDATE ON `warehouse`
|
||
|
FOR EACH ROW
|
||
|
BEGIN
|
||
|
IF NEW.isFeedStock IS TRUE AND OLD.isFeedStock IS FALSE THEN
|
||
|
INSERT IGNORE INTO warehouseAlias(`name`) VALUES(NEW.`name`);
|
||
|
INSERT IGNORE INTO warehouseJoined(warehouseFk, warehouseAliasFk)
|
||
|
VALUES(NEW.id,LAST_INSERT_ID());
|
||
|
END IF;
|
||
|
END$$
|
||
|
DELIMITER ;
|