From 7555441ace13ff32cbefa890d8a7e35f5a5dc9ac Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 18 Oct 2019 13:02:16 +0100 Subject: [PATCH] Bug 23049: (QA follow-up) DB Update Improvements Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize --- .../mysql/atomicupdate/bug_23049_debit.perl | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_23049_debit.perl b/installer/data/mysql/atomicupdate/bug_23049_debit.perl index 8ed3820b9c..cd5cfa7be4 100644 --- a/installer/data/mysql/atomicupdate/bug_23049_debit.perl +++ b/installer/data/mysql/atomicupdate/bug_23049_debit.perl @@ -83,6 +83,17 @@ if ( CheckVersion($DBversion) ) { } ); + # Catch 'F' cases introduced since bug 22521 + $dbh->do(qq{ + UPDATE + accountlines + SET + accounttype = 'OVERDUE', + status = 'RETURNED' + WHERE + accounttype = 'F'; + }); + # Moving MANUAL_INV to account_debit_types $dbh->do( qq{ @@ -94,7 +105,7 @@ if ( CheckVersion($DBversion) ) { is_system ) SELECT - SUBSTR(authorised_value, 1, 80), + authorised_value, lib, authorised_value, 1, @@ -106,6 +117,22 @@ if ( CheckVersion($DBversion) ) { } ); + # Update uncaught partial accounttypes left behind after bugs 23539 and 22521 + my $sth = $dbh->prepare( "SELECT code, SUBSTR(code, 1,5) AS subcode FROM account_debit_types" ); + $sth->execute(); + while ( my $row = $sth->fetchrow_hashref ) { + $dbh->do( + qq{ + UPDATE accountlines SET accounttype = ? WHERE accounttype = ? + }, + {}, + ( + $row->{code}, + $row->{subcode} + ) + ); + } + # Add any unexpected accounttype codes to debit_types as appropriate $dbh->do( qq{ @@ -117,7 +144,7 @@ if ( CheckVersion($DBversion) ) { is_system ) SELECT - SUBSTR(accounttype, 1, 80), + DISTINCT(accounttype), "Unexpected type found during upgrade", 1, NULL, -- 2.39.2