From f1f1c2e9b12d8d7bbcf5d88ad739e098a6031aef Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 28 Jan 2020 15:05:44 +0000 Subject: [PATCH] Bug 24296: DBRev 19.12.00.015 Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- Koha/Schema/Result/Branchtransfer.pm | 14 ++++-- .../data/mysql/atomicupdate/bug_24296.perl | 45 ------------------ installer/data/mysql/updatedatabase.pl | 46 +++++++++++++++++++ 4 files changed, 57 insertions(+), 50 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_24296.perl diff --git a/Koha.pm b/Koha.pm index a80840c9a4..18b417c258 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 = "19.12.00.014"; +$VERSION = "19.12.00.015"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/Branchtransfer.pm b/Koha/Schema/Result/Branchtransfer.pm index 01409019a0..47a55b48f6 100644 --- a/Koha/Schema/Result/Branchtransfer.pm +++ b/Koha/Schema/Result/Branchtransfer.pm @@ -72,7 +72,7 @@ __PACKAGE__->table("branchtransfers"); =head2 reason data_type: 'enum' - extra: {list => ["Manual"]} + extra: {list => ["Manual","StockrotationAdvance","StockrotationRepatriation"]} is_nullable: 1 =cut @@ -118,7 +118,13 @@ __PACKAGE__->add_columns( "comments", { data_type => "longtext", is_nullable => 1 }, "reason", - { data_type => "enum", extra => { list => ["Manual"] }, is_nullable => 1 }, + { + data_type => "enum", + extra => { + list => ["Manual", "StockrotationAdvance", "StockrotationRepatriation"], + }, + is_nullable => 1, + }, ); =head1 PRIMARY KEY @@ -181,8 +187,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-01-28 15:01:05 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vN1IPDN+R7eqJ9BxMdlg4A +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-01-28 15:04:48 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PD2BJD5BaNcemKr2k7zPGA sub koha_object_class { 'Koha::Item::Transfer'; diff --git a/installer/data/mysql/atomicupdate/bug_24296.perl b/installer/data/mysql/atomicupdate/bug_24296.perl deleted file mode 100644 index 92d7c9a9e2..0000000000 --- a/installer/data/mysql/atomicupdate/bug_24296.perl +++ /dev/null @@ -1,45 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - - # Add stockrotation states to reason enum - $dbh->do( - qq{ - ALTER TABLE - `branchtransfers` - MODIFY COLUMN - `reason` enum( - 'Manual', - 'StockrotationAdvance', - 'StockrotationRepatriation' - ) - AFTER `comments` - } - ); - - # Move stockrotation states to reason field - $dbh->do( - qq{ - UPDATE - `branchtransfers` - SET - `reason` = 'StockrotationAdvance', - `comments` = NULL - WHERE - `comments` = 'StockrotationAdvance' - } - ); - $dbh->do( - qq{ - UPDATE - `branchtransfers` - SET - `reason` = 'StockrotationRepatriation', - `comments` = NULL - WHERE - `comments` = 'StockrotationRepatriation' - } - ); - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 24296 - Update stockrotation to use 'reason' field in transfers table)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f4445437b7..3e6a208ff1 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20594,6 +20594,52 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 24287 - Add 'reason' field to transfers table)\n"; } +$DBversion = '19.12.00.015'; +if( CheckVersion( $DBversion ) ) { + + # Add stockrotation states to reason enum + $dbh->do( + qq{ + ALTER TABLE + `branchtransfers` + MODIFY COLUMN + `reason` enum( + 'Manual', + 'StockrotationAdvance', + 'StockrotationRepatriation' + ) + AFTER `comments` + } + ); + + # Move stockrotation states to reason field + $dbh->do( + qq{ + UPDATE + `branchtransfers` + SET + `reason` = 'StockrotationAdvance', + `comments` = NULL + WHERE + `comments` = 'StockrotationAdvance' + } + ); + $dbh->do( + qq{ + UPDATE + `branchtransfers` + SET + `reason` = 'StockrotationRepatriation', + `comments` = NULL + WHERE + `comments` = 'StockrotationRepatriation' + } + ); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 24296 - Update stockrotation to use 'reason' field in transfers table)\n"; +} + # 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