7167-testToMaster_2414 #2244

Merged
alexm merged 643 commits from 7167-testToMaster_2414 into master 2024-04-04 05:32:41 +00:00
1 changed files with 11 additions and 10 deletions
Showing only changes of commit fe0a1ad7be - Show all commits

View File

@ -12,7 +12,7 @@ BEGIN
DECLARE v1Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 1 YEAR;
DECLARE v2Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 2 YEAR;
DECLARE v4Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 4 YEAR;
DECLARE v5Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 5 YEAR;
DECLARE v5Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 5 YEAR;
DECLARE vTrashId VARCHAR(15);
DECLARE vCompanyBlk INT;
@ -30,8 +30,9 @@ BEGIN
DELETE IGNORE FROM expedition WHERE created < v26Months;
DELETE FROM sms WHERE created < v18Months;
DELETE FROM saleTracking WHERE created < v1Years;
DELETE FROM productionError WHERE dated < v1Years;
DELETE FROM ticketTracking WHERE created < v18Months;
DELETE tobs FROM ticketObservation tobs
DELETE tobs FROM ticketObservation tobs
JOIN ticket t ON tobs.ticketFk = t.id
WHERE t.shipped < v5Years;
DELETE sc.* FROM saleCloned sc JOIN sale s ON s.id = sc.saleClonedFk JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped < v1Years;
@ -113,12 +114,12 @@ BEGIN
FROM travel t
LEFT JOIN entry e ON e.travelFk = t.id
WHERE t.shipped < v3Months AND e.travelFk IS NULL;
UPDATE dms d
JOIN dmsType dt ON dt.id = d.dmsTypeFk
SET d.dmsTypeFk = vTrashId
JOIN dmsType dt ON dt.id = d.dmsTypeFk
SET d.dmsTypeFk = vTrashId
WHERE created < util.VN_CURDATE() - INTERVAL dt.monthToDelete MONTH;
-- borrar entradas sin compras
CREATE OR REPLACE TEMPORARY TABLE tEntryToDelete
SELECT e.*
@ -136,7 +137,7 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tRouteToDelete
SELECT *
FROM route r
WHERE created < v4Years;
WHERE created < v4Years;
UPDATE tRouteToDelete tmp
JOIN dms d ON d.id = tmp.gestdocFk
@ -180,7 +181,7 @@ BEGIN
DELETE FROM mail WHERE creationDate < v2Months;
DELETE FROM split WHERE dated < v18Months;
DELETE FROM remittance WHERE dated < v18Months;
CREATE OR REPLACE TEMPORARY TABLE tTicketDelete
SELECT DISTINCT tl.originFk ticketFk
FROM ticketLog tl
@ -189,11 +190,11 @@ BEGIN
FROM ticket t
JOIN ticketLog tl ON tl.originFk = t.id
LEFT JOIN ticketWeekly tw ON tw.ticketFk = t.id
WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31'
WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31'
AND t.isDeleted
AND tw.ticketFk IS NULL
GROUP BY t.id
) sub ON sub.ids = tl.id
) sub ON sub.ids = tl.id
WHERE tl.creationDate <= v2Months;
DELETE t
FROM ticket t