This commit is contained in:
parent
930e2951b7
commit
3cf5555612
|
@ -8,6 +8,7 @@ BEGIN
|
||||||
DECLARE vSchemaName VARCHAR(65);
|
DECLARE vSchemaName VARCHAR(65);
|
||||||
DECLARE vTableName VARCHAR(65);
|
DECLARE vTableName VARCHAR(65);
|
||||||
DECLARE vRetentionDays INT;
|
DECLARE vRetentionDays INT;
|
||||||
|
DECLARE vStarted DATETIME;
|
||||||
DECLARE vDated DATE;
|
DECLARE vDated DATE;
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
|
|
||||||
|
@ -23,28 +24,23 @@ BEGIN
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays;
|
FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays;
|
||||||
|
|
||||||
IF vRetentionDays THEN
|
|
||||||
|
|
||||||
UPDATE logCleanMultiConfig
|
|
||||||
SET `started` = util.VN_NOW()
|
|
||||||
WHERE schemaName = vSchemaName
|
|
||||||
AND tableName = vTableName;
|
|
||||||
|
|
||||||
SET vSchemaName = util.quoteIdentifier(vSchemaName);
|
|
||||||
SET vTableName = util.quoteIdentifier(vTableName);
|
|
||||||
SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY;
|
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
IF vRetentionDays THEN
|
||||||
|
SET vStarted = util.VN_NOW();
|
||||||
|
SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY;
|
||||||
|
|
||||||
CALL util.exec(CONCAT(
|
CALL util.exec(CONCAT(
|
||||||
'DELETE FROM ', vSchemaName , '.', vTableName,
|
'DELETE FROM ', util.quoteIdentifier(vSchemaName),
|
||||||
|
'.', util.quoteIdentifier(vTableName),
|
||||||
" WHERE creationDate < '", vDated, "'"
|
" WHERE creationDate < '", vDated, "'"
|
||||||
));
|
));
|
||||||
|
|
||||||
UPDATE logCleanMultiConfig
|
UPDATE logCleanMultiConfig
|
||||||
SET `finished` = util.VN_NOW()
|
SET `started` = vStarted,
|
||||||
|
`finished` = VN_NOW()
|
||||||
WHERE schemaName = vSchemaName
|
WHERE schemaName = vSchemaName
|
||||||
AND tableName = vTableName;
|
AND tableName = vTableName;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -8,25 +8,25 @@ CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` (
|
||||||
PRIMARY KEY (`schemaName`,`tableName`)
|
PRIMARY KEY (`schemaName`,`tableName`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||||
|
|
||||||
INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`, `retentionDays`, `order`)
|
INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`)
|
||||||
VALUES
|
VALUES
|
||||||
('account', 'roleLog', 'xxx', NULL),
|
('account', 'roleLog' ),
|
||||||
('account', 'userLog', 'xxx', NULL),
|
('account', 'userLog' ),
|
||||||
('vn', 'entryLog', 'xxx', NULL),
|
('vn', 'entryLog' ),
|
||||||
('vn', 'clientLog', 'xxx', NULL),
|
('vn', 'clientLog' ),
|
||||||
('vn', 'itemLog', 'xxx', NULL),
|
('vn', 'itemLog' ),
|
||||||
('vn', 'shelvingLog', 'xxx', NULL),
|
('vn', 'shelvingLog' ),
|
||||||
('vn', 'workerLog', 'xxx', NULL),
|
('vn', 'workerLog' ),
|
||||||
('vn', 'deviceProductionLog', 'xxx', NULL),
|
('vn', 'deviceProductionLog' ),
|
||||||
('vn', 'zoneLog', 'xxx', NULL),
|
('vn', 'zoneLog' ),
|
||||||
('vn', 'rateLog', 'xxx', NULL),
|
('vn', 'rateLog' ),
|
||||||
('vn', 'ticketLog', 'xxx', NULL),
|
('vn', 'ticketLog' ),
|
||||||
('vn', 'agencyLog', 'xxx', NULL),
|
('vn', 'agencyLog' ),
|
||||||
('vn', 'userLog', 'xxx', NULL),
|
('vn', 'userLog' ),
|
||||||
('vn', 'routeLog', 'xxx', NULL),
|
('vn', 'routeLog' ),
|
||||||
('vn', 'claimLog', 'xxx', NULL),
|
('vn', 'claimLog' ),
|
||||||
('vn', 'supplierLog', 'xxx', NULL),
|
('vn', 'supplierLog' ),
|
||||||
('vn', 'invoiceInLog', 'xxx', NULL),
|
('vn', 'invoiceInLog' ),
|
||||||
('vn', 'travelLog', 'xxx', NULL),
|
('vn', 'travelLog' ),
|
||||||
('vn', 'packingSiteDeviceLog', 'xxx', NULL),
|
('vn', 'packingSiteDeviceLog' ),
|
||||||
('vn', 'parkingLog', 'xxx', NULL);
|
('vn', 'parkingLog' );
|
||||||
|
|
Loading…
Reference in New Issue