From f2aeaede38b05cb93146d9fbe86bcd4a2a76b8d5 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 --deleted-patrons 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 --- 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 8bb7f8605d..3573db7839 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, @@ -140,6 +142,7 @@ GetOptions( 'oauth-tokens' => \$oauth_tokens, 'statistics:i' => \$pStatistics, 'deleted-catalog:i' => \$pDeletedCatalog, + 'deleted-patrons:i' => \$pDeletedPatrons, ) || usage(1); # Use default values @@ -176,6 +179,7 @@ unless ( $sessions || $oauth_tokens || $pStatistics || $pDeletedCatalog + || $pDeletedPatrons ) { print "You did not specify any cleanup work for the script to do.\n\n"; usage(1); @@ -416,6 +420,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.39.5