From 9cb2ff97d2cd340928224ff688cf1b9647ca61b7 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Mon, 14 Mar 2022 21:50:34 -1000 Subject: [PATCH] Bug 19532: DBRev 21.12.00.018 Signed-off-by: Fridolin Somers --- Koha.pm | 2 +- ...9532-add_recalls_enum_branchtransfers.perl | 6 -- .../bug_19532-add_recalls_flags.perl | 7 -- .../bug_19532-add_recalls_notices.perl | 36 ------- .../bug_19532-add_recalls_sysprefs.perl | 11 --- .../bug_19532-add_recalls_table.perl | 34 ------- .../bug_19532_make_status_enum.pl | 16 --- installer/data/mysql/db_revs/211200018.pl | 99 +++++++++++++++++++ 8 files changed, 100 insertions(+), 111 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_19532-add_recalls_enum_branchtransfers.perl delete mode 100644 installer/data/mysql/atomicupdate/bug_19532-add_recalls_flags.perl delete mode 100644 installer/data/mysql/atomicupdate/bug_19532-add_recalls_notices.perl delete mode 100644 installer/data/mysql/atomicupdate/bug_19532-add_recalls_sysprefs.perl delete mode 100644 installer/data/mysql/atomicupdate/bug_19532-add_recalls_table.perl delete mode 100755 installer/data/mysql/atomicupdate/bug_19532_make_status_enum.pl create mode 100755 installer/data/mysql/db_revs/211200018.pl diff --git a/Koha.pm b/Koha.pm index 96315e60c4..3bed05d5d2 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.12.00.017"; +$VERSION = "21.12.00.018"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_enum_branchtransfers.perl b/installer/data/mysql/atomicupdate/bug_19532-add_recalls_enum_branchtransfers.perl deleted file mode 100644 index 654242817e..0000000000 --- a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_enum_branchtransfers.perl +++ /dev/null @@ -1,6 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ ALTER TABLE branchtransfers MODIFY COLUMN reason ENUM('Manual', 'StockrotationAdvance', 'StockrotationRepatriation', 'ReturnToHome', 'ReturnToHolding', 'RotatingCollection', 'Reserve', 'LostReserve', 'CancelReserve', 'Recall', 'CancelRecall') }); - - NewVersion( $DBversion, 19532, "Add Recall and CancelReserve ENUM options to branchtransfers.reason" ); -} diff --git a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_flags.perl b/installer/data/mysql/atomicupdate/bug_19532-add_recalls_flags.perl deleted file mode 100644 index 5ece22846e..0000000000 --- a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_flags.perl +++ /dev/null @@ -1,7 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ INSERT IGNORE INTO userflags (bit, flag, flagdesc, defaulton) VALUES (27, 'recalls', 'Recalls', 0) }); - $dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (27, 'manage_recalls', 'Manage recalls for patrons') }); - - NewVersion( $DBversion, 19532, "Add recalls user flag and manage_recalls user permission" ); -} diff --git a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_notices.perl b/installer/data/mysql/atomicupdate/bug_19532-add_recalls_notices.perl deleted file mode 100644 index d3921778df..0000000000 --- a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_notices.perl +++ /dev/null @@ -1,36 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ - INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES - ('circulation','RETURN_RECALLED_ITEM','','Notification to return a recalled item','0','Notification to return a recalled item','Date: <> - -<> <>, - -A recall has been placed on the following item: <> / <> (<>). The due date has been updated, and is now <>. Please return the item before the due date. - -Thank you!','email'), - ('circulation','PICKUP_RECALLED_ITEM','','Recalled item awaiting pickup','0','Recalled item awaiting pickup','Date: <> - -<> <>, - -A recall that you requested on the following item: <> / <> (<>) is now ready for you to pick up at <>. Please pick up your item by <>. - -Thank you!','email'), - ('circulation','RECALL_REQUESTER_DET','','Details of patron who recalled item',0,'Details of patron who recalled item','Date: <> - -Recall for pickup at <> -<>, <> (<>) -<> -<> <>, <>, <> <> -<> - -ITEM RECALLED -<> by <> -Barcode: <> -Callnumber: <> -Waiting since: <> -Notes: <>', 'print') - }); - - NewVersion( $DBversion, 19532, "Add recalls notices: RETURN_RECALLED_ITEM, PICKUP_RECALLED_ITEM, RECALL_REQUESTER_DET" ); -} diff --git a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_sysprefs.perl b/installer/data/mysql/atomicupdate/bug_19532-add_recalls_sysprefs.perl deleted file mode 100644 index c5d48271e7..0000000000 --- a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_sysprefs.perl +++ /dev/null @@ -1,11 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ - INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES - ('RecallsLog','1',NULL,'If ON, log create/cancel/expire/fulfill actions on recalls','YesNo'), - ('RecallsMaxPickUpDelay','7',NULL,'Define the maximum time a recall can be awaiting pickup','Integer'), - ('UseRecalls','0',NULL,'Enable or disable recalls','YesNo') - }); - - NewVersion( $DBversion, 19532, "Add RecallsLog, RecallsMaxPickUpDelay and UseRecalls system preferences"); -} diff --git a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_table.perl b/installer/data/mysql/atomicupdate/bug_19532-add_recalls_table.perl deleted file mode 100644 index 57aaabd3ad..0000000000 --- a/installer/data/mysql/atomicupdate/bug_19532-add_recalls_table.perl +++ /dev/null @@ -1,34 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ) { - $dbh->do(q{ DROP TABLE IF EXISTS recalls }); - $dbh->do(q{ - CREATE TABLE recalls ( - recall_id int(11) NOT NULL auto_increment, - borrowernumber int(11) NOT NULL DEFAULT 0, - recalldate datetime DEFAULT NULL, - biblionumber int(11) NOT NULL DEFAULT 0, - branchcode varchar(10) DEFAULT NULL, - cancellationdate datetime DEFAULT NULL, - recallnotes mediumtext, - priority smallint(6) DEFAULT NULL, - status varchar(1) DEFAULT NULL, - timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - itemnumber int(11) DEFAULT NULL, - waitingdate datetime DEFAULT NULL, - expirationdate datetime DEFAULT NULL, - old TINYINT(1) DEFAULT NULL, - item_level_recall TINYINT(1) NOT NULL DEFAULT 0, - PRIMARY KEY (recall_id), - KEY borrowernumber (borrowernumber), - KEY biblionumber (biblionumber), - KEY itemnumber (itemnumber), - KEY branchcode (branchcode), - CONSTRAINT recalls_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT recalls_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT recalls_ibfk_3 FOREIGN KEY (itemnumber) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT recalls_ibfk_4 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - }); - - NewVersion( $DBversion, 19532, "Add recalls table" ); -} diff --git a/installer/data/mysql/atomicupdate/bug_19532_make_status_enum.pl b/installer/data/mysql/atomicupdate/bug_19532_make_status_enum.pl deleted file mode 100755 index 9935c9cbf2..0000000000 --- a/installer/data/mysql/atomicupdate/bug_19532_make_status_enum.pl +++ /dev/null @@ -1,16 +0,0 @@ -use Modern::Perl; - -return { - bug_number => "19532", - description => "Make recalls.status an enum", - up => sub { - my ($args) = @_; - my ($dbh) = @$args{qw(dbh)}; - - $dbh->do(q{ - ALTER TABLE recalls - MODIFY COLUMN - status ENUM('requested','overdue','waiting','in_transit','cancelled','expired','fulfilled') DEFAULT 'requested' COMMENT "Request status" - }); - }, -}; diff --git a/installer/data/mysql/db_revs/211200018.pl b/installer/data/mysql/db_revs/211200018.pl new file mode 100755 index 0000000000..5b57350cdd --- /dev/null +++ b/installer/data/mysql/db_revs/211200018.pl @@ -0,0 +1,99 @@ +use Modern::Perl; + +return { + bug_number => "19532", + description => "Add Recalls", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + unless( TableExists('recalls') ) { + + # Add recalls table + $dbh->do(q{ + CREATE TABLE recalls ( + recall_id int(11) NOT NULL auto_increment, + borrowernumber int(11) NOT NULL DEFAULT 0, + recalldate datetime DEFAULT NULL, + biblionumber int(11) NOT NULL DEFAULT 0, + branchcode varchar(10) DEFAULT NULL, + cancellationdate datetime DEFAULT NULL, + recallnotes mediumtext, + priority smallint(6) DEFAULT NULL, + status status ENUM('requested','overdue','waiting','in_transit','cancelled','expired','fulfilled') DEFAULT 'requested', + timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + itemnumber int(11) DEFAULT NULL, + waitingdate datetime DEFAULT NULL, + expirationdate datetime DEFAULT NULL, + old TINYINT(1) DEFAULT NULL, + item_level_recall TINYINT(1) NOT NULL DEFAULT 0, + PRIMARY KEY (recall_id), + KEY borrowernumber (borrowernumber), + KEY biblionumber (biblionumber), + KEY itemnumber (itemnumber), + KEY branchcode (branchcode), + CONSTRAINT recalls_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT recalls_ibfk_2 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT recalls_ibfk_3 FOREIGN KEY (itemnumber) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT recalls_ibfk_4 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + + # Add RecallsLog, RecallsMaxPickUpDelay and UseRecalls system preferences + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES + ('RecallsLog','1',NULL,'If ON, log create/cancel/expire/fulfill actions on recalls','YesNo'), + ('RecallsMaxPickUpDelay','7',NULL,'Define the maximum time a recall can be awaiting pickup','Integer'), + ('UseRecalls','0',NULL,'Enable or disable recalls','YesNo') + }); + + # Add recalls notices: RETURN_RECALLED_ITEM, PICKUP_RECALLED_ITEM, RECALL_REQUESTER_DET + $dbh->do(q{ + INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES + ('circulation','RETURN_RECALLED_ITEM','','Notification to return a recalled item','0','Notification to return a recalled item','Date: <> + +<> <>, + +A recall has been placed on the following item: <> / <> (<>). The due date has been updated, and is now <>. Please return the item before the due date. + +Thank you!','email'), + ('circulation','PICKUP_RECALLED_ITEM','','Recalled item awaiting pickup','0','Recalled item awaiting pickup','Date: <> + +<> <>, + +A recall that you requested on the following item: <> / <> (<>) is now ready for you to pick up at <>. Please pick up your item by <>. + +Thank you!','email'), + ('circulation','RECALL_REQUESTER_DET','','Details of patron who recalled item',0,'Details of patron who recalled item','Date: <> + +Recall for pickup at <> +<>, <> (<>) +<> +<> <>, <>, <> <> +<> + +ITEM RECALLED +<> by <> +Barcode: <> +Callnumber: <> +Waiting since: <> +Notes: <>', 'print') + }); + + # Add recalls user flag and manage_recalls user permission + $dbh->do(q{ + INSERT IGNORE INTO userflags (bit, flag, flagdesc, defaulton) VALUES (27, 'recalls', 'Recalls', 0) + }); + $dbh->do(q{ + INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (27, 'manage_recalls', 'Manage recalls for patrons') + }); + + # Add Recall and CancelReserve ENUM options to branchtransfers.reason + $dbh->do(q{ + ALTER TABLE branchtransfers MODIFY COLUMN reason + ENUM('Manual', 'StockrotationAdvance', 'StockrotationRepatriation', 'ReturnToHome', 'ReturnToHolding', 'RotatingCollection', 'Reserve', 'LostReserve', 'CancelReserve', 'Recall', 'CancelRecall') + }); + + } + }, +}; -- 2.39.5