PC-1016 Delete snapshots > 30 days and not linked to report in
cleanup task
This commit is contained in:
parent
09e5d13b96
commit
3dc441d61d
|
@ -58,6 +58,12 @@ DO BEGIN
|
|||
LEFT JOIN snapshots ON reports.snapshotId = snapshots.id
|
||||
WHERE reportResults.closedTime NOT BETWEEN NOW() - INTERVAL 30 DAY AND NOW();
|
||||
|
||||
-- DELETE SNAPSHOTS NOT LINKED TO REPORT AND OLDER THAN 30 DAYS
|
||||
DELETE snapshots FROM snapshots
|
||||
LEFT JOIN reports ON snapshots.id = reports.snapshotId
|
||||
WHERE reports.id IS NULL
|
||||
AND snapshots.created NOT BETWEEN NOW() - INTERVAL 30 DAY AND NOW();
|
||||
|
||||
-- DELETE ORPHANED SNAPSHOT MESSAGES
|
||||
DELETE snapshotMessages FROM snapshotMessages
|
||||
LEFT JOIN snapshotMessageMap ON snapshotMessages.id = snapshotMessageMap.messageId
|
||||
|
|
Loading…
Reference in New Issue