From 3dc441d61d7045f218652b357e0f4884d23d9995 Mon Sep 17 00:00:00 2001 From: Keir Nellyer Date: Sat, 29 Oct 2016 14:38:16 +0100 Subject: [PATCH] PC-1016 Delete snapshots > 30 days and not linked to report in cleanup task --- Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql index b83563c92..b0a634722 100644 --- a/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql +++ b/Plugins/Mineplex.ReportSite/sql/6-cleanup-task.sql @@ -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