From cebaf458140e34fad7a7dcae077c0e0326a95d25 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 28 Jul 2017 16:09:14 +0200 Subject: [PATCH] Bug 19008: More database cleanups - item transfers 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 branchtransfers table. Test plan : - Count : select count(*),datearrived from branchtransfers group by datearrived; - Run cleanup : misc/cronjobs/cleanup_database.pl -v --transfers 30 - Recount Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit dd8df39986ebc7c055894fea0148f900ba4a3a45) Signed-off-by: Lucas Gass --- 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 258a04f904..1a708b4f7b 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, @@ -149,6 +151,7 @@ GetOptions( 'deleted-patrons:i' => \$pDeletedPatrons, 'old-issues:i' => \$pOldIssues, 'old-reserves:i' => \$pOldReserves, + 'transfers:i' => \$pTransfers, ) || usage(1); # Use default values @@ -188,6 +191,7 @@ unless ( $sessions || $pDeletedPatrons || $pOldIssues || $pOldReserves + || $pTransfers ) { print "You did not specify any cleanup work for the script to do.\n\n"; usage(1); @@ -464,6 +468,18 @@ if ($pOldReserves) { print "Done with purging old reserves.\n" if $verbose; } +if ($pTransfers) { + print "Purging arrived item transfers older than $pTransfers days.\n" if $verbose; + $sth = $dbh->prepare( + q{ + DELETE FROM branchtransfers + WHERE datearrived < DATE_SUB(CURDATE(), INTERVAL ? DAY) + } + ); + $sth->execute($pTransfers); + print "Done with purging transfers.\n" if $verbose; +} + exit(0); sub RemoveOldSessions { -- 2.39.5