refactor: refs #7952 Deprecate creditInsurance.creditClassification #2951

Merged
ivanm merged 3 commits from 7952-DeprecateCreditInsurance.creditClassification into dev 2024-09-12 11:25:17 +00:00
7 changed files with 8 additions and 16 deletions

View File

@ -10,7 +10,7 @@ BEGIN
SELECT * FROM ( SELECT * FROM (
SELECT cc.client clientFk, ci.grade SELECT cc.client clientFk, ci.grade
FROM creditClassification cc FROM creditClassification cc
JOIN creditInsurance ci ON cc.id = ci.creditClassification JOIN creditInsurance ci ON cc.id = ci.creditClassificationFk
WHERE dateEnd IS NULL WHERE dateEnd IS NULL
ORDER BY ci.creationDate DESC ORDER BY ci.creationDate DESC
LIMIT 10000000000000000000) t1 LIMIT 10000000000000000000) t1

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditInsurance_afterIn
BEGIN BEGIN
UPDATE `client` c UPDATE `client` c
JOIN vn.creditClassification cc ON cc.client = c.id JOIN vn.creditClassification cc ON cc.client = c.id
SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassification; SET creditInsurance = NEW.credit WHERE cc.id = NEW.creditClassificationFk;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,10 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`creditInsurance_beforeInsert`
BEFORE INSERT ON `creditInsurance`
FOR EACH ROW
BEGIN
IF NEW.creditClassificationFk THEN
SET NEW.creditClassification = NEW.creditClassificationFk;
END IF;
END$$
DELIMITER ;

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_afterInsert
BEGIN BEGIN
UPDATE client c UPDATE client c
JOIN creditClassification cc ON cc.client = c.id JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassification = cc.id JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance; SET creditInsurance = ci.credit * 2 WHERE ci.id = NEW.creditInsurance;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -6,12 +6,12 @@ BEGIN
IF NEW.dateLeaving IS NOT NULL THEN IF NEW.dateLeaving IS NOT NULL THEN
UPDATE client c UPDATE client c
JOIN creditClassification cc ON cc.client = c.id JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassification = cc.id JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
ELSE ELSE
UPDATE client c UPDATE client c
JOIN creditClassification cc ON cc.client = c.id JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassification = cc.id JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance; SET creditInsurance = ci.credit * 2 WHERE ci.id = OLD.creditInsurance;
END IF; END IF;
END$$ END$$

View File

@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`solunionCAP_beforeDelet
BEGIN BEGIN
UPDATE client c UPDATE client c
JOIN creditClassification cc ON cc.client = c.id JOIN creditClassification cc ON cc.client = c.id
JOIN creditInsurance ci ON ci.creditClassification = cc.id JOIN creditInsurance ci ON ci.creditClassificationFk = cc.id
SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance; SET creditInsurance = ci.credit WHERE ci.id = OLD.creditInsurance;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.creditInsurance
CHANGE creditClassification creditClassification__ int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11';