From 1718952fcfb12b7d2caf360b150624fd3a439613 Mon Sep 17 00:00:00 2001 From: Bernat Date: Tue, 30 Oct 2018 08:35:17 +0100 Subject: [PATCH] update structure table ticketLog --- .../1.2-CHECK/07-ticketLogAfterInsert.sql | 17 +++++++++++++++++ .../install/changes/1.2-CHECK/08-ticketLog.sql | 10 ++++++++++ .../changes/1.2-CHECK/09-ticket_dits.sql | 10 ++++++++++ 3 files changed, 37 insertions(+) create mode 100644 services/db/install/changes/1.2-CHECK/07-ticketLogAfterInsert.sql create mode 100644 services/db/install/changes/1.2-CHECK/08-ticketLog.sql create mode 100644 services/db/install/changes/1.2-CHECK/09-ticket_dits.sql diff --git a/services/db/install/changes/1.2-CHECK/07-ticketLogAfterInsert.sql b/services/db/install/changes/1.2-CHECK/07-ticketLogAfterInsert.sql new file mode 100644 index 000000000..43f0e7ec1 --- /dev/null +++ b/services/db/install/changes/1.2-CHECK/07-ticketLogAfterInsert.sql @@ -0,0 +1,17 @@ +DROP TRIGGER IF EXISTS `vn`.`ticketLog_AFTER_INSERT`; + +DELIMITER $$ +USE `vn`$$ +CREATE DEFINER=`root`@`%` TRIGGER `vn`.`ticketLog_AFTER_INSERT` AFTER INSERT ON `ticketLog` FOR EACH ROW +BEGIN + DECLARE vActionId INT DEFAULT 84; + DECLARE vWorkerFk INT; + + SELECT id INTO vWorkerFk + FROM worker w + WHERE w.userFk = NEW.userFk; + + INSERT INTO vn2008.Tickets_dits(idaccion_dits,Id_Trabajador,Id_Ticket,value_old,value_new) + VALUES (vActionId, vWorkerFk, NEW.originFk, NULL, NULL); +END$$ +DELIMITER ; diff --git a/services/db/install/changes/1.2-CHECK/08-ticketLog.sql b/services/db/install/changes/1.2-CHECK/08-ticketLog.sql new file mode 100644 index 000000000..2a781d2e9 --- /dev/null +++ b/services/db/install/changes/1.2-CHECK/08-ticketLog.sql @@ -0,0 +1,10 @@ +ALTER TABLE `vn`.`ticketLog` +DROP FOREIGN KEY `ticketLog_ibfk_2`; +ALTER TABLE `vn`.`ticketLog` +CHANGE COLUMN `userFk` `userFk` INT(10) UNSIGNED NULL DEFAULT NULL ; +ALTER TABLE `vn`.`ticketLog` +ADD CONSTRAINT `ticketLog_ibfk_2` + FOREIGN KEY (`userFk`) + REFERENCES `account`.`user` (`id`) + ON DELETE CASCADE + ON UPDATE CASCADE; diff --git a/services/db/install/changes/1.2-CHECK/09-ticket_dits.sql b/services/db/install/changes/1.2-CHECK/09-ticket_dits.sql new file mode 100644 index 000000000..5be857af0 --- /dev/null +++ b/services/db/install/changes/1.2-CHECK/09-ticket_dits.sql @@ -0,0 +1,10 @@ +ALTER TABLE `vn2008`.`Tickets_dits` +DROP FOREIGN KEY `fgkey3`; +ALTER TABLE `vn2008`.`Tickets_dits` +CHANGE COLUMN `Id_Trabajador` `Id_Trabajador` INT(11) NULL DEFAULT NULL ; +ALTER TABLE `vn2008`.`Tickets_dits` +ADD CONSTRAINT `fgkey3` + FOREIGN KEY (`Id_Trabajador`) + REFERENCES `vn2008`.`Trabajadores` (`Id_Trabajador`) + ON DELETE NO ACTION + ON UPDATE CASCADE;