From fc7d7eece8c64a20305c6efc935128ce55b31f3a Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 28 Jul 2017 16:01:51 +0200 Subject: [PATCH] Bug 19008: More database cleanups - old reserves misc/cronjobs/cleanup_database.pl provides some database cleanup. Yet some tables that could need cleanup are not in this script. This patch adds cleanup for old_reserves table. Test plan : - Count : select count(*),date(timestamp) from old_reserves group by date(timestamp); - Run cleanup : misc/cronjobs/cleanup_database.pl -v --old-reserves 30 - Recount Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- misc/cronjobs/cleanup_database.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 0e6bd6606b..b527df17a0 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -45,7 +45,7 @@ use Koha::UploadedFiles; sub usage { print STDERR < \$help, @@ -146,6 +148,7 @@ GetOptions( 'deleted-catalog:i' => \$pDeletedCatalog, 'deleted-patrons:i' => \$pDeletedPatrons, 'old-issues:i' => \$pOldIssues, + 'old-reserves:i' => \$pOldReserves, ) || usage(1); # Use default values @@ -184,6 +187,7 @@ unless ( $sessions || $pDeletedCatalog || $pDeletedPatrons || $pOldIssues + || $pOldReserves ) { print "You did not specify any cleanup work for the script to do.\n\n"; usage(1); @@ -433,6 +437,18 @@ if ($pOldIssues) { print "Done with purging old issues.\n" if $verbose; } +if ($pOldReserves) { + print "Purging old reserves older than $pOldReserves days.\n" if $verbose; + $sth = $dbh->prepare( + q{ + DELETE FROM old_reserves + WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL ? DAY) + } + ); + $sth->execute($pOldReserves); + print "Done with purging old reserves.\n" if $verbose; +} + exit(0); sub RemoveOldSessions { -- 2.39.5