From 07968fc5f68d7bf7c3ae1674489cebab6bea3817 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 --- 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 b527df17a0..695dc3bcdb 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); @@ -449,6 +453,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