5 description => "Update existing offsets",
8 my $dbh = $args->{dbh};
10 # Remove foreign key for offset types
11 if ( foreign_key_exists( 'account_offsets', 'account_offsets_ibfk_t' ) ) {
12 $dbh->do( "ALTER TABLE account_offsets DROP FOREIGN KEY account_offsets_ibfk_t" );
15 # Drop account_offset_types table
16 $dbh->do( "DROP TABLE IF EXISTS account_offset_types" );
18 # Update offset_types to 'CREATE' where appropriate
19 $dbh->do( "UPDATE account_offsets SET type = 'CREATE' WHERE type != 'OVERDUE_INCREASE' AND type != 'OVERDUE_DECREASE' AND ( debit_id IS NULL OR credit_id IS NULL)" );
20 $dbh->do( "UPDATE account_offsets SET amount = ABS(amount) WHERE type = 'CREATE'" );
22 # Update offset_types to 'APPLY' where appropriate
23 $dbh->do( "UPDATE account_offsets SET type = 'APPLY' WHERE type != 'OVERDUE_INCREASE' AND type != 'OVERDUE_DECREASE' AND type != 'CREATE' AND type != 'VOID'" );
25 # Update table to ENUM