8032-devToTest_2440 #3009
|
@ -13,7 +13,7 @@ BEGIN
|
|||
|
||||
DECLARE vQueue CURSOR FOR
|
||||
SELECT schemaName, tableName, retentionDays
|
||||
FROM logClean
|
||||
FROM logCleanMultiConfig
|
||||
ORDER BY `order`;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
@ -23,6 +23,13 @@ BEGIN
|
|||
SET vDone = FALSE;
|
||||
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;
|
||||
|
@ -35,6 +42,12 @@ BEGIN
|
|||
'DELETE FROM ', vSchemaName , '.', vTableName,
|
||||
" WHERE creationDate < '", vDated, "'"
|
||||
));
|
||||
|
||||
UPDATE logCleanMultiConfig
|
||||
SET `finished` = util.VN_NOW()
|
||||
WHERE schemaName = vSchemaName
|
||||
AND tableName = vTableName;
|
||||
END IF;
|
||||
END LOOP;
|
||||
CLOSE vQueue;
|
||||
END$$
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
CREATE OR REPLACE TABLE `util`.`logClean` (
|
||||
CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` (
|
||||
`schemaName` varchar(64) NOT NULL,
|
||||
`tableName` varchar(64) NOT NULL,
|
||||
`retentionDays` int(11) NOT NULL,
|
||||
`retentionDays` int(11) DEFAULT NULL,
|
||||
`order` int(11) DEFAULT NULL,
|
||||
`started` datetime DEFAULT NULL,
|
||||
`finished` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`schemaName`,`tableName`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
|
||||
|
||||
INSERT INTO `util`.`logClean` (`schemaName`, `tableName`, `retentionDays`, `order`)
|
||||
INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`, `retentionDays`, `order`)
|
||||
VALUES
|
||||
('account', 'roleLog', 'xxx', NULL),
|
||||
('account', 'userLog', 'xxx', NULL),
|
||||
|
|
Loading…
Reference in New Issue