Bug 24532: Fix misidentified credit_types from bug 23049
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
1a5efe389d
commit
c6bdb0fda8
1 changed files with 43 additions and 0 deletions
43
installer/data/mysql/atomicupdate/bug_24532.perl
Normal file
43
installer/data/mysql/atomicupdate/bug_24532.perl
Normal file
|
@ -0,0 +1,43 @@
|
|||
$DBversion = 'XXX'; # will be replaced by the RM
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
|
||||
# Add any pathalogical incorrect debit_types as credit_types as appropriate
|
||||
$dbh->do(
|
||||
qq{
|
||||
INSERT IGNORE INTO account_credit_types (
|
||||
code,
|
||||
description,
|
||||
can_be_added_manually,
|
||||
is_system
|
||||
)
|
||||
SELECT
|
||||
DISTINCT(debit_type_code),
|
||||
"Unexpected type found during upgrade",
|
||||
1,
|
||||
0
|
||||
FROM
|
||||
accountlines
|
||||
WHERE
|
||||
amount < 0
|
||||
AND
|
||||
debit_type_code IS NOT NULL
|
||||
}
|
||||
);
|
||||
|
||||
# Correct any pathalogical cases
|
||||
$dbh->do( qq{
|
||||
UPDATE
|
||||
accountlines
|
||||
SET
|
||||
credit_type_code = debit_type_code,
|
||||
debit_type_code = NULL
|
||||
WHERE
|
||||
amount < 0
|
||||
AND
|
||||
debit_type_code IS NOT NULL
|
||||
});
|
||||
|
||||
# Always end with this (adjust the bug info)
|
||||
SetVersion( $DBversion );
|
||||
print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
|
||||
}
|
Loading…
Reference in a new issue