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

(-)a/installer/data/mysql/atomicupdate/bug_24532.perl (-1 / +43 lines)
Line 0 Link Here
0
- 
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    # Add any pathalogical incorrect debit_types as credit_types as appropriate
5
    $dbh->do(
6
        qq{
7
          INSERT IGNORE INTO account_credit_types (
8
            code,
9
            description,
10
            can_be_added_manually,
11
            is_system
12
          )
13
          SELECT
14
            DISTINCT(debit_type_code),
15
            "Unexpected type found during upgrade",
16
            1,
17
            0
18
          FROM
19
            accountlines
20
          WHERE
21
            amount < 0
22
          AND
23
            debit_type_code IS NOT NULL
24
        }
25
    );
26
27
    # Correct any pathalogical cases
28
    $dbh->do( qq{
29
      UPDATE
30
        accountlines
31
      SET
32
        credit_type_code = debit_type_code,
33
        debit_type_code = NULL
34
      WHERE
35
        amount < 0
36
      AND
37
        debit_type_code IS NOT NULL
38
    });
39
40
    # Always end with this (adjust the bug info)
41
    SetVersion( $DBversion );
42
    print "Upgrade to $DBversion done (Bug XXXXX - description)\n";
43
}

Return to bug 24532