From d6edac3f7bfc1bf59227b273eb0bceac5a3415e4 Mon Sep 17 00:00:00 2001
From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Date: Fri, 26 Nov 2021 07:53:44 +0000
Subject: [PATCH] Bug 29457: (QA follow-up) Warn number of missing manager_id's
Content-Type: text/plain; charset=utf-8

No sense in trying to match userid's with borrowernumbers. In 99%
of the cases (at least) we will find just NULLs.
We could print the number we found.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
---
 installer/data/mysql/atomicupdate/bug_29457.pl | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100755 installer/data/mysql/atomicupdate/bug_29457.pl

diff --git a/installer/data/mysql/atomicupdate/bug_29457.pl b/installer/data/mysql/atomicupdate/bug_29457.pl
new file mode 100755
index 0000000000..732c919fbd
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_29457.pl
@@ -0,0 +1,12 @@
+use Modern::Perl;
+
+return {
+    bug_number => "29457",
+    description => "Warn about missing manager_id in cancelled account lines",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out)};
+        my ( $count ) = $dbh->selectrow_array( q{SELECT COUNT(*) FROM accountlines WHERE credit_type_code = 'CANCELLATION' AND manager_id is NULL} );
+        say "Note: We counted $count cancellations in accountlines with an empty manager_id. We regret that this information is missing, but it can't hurt. This release fixed the bug causing it." if $count;
+    },
+}
-- 
2.20.1