From be89fe2d9a2a92ec99a9b8cf7d793737cf6462ab 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. --- .../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..6342c1896f --- /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 dde5569908..dc945751ac 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