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