feat: refs #6727 Added started and finished
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
4880d1497f
commit
930e2951b7
|
@ -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,6 +23,13 @@ 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 vSchemaName = util.quoteIdentifier(vSchemaName);
|
||||||
SET vTableName = util.quoteIdentifier(vTableName);
|
SET vTableName = util.quoteIdentifier(vTableName);
|
||||||
SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY;
|
SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY;
|
||||||
|
@ -35,6 +42,12 @@ BEGIN
|
||||||
'DELETE FROM ', vSchemaName , '.', vTableName,
|
'DELETE FROM ', vSchemaName , '.', vTableName,
|
||||||
" WHERE creationDate < '", vDated, "'"
|
" WHERE creationDate < '", vDated, "'"
|
||||||
));
|
));
|
||||||
|
|
||||||
|
UPDATE logCleanMultiConfig
|
||||||
|
SET `finished` = util.VN_NOW()
|
||||||
|
WHERE schemaName = vSchemaName
|
||||||
|
AND tableName = vTableName;
|
||||||
|
END IF;
|
||||||
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