From 126951c83cb912ea76529556f7608ce0dd7fc2d7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 16 Jan 2020 09:01:34 +0000 Subject: [PATCH] Bug 24296: Update existing data in the database This DB udpate adds the stockration states to the trigger enum in the branchtransfers table and then populates it with any such data currently contained within the comments field. https://bugs.koha-community.org/show_bug.cgi?id=24292 --- .../data/mysql/atomicupdate/bug_24296.perl | 45 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_24296.perl diff --git a/installer/data/mysql/atomicupdate/bug_24296.perl b/installer/data/mysql/atomicupdate/bug_24296.perl new file mode 100644 index 0000000000..41fe00b8f9 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24296.perl @@ -0,0 +1,45 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + # Add stockrotation states to trigger enum + $dbh->do( + qq{ + ALTER TABLE + `branchtransfers` + MODIFY COLUMN + `trigger` enum( + 'Manual', + 'StockrotationAdvance', + 'StockrotationRepatriation' + ) + AFTER `comments` + } + ); + + # Move stockrotation states to trigger field + $dbh->do( + qq{ + UPDATE + `branchtransfers` + SET + `trigger` = 'StockrotationAdvance', + `comments` = NULL + WHERE + `comments` = 'StockrotationAdvance' + } + ); + $dbh->do( + qq{ + UPDATE + `branchtransfers` + SET + `trigger` = 'StockrotationRepatriation', + `comments` = NULL + WHERE + `comments` = 'StockrotationRepatriation' + } + ); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 24296 - Update stockrotation to use 'trigger' field in transfers table)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 4454b14969..5a62c3db39 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -951,7 +951,7 @@ CREATE TABLE `branchtransfers` ( -- information for items that are in transit be `datearrived` datetime default NULL, -- the date the transfer arrived at its destination `tobranch` varchar(10) NOT NULL default '', -- the branch the transfer was going to `comments` LONGTEXT, -- any comments related to the transfer - `trigger` ENUM('Manual'), -- what triggered the transfer + `trigger` ENUM('Manual', 'StockrotationAdvance', 'StockrotationRepatriation'), -- what triggered the transfer PRIMARY KEY (`branchtransfer_id`), KEY `frombranch` (`frombranch`), KEY `tobranch` (`tobranch`), -- 2.20.1