8032-devToTest_2440 #3009
|
@ -13,7 +13,7 @@ BEGIN
|
||||||
|
|
||||||
DECLARE vQueue CURSOR FOR
|
DECLARE vQueue CURSOR FOR
|
||||||
SELECT schemaName, tableName, retentionDays
|
SELECT schemaName, tableName, retentionDays
|
||||||
FROM logClean
|
FROM logCleanMultiConfig
|
||||||
ORDER BY `order`;
|
ORDER BY `order`;
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
@ -23,18 +23,31 @@ BEGIN
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays;
|
FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays;
|
||||||
|
|
||||||
SET vSchemaName = util.quoteIdentifier(vSchemaName);
|
IF vRetentionDays THEN
|
||||||
SET vTableName = util.quoteIdentifier(vTableName);
|
|
||||||
SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY;
|
|
||||||
|
|
||||||
IF vDone THEN
|
UPDATE logCleanMultiConfig
|
||||||
LEAVE l;
|
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
|
||||||
|
LEAVE l;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
CALL util.exec(CONCAT(
|
||||||
|
'DELETE FROM ', vSchemaName , '.', vTableName,
|
||||||
|
" WHERE creationDate < '", vDated, "'"
|
||||||
|
));
|
||||||
|
|
||||||
|
UPDATE logCleanMultiConfig
|
||||||
|
SET `finished` = util.VN_NOW()
|
||||||
|
WHERE schemaName = vSchemaName
|
||||||
|
AND tableName = vTableName;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL util.exec(CONCAT(
|
|
||||||
'DELETE FROM ', vSchemaName , '.', vTableName,
|
|
||||||
" WHERE creationDate < '", vDated, "'"
|
|
||||||
));
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE vQueue;
|
CLOSE vQueue;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
CREATE OR REPLACE TABLE `util`.`logClean` (
|
CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` (
|
||||||
`schemaName` varchar(64) NOT NULL,
|
`schemaName` varchar(64) NOT NULL,
|
||||||
`tableName` varchar(64) NOT NULL,
|
`tableName` varchar(64) NOT NULL,
|
||||||
`retentionDays` int(11) NOT NULL,
|
`retentionDays` int(11) DEFAULT NULL,
|
||||||
`order` int(11) DEFAULT NULL,
|
`order` int(11) DEFAULT NULL,
|
||||||
|
`started` datetime DEFAULT NULL,
|
||||||
|
`finished` datetime DEFAULT NULL,
|
||||||
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`.`logClean` (`schemaName`, `tableName`, `retentionDays`, `order`)
|
INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`, `retentionDays`, `order`)
|
||||||
VALUES
|
VALUES
|
||||||
('account', 'roleLog', 'xxx', NULL),
|
('account', 'roleLog', 'xxx', NULL),
|
||||||
('account', 'userLog', 'xxx', NULL),
|
('account', 'userLog', 'xxx', NULL),
|
||||||
|
|
Loading…
Reference in New Issue