@@ -, +, @@ --- installer/data/mysql/account_credit_types.sql | 2 +- installer/data/mysql/account_offset_types.sql | 1 + installer/data/mysql/atomicupdate/bug_24592.perl | 49 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_24592.perl --- a/installer/data/mysql/account_credit_types.sql +++ a/installer/data/mysql/account_credit_types.sql @@ -3,4 +3,4 @@ INSERT INTO account_credit_types ( code, description, can_be_added_manually, is_ ('WRITEOFF', 'Writeoff', 0, 1), ('FORGIVEN', 'Forgiven', 1, 1), ('CREDIT', 'Credit', 1, 1), -('LOST_RETURN', 'Lost item fee refund', 0, 1); +('LOST_FOUND', 'Lost item fee refund', 0, 1); --- a/installer/data/mysql/account_offset_types.sql +++ a/installer/data/mysql/account_offset_types.sql @@ -2,6 +2,7 @@ INSERT INTO account_offset_types ( type ) VALUES ('Writeoff'), ('Payment'), ('Lost Item'), +('Lost Item Found'), ('Processing Fee'), ('Manual Credit'), ('Manual Debit'), --- a/installer/data/mysql/atomicupdate/bug_24592.perl +++ a/installer/data/mysql/atomicupdate/bug_24592.perl @@ -0,0 +1,49 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + # Add LOST_FOUND debit type + $dbh->do(qq{ + INSERT IGNORE INTO + account_credit_types ( code, description, can_be_added_manually, is_system ) + VALUES + ('LOST_FOUND', 'Lost item fee refund', 0, 1) + }); + + # Migrate LOST_RETURN to LOST_FOUND + $dbh->do(qq{ + UPDATE + accountlines + SET + credit_type_code = 'LOST_FOUND' + WHERE + credit_type_code = 'LOST_RETURN' + }); + + # Migrate LOST + RETURNED to LOST + FOUND + $dbh->do(qq{ + UPDATE + accountlines + SET + status = 'FOUND' + WHERE + debit_type_code = 'LOST' + AND + status = 'RETURNED' + }); + + # Drop LOST_RETURNED credit type + $dbh->do(qq{ + DELETE FROM account_credit_types WHERE code = 'LOST_RETURN' + }); + + # Add Lost Item Found offset type + $dbh->do(qq{ + INSERT IGNORE INTO + account_offset_types ( type ) + VALUES + ( 'Lost Item Found' ) + }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 24592 - Update LOST_RETURN to LOST_FOUND)\n"; +} --