From a957777158a5d65ababdde21a03f2d316d66d2c8 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Fri, 28 Jul 2017 14:43:45 +0200 Subject: [PATCH] Bug 19008 - More database cleanups - deleted patrons 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 deletedborrowers table. Test plan : - Count : select count(*),date(updated_on) from deletedborrowers group by date(updated_on); - Run cleanup : misc/cronjobs/cleanup_database.pl -v --delete-patrons 30 - Recount --- 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 f503bdc..efe81a1 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -44,7 +44,7 @@ use Koha::UploadedFiles; sub usage { print STDERR < \$help, @@ -139,6 +141,7 @@ GetOptions( 'uploads-missing:i' => \$uploads_missing, 'statistics:i' => \$pStatistics, 'deleted-catalog:i' => \$pDeletedCatalog, + 'deleted-patrons:i' => \$pDeletedPatrons, ) || usage(1); # Use default values @@ -174,6 +177,7 @@ unless ( $sessions || defined $uploads_missing || $pStatistics || $pDeletedCatalog + || $pDeletedPatrons ) { print "You did not specify any cleanup work for the script to do.\n\n"; usage(1); @@ -384,6 +388,18 @@ if ($pDeletedCatalog) { print "Done with purging deleted catalog.\n" if $verbose; } +if ($pDeletedPatrons) { + print "Purging deleted patrons older than $pDeletedPatrons days.\n" if $verbose; + $sth = $dbh->prepare( + q{ + DELETE FROM deletedborrowers + WHERE updated_on < DATE_SUB(CURDATE(), INTERVAL ? DAY) + } + ); + $sth->execute($pDeletedPatrons); + print "Done with purging deleted patrons.\n" if $verbose; +} + exit(0); sub RemoveOldSessions { -- 2.7.4