View | Details | Raw Unified | Return to bug 26940
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_26940.perl (-1 / +22 lines)
Line 0 Link Here
0
- 
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    my $debar = $dbh->selectall_arrayref(q|
4
        SELECT d.borrowernumber, GROUP_CONCAT(comment SEPARATOR '\n') AS comment
5
        FROM borrower_debarments d
6
        LEFT JOIN borrowers b ON b.borrowernumber=d.borrowernumber
7
        WHERE b.debarredcomment IS NULL AND ( expiration > CURRENT_DATE() OR expiration IS NULL )
8
        GROUP BY d.borrowernumber
9
    |, { Slice => {} });
10
11
12
    my $update_sth = $dbh->prepare(q|
13
        UPDATE borrowers
14
        SET debarredcomment=?
15
        WHERE borrowernumber=?
16
    |);
17
    for my $d ( @$debar ) {
18
        $update_sth->execute($d->{comment}, $d->{borrowernumber});
19
    }
20
21
    NewVersion( $DBversion, 26940, "Put in sync borrowers.debarredcomment with comments from borrower_debarments");
22
}

Return to bug 26940