Bug 22435: DBRev 21.06.00.013

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-08-04 09:28:52 +00:00
parent 2ba7010899
commit 90bcfaff9a
3 changed files with 39 additions and 38 deletions

View File

@ -29,7 +29,7 @@ use vars qw{ $VERSION };
# - #4 : the developer version. The 4th number is the database subversion.
# used by developers when the database changes. updatedatabase take care of the changes itself
# and is automatically called by Auth.pm when needed.
$VERSION = "21.06.00.012";
$VERSION = "21.06.00.013";
sub version {
return $VERSION;

View File

@ -1,37 +0,0 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
# Remove foreign key for offset types
if ( foreign_key_exists( 'account_offsets', 'account_offsets_ibfk_t' ) ) {
$dbh->do( "ALTER TABLE account_offsets DROP FOREIGN KEY account_offsets_ibfk_t" );
}
# Drop account_offset_types table
$dbh->do( "DROP TABLE IF EXISTS account_offset_types" );
# Update offset_types to 'CREATE' where appropriate
$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)" );
$dbh->do( "UPDATE account_offsets SET amount = ABS(amount) WHERE type = 'CREATE'" );
# Update offset_types to 'APPLY' where appropriate
$dbh->do( "UPDATE account_offsets SET type = 'APPLY' WHERE type != 'OVERDUE_INCREASE' AND type != 'OVERDUE_DECREASE' AND type != 'CREATE' AND type != 'VOID'" );
# Update table to ENUM
$dbh->do(
q{
ALTER TABLE
`account_offsets`
MODIFY COLUMN
`type` enum(
'CREATE',
'APPLY',
'VOID',
'OVERDUE_INCREASE',
'OVERDUE_DECREASE'
)
AFTER `debit_id`
}
);
NewVersion( $DBversion, 22435, "Update existing offsets");
}

View File

@ -24542,6 +24542,44 @@ if( CheckVersion( $DBversion ) ) {
NewVersion( $DBversion, 15067, "Add missing languages" );
}
$DBversion = '21.06.00.013';
if( CheckVersion( $DBversion ) ) {
# Remove foreign key for offset types
if ( foreign_key_exists( 'account_offsets', 'account_offsets_ibfk_t' ) ) {
$dbh->do( "ALTER TABLE account_offsets DROP FOREIGN KEY account_offsets_ibfk_t" );
}
# Drop account_offset_types table
$dbh->do( "DROP TABLE IF EXISTS account_offset_types" );
# Update offset_types to 'CREATE' where appropriate
$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)" );
$dbh->do( "UPDATE account_offsets SET amount = ABS(amount) WHERE type = 'CREATE'" );
# Update offset_types to 'APPLY' where appropriate
$dbh->do( "UPDATE account_offsets SET type = 'APPLY' WHERE type != 'OVERDUE_INCREASE' AND type != 'OVERDUE_DECREASE' AND type != 'CREATE' AND type != 'VOID'" );
# Update table to ENUM
$dbh->do(
q{
ALTER TABLE
`account_offsets`
MODIFY COLUMN
`type` enum(
'CREATE',
'APPLY',
'VOID',
'OVERDUE_INCREASE',
'OVERDUE_DECREASE'
)
AFTER `debit_id`
}
);
NewVersion( $DBversion, 22435, "Update existing offsets");
}
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.
my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';