2023-06-06 08:31:08 +00:00
|
|
|
ALTER TABLE `vn`.`zoneIncluded`
|
|
|
|
ADD COLUMN `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
|
|
|
|
DROP PRIMARY KEY,
|
|
|
|
DROP FOREIGN KEY `zoneFk2`,
|
|
|
|
DROP FOREIGN KEY `zoneGeoFk2`,
|
|
|
|
DROP KEY `geoFk_idx`,
|
|
|
|
ADD PRIMARY KEY (`id`),
|
|
|
|
ADD CONSTRAINT `zoneIncluded_FK_1` FOREIGN KEY (zoneFk) REFERENCES `vn`.`zone`(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
ADD CONSTRAINT `zoneIncluded_FK_2` FOREIGN KEY (geoFk) REFERENCES `vn`.`zoneGeo`(id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
|
|
ADD CONSTRAINT `unique_zone_geo` UNIQUE (`zoneFk`, `geoFk`);
|
|
|
|
|
|
|
|
DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`;
|
|
|
|
USE `vn`;
|
|
|
|
|
|
|
|
DELIMITER $$
|
2023-10-17 13:05:48 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete`
|
2023-06-06 08:31:08 +00:00
|
|
|
AFTER DELETE ON `zoneIncluded`
|
|
|
|
FOR EACH ROW
|
|
|
|
BEGIN
|
|
|
|
INSERT INTO zoneLog
|
|
|
|
SET `action` = 'delete',
|
2023-10-17 13:05:48 +00:00
|
|
|
`changedModel` = 'zoneIncluded',
|
|
|
|
`changedModelId` = OLD.zoneFk,
|
2023-06-06 08:31:08 +00:00
|
|
|
`userFk` = account.myUser_getId();
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|