refs #5858 perf: move files to current version folder

This commit is contained in:
Javier Segarra 2023-11-23 15:18:09 +01:00
parent a2329e1276
commit 5d156e81ca
9 changed files with 130 additions and 54 deletions

View File

@ -0,0 +1,72 @@
DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterInsert`;
USE `vn`;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterInsert`
AFTER INSERT ON `zoneIncluded`
FOR EACH ROW
BEGIN
INSERT INTO zoneLog
SET `action` = 'insert',
`changedModel` = 'zoneIncluded',
`changedModelId` = NEW.zoneFk,
`userFk` = account.myUser_getId();
INSERT INTO zoneIncludedCheck
SET
`action`= 'insert',
`zoneFk` = NEW.zoneFk,
`geoFk` = NEW.geoFk,
`userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`();
END$$
DELIMITER ;
DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterUpdate`;
USE `vn`;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterUpdate`
AFTER UPDATE ON `zoneIncluded`
FOR EACH ROW
BEGIN
INSERT INTO zoneLog
SET `action` = 'update',
`changedModel` = 'zoneIncluded',
`changedModelId` = OLD.zoneFk,
`userFk` = account.myUser_getId();
INSERT INTO zoneIncludedCheck
SET
`action`= 'update',
`zoneFk` = NEW.zoneFk,
`geoFk` = NEW.geoFk,
`userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`();
END$$
DELIMITER ;
DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`;
USE `vn`;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete`
AFTER DELETE ON `zoneIncluded`
FOR EACH ROW
BEGIN
INSERT INTO zoneLog
SET `action` = 'delete',
`changedModel` = 'zoneIncluded',
`changedModelId` = OLD.zoneFk,
`userFk` = account.myUser_getId();
INSERT INTO zoneIncludedCheck
SET
`action`= 'delete',
`zoneFk` = OLD.zoneFk,
`geoFk` = OLD.geoFk,
`userFk` = account.myUser_getId();
CALL `vn`.`zoneIncluded_checkCollisions`();
END$$
DELIMITER ;

View File

@ -0,0 +1,14 @@
CREATE TABLE `vn`.`zoneIncludedCheck` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`zoneFK` int(11) NOT NULL,
`geoFK` int(11) NOT NULL,
`userFK` int(10) unsigned NOT NULL,
`action`set('insert','update','delete') NOT NULL,
PRIMARY KEY (`id`),
CONSTRAINT `user_FK` FOREIGN KEY (`userFK`) REFERENCES `account`.`user` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `zone_FK` FOREIGN KEY (`zoneFK`) REFERENCES `vn`.`zone` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `geo_FK` FOREIGN KEY (`geoFK`) REFERENCES `vn`.`zoneGeo` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
UNIQUE INDEX (`zoneFK`, `geoFK`, `userFK`, `action`)
)
comment 'Table to save temporarily zone changes';

View File

@ -0,0 +1,30 @@
-- DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`;
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`(IN id INT)
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE zic_id, zic_zone, zic_geo, zic_action, zic_userFk INT;
DECLARE z_name VARCHAR(255);
DECLARE g_name VARCHAR(255);
DECLARE my_cur CURSOR FOR
SELECT zic.id, z.name , zg.name , zic.geoFk ,zic.`action` , zic.userFK FROM vn.zoneIncludedCheck zic, vn.`zone` z, vn.zoneGeo zg WHERE zic.zoneFK =z.id AND zic.geoFK = zg.id ;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN my_cur;
my_cur_loop:
LOOP FETCH my_cur INTO zic_id, z_name,g_name, zic_geo, zic_action, zic_userFk ;
IF done = 1 THEN
select concat('NO REDCORDS' ) AS '** DEBUG:';
LEAVE my_cur_loop;
END IF;
SELECT concat('** ', zic_id, '** ',z_name, '** ',g_name,'**',zic_geo,'** ', zic_action,'** ', zic_userFk ) AS '** DEBUG:';
DELETE FROM vn.zoneIncludedCheck WHERE id =zic_id;
SELECT util.notification_send('zone-included',
JSON_OBJECT('zoneSelected', z_name, 'geoSelected', g_name),
account.myUser_getId()
);
END LOOP my_cur_loop;
CLOSE my_cur;
END

View File

@ -1,47 +0,0 @@
DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterInsert`;
USE `vn`;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterInsert`
AFTER INSERT ON `zoneIncluded`
FOR EACH ROW
BEGIN
INSERT INTO zoneLog
SET `action` = 'insert',
`changedModel` = 'zoneIncluded',
`changedModelId` = OLD.zoneFk,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;
DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterUpdate`;
USE `vn`;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterUpdate`
AFTER UPDATE ON `zoneIncluded`
FOR EACH ROW
BEGIN
INSERT INTO zoneLog
SET `action` = 'update',
`changedModel` = 'zoneIncluded',
`changedModelId` = OLD.zoneFk,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;
-- DROP TRIGGER IF EXISTS `vn`.`zoneIncluded_afterDelete`;
-- USE `vn`;
-- DELIMITER $$
-- CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`zoneIncluded_afterDelete`
-- AFTER DELETE ON `zoneIncluded`
-- FOR EACH ROW
-- BEGIN
-- INSERT INTO zoneLog
-- SET `action` = 'delete',
-- `changedModel` = 'zoneIncluded',
-- `changedModelId` = OLD.zoneFk,
-- `userFk` = account.myUser_getId();
-- END$$
-- DELIMITER ;

View File

@ -1,7 +0,0 @@
CREATE TABLE `vn`.`zoneIncludedCheck` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`zoneFK` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY (`inclusion_FK`,`zoneFK`),
CONSTRAINT `inclusion_FK` FOREIGN KEY (`zoneFK`) REFERENCES `zoneIncluded` (`id`) ON UPDATE CASCADE,
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

View File

@ -0,0 +1,14 @@
DROP PROCEDURE IF EXISTS `vn`.`zoneIncluded_checkCollisions`;
DELIMITER $$
$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zoneIncluded_checkCollisions`()
BEGIN
-- DROP TEMPORARY TABLE IF EXISTS tmp.toCheck;
DECLARE vZonesToCheck INT;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vZoneFk INT;
DECLARE vCounter INT;
END$$
DELIMITER ;