Bug 26940: Put in sync borrowers.debarredcomment with comments from borrower_debarment

Signed-off-by: Katariina Hanhisalo <katariina.hanhisalo@xamk.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-11-17 12:18:48 +01:00
parent 3b9f1e1560
commit c309ee36dd

View file

@ -0,0 +1,22 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
my $debar = $dbh->selectall_arrayref(q|
SELECT d.borrowernumber, GROUP_CONCAT(comment SEPARATOR '\n') AS comment
FROM borrower_debarments d
LEFT JOIN borrowers b ON b.borrowernumber=d.borrowernumber
WHERE b.debarredcomment IS NULL AND ( expiration > CURRENT_DATE() OR expiration IS NULL )
GROUP BY d.borrowernumber
|, { Slice => {} });
my $update_sth = $dbh->prepare(q|
UPDATE borrowers
SET debarredcomment=?
WHERE borrowernumber=?
|);
for my $d ( @$debar ) {
$update_sth->execute($d->{comment}, $d->{borrowernumber});
}
NewVersion( $DBversion, 26940, "Put in sync borrowers.debarredcomment with comments from borrower_debarments");
}