feat: refs #6727 Fixes
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-07-19 08:58:51 +02:00
parent 930e2951b7
commit 3cf5555612
2 changed files with 31 additions and 35 deletions

View File

@ -8,6 +8,7 @@ BEGIN
DECLARE vSchemaName VARCHAR(65);
DECLARE vTableName VARCHAR(65);
DECLARE vRetentionDays INT;
DECLARE vStarted DATETIME;
DECLARE vDated DATE;
DECLARE vDone BOOL;
@ -23,28 +24,23 @@ BEGIN
SET vDone = FALSE;
FETCH vQueue INTO vSchemaName, vTableName, vRetentionDays;
IF vDone THEN
LEAVE l;
END IF;
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 vStarted = util.VN_NOW();
SET vDated = VN_CURDATE() - INTERVAL vRetentionDays DAY;
IF vDone THEN
LEAVE l;
END IF;
CALL util.exec(CONCAT(
'DELETE FROM ', vSchemaName , '.', vTableName,
'DELETE FROM ', util.quoteIdentifier(vSchemaName),
'.', util.quoteIdentifier(vTableName),
" WHERE creationDate < '", vDated, "'"
));
UPDATE logCleanMultiConfig
SET `finished` = util.VN_NOW()
SET `started` = vStarted,
`finished` = VN_NOW()
WHERE schemaName = vSchemaName
AND tableName = vTableName;
END IF;

View File

@ -8,25 +8,25 @@ CREATE OR REPLACE TABLE `util`.`logCleanMultiConfig` (
PRIMARY KEY (`schemaName`,`tableName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`, `retentionDays`, `order`)
INSERT INTO `util`.`logCleanMultiConfig` (`schemaName`, `tableName`)
VALUES
('account', 'roleLog', 'xxx', NULL),
('account', 'userLog', 'xxx', NULL),
('vn', 'entryLog', 'xxx', NULL),
('vn', 'clientLog', 'xxx', NULL),
('vn', 'itemLog', 'xxx', NULL),
('vn', 'shelvingLog', 'xxx', NULL),
('vn', 'workerLog', 'xxx', NULL),
('vn', 'deviceProductionLog', 'xxx', NULL),
('vn', 'zoneLog', 'xxx', NULL),
('vn', 'rateLog', 'xxx', NULL),
('vn', 'ticketLog', 'xxx', NULL),
('vn', 'agencyLog', 'xxx', NULL),
('vn', 'userLog', 'xxx', NULL),
('vn', 'routeLog', 'xxx', NULL),
('vn', 'claimLog', 'xxx', NULL),
('vn', 'supplierLog', 'xxx', NULL),
('vn', 'invoiceInLog', 'xxx', NULL),
('vn', 'travelLog', 'xxx', NULL),
('vn', 'packingSiteDeviceLog', 'xxx', NULL),
('vn', 'parkingLog', 'xxx', NULL);
('account', 'roleLog' ),
('account', 'userLog' ),
('vn', 'entryLog' ),
('vn', 'clientLog' ),
('vn', 'itemLog' ),
('vn', 'shelvingLog' ),
('vn', 'workerLog' ),
('vn', 'deviceProductionLog' ),
('vn', 'zoneLog' ),
('vn', 'rateLog' ),
('vn', 'ticketLog' ),
('vn', 'agencyLog' ),
('vn', 'userLog' ),
('vn', 'routeLog' ),
('vn', 'claimLog' ),
('vn', 'supplierLog' ),
('vn', 'invoiceInLog' ),
('vn', 'travelLog' ),
('vn', 'packingSiteDeviceLog' ),
('vn', 'parkingLog' );