From 90bcfaff9a30e92bccf55699b7cd0aec0f16595a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 4 Aug 2021 09:28:52 +0000 Subject: [PATCH] Bug 22435: DBRev 21.06.00.013 Signed-off-by: Jonathan Druart --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_22435.perl | 37 ------------------ installer/data/mysql/updatedatabase.pl | 38 +++++++++++++++++++ 3 files changed, 39 insertions(+), 38 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_22435.perl diff --git a/Koha.pm b/Koha.pm index 77a3f819cb..173f3f29f7 100644 --- a/Koha.pm +++ b/Koha.pm @@ -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; diff --git a/installer/data/mysql/atomicupdate/bug_22435.perl b/installer/data/mysql/atomicupdate/bug_22435.perl deleted file mode 100644 index 2862574b71..0000000000 --- a/installer/data/mysql/atomicupdate/bug_22435.perl +++ /dev/null @@ -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"); -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index fe2fe27d88..b326bcf55f 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -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/'; -- 2.39.5