|
Line 0
Link Here
|
|
|
1 |
use Modern::Perl; |
| 2 |
|
| 3 |
return { |
| 4 |
bug_number => "", |
| 5 |
description => "Add display tables for display module", |
| 6 |
up => sub { |
| 7 |
my ($args) = @_; |
| 8 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
| 9 |
|
| 10 |
# Create displays table |
| 11 |
unless ( TableExists('displays') ) { |
| 12 |
$dbh->do( |
| 13 |
q{ |
| 14 |
CREATE TABLE IF NOT EXISTS `displays` ( |
| 15 |
`display_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique id for the display', |
| 16 |
`display_name` varchar(255) DEFAULT NULL COMMENT 'the name of the display', |
| 17 |
`start_date` date DEFAULT NULL COMMENT 'the start date of the display (optional)', |
| 18 |
`end_date` date DEFAULT NULL COMMENT 'the end date of the display (optional)', |
| 19 |
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'determines whether the display is active', |
| 20 |
`display_location` varchar(80) DEFAULT NULL COMMENT 'the shelving location for the display (optional)', |
| 21 |
`display_code` varchar(80) DEFAULT NULL COMMENT 'the collection code for the display (optional)', |
| 22 |
`display_branch` varchar(10) DEFAULT NULL COMMENT 'a new home branch for the item to have while on display (optional)', |
| 23 |
`display_holding_branch` varchar(10) DEFAULT NULL COMMENT 'a new holding branch for the item to have while on display (optional)', |
| 24 |
`display_itype` varchar(10) DEFAULT NULL COMMENT 'a new itype for the item to have while on display (optional)', |
| 25 |
`staff_note` mediumtext DEFAULT NULL COMMENT 'staff note for the display', |
| 26 |
`public_note` mediumtext DEFAULT NULL COMMENT 'public note for the display', |
| 27 |
`display_days` int(11) DEFAULT NULL COMMENT 'default number of days items will remain on display', |
| 28 |
`display_return_over` enum('yes - any library','yes - except at home library','no') NOT NULL DEFAULT 'no' COMMENT 'should the item be removed from the display when it is returned', |
| 29 |
PRIMARY KEY (`display_id`), |
| 30 |
KEY `display_branch` (`display_branch`), |
| 31 |
KEY `display_holding_branch` (`display_holding_branch`), |
| 32 |
KEY `display_itype` (`display_itype`), |
| 33 |
CONSTRAINT `displays_ibfk_1` FOREIGN KEY (`display_branch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, |
| 34 |
CONSTRAINT `displays_ibfk_2` FOREIGN KEY (`display_holding_branch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, |
| 35 |
CONSTRAINT `displays_ibfk_3` FOREIGN KEY (`display_itype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE |
| 36 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci |
| 37 |
} |
| 38 |
); |
| 39 |
|
| 40 |
say $out "Added new table 'displays'"; |
| 41 |
} |
| 42 |
|
| 43 |
# Create display_items table |
| 44 |
unless ( TableExists('display_items') ) { |
| 45 |
$dbh->do( |
| 46 |
q{ |
| 47 |
CREATE TABLE IF NOT EXISTS `display_items` ( |
| 48 |
`display_item_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', |
| 49 |
`display_id` int(11) NOT NULL COMMENT 'foreign key to link to displays.display_id', |
| 50 |
`itemnumber` int(11) DEFAULT NULL COMMENT 'items.itemnumber for the item on display', |
| 51 |
`biblionumber` int(11) DEFAULT NULL COMMENT 'biblio.biblionumber for the bibliographic record on display', |
| 52 |
`date_added` date DEFAULT NULL COMMENT 'the date the item was added to the display', |
| 53 |
`date_remove` date DEFAULT NULL COMMENT 'the date the item should be removed from the display', |
| 54 |
PRIMARY KEY (`display_item_id`), |
| 55 |
UNIQUE KEY `display_items_uniq` (`display_id`,`itemnumber`), |
| 56 |
KEY `display_id` (`display_id`), |
| 57 |
KEY `itemnumber` (`itemnumber`), |
| 58 |
KEY `biblionumber` (`biblionumber`), |
| 59 |
CONSTRAINT `display_items_ibfk_1` FOREIGN KEY (`display_id`) REFERENCES `displays` (`display_id`) ON DELETE CASCADE ON UPDATE CASCADE, |
| 60 |
CONSTRAINT `display_items_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, |
| 61 |
CONSTRAINT `display_items_ibfk_3` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE |
| 62 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci |
| 63 |
} |
| 64 |
); |
| 65 |
|
| 66 |
say $out "Added new table 'display_items'"; |
| 67 |
} |
| 68 |
|
| 69 |
# Add UseDisplayModule system preference |
| 70 |
$dbh->do( |
| 71 |
q{ |
| 72 |
INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) |
| 73 |
VALUES ('UseDisplayModule', '0', NULL, 'Enable the display module for managing item displays.', 'YesNo') |
| 74 |
} |
| 75 |
); |
| 76 |
say $out "Added UseDisplayModule system preference"; |
| 77 |
|
| 78 |
# Add displays user flag |
| 79 |
$dbh->do( |
| 80 |
q{ |
| 81 |
INSERT IGNORE INTO userflags (bit, flag, flagdesc, defaulton) |
| 82 |
VALUES (31, 'displays', 'Display module', 0) |
| 83 |
} |
| 84 |
); |
| 85 |
say $out "Added displays user flag"; |
| 86 |
|
| 87 |
# Add display permissions |
| 88 |
$dbh->do( |
| 89 |
q{ |
| 90 |
INSERT IGNORE INTO permissions (module_bit, code, description) VALUES |
| 91 |
(31, 'add_display', 'Add displays'), |
| 92 |
(31, 'edit_display', 'Edit displays'), |
| 93 |
(31, 'delete_display', 'Delete displays'), |
| 94 |
(31, 'add_items_to_display', 'Add items to displays'), |
| 95 |
(31, 'add_items_to_display_from_any_libraries', 'Add items to displays from any libraries'), |
| 96 |
(31, 'remove_items_from_display', 'Remove items from displays') |
| 97 |
} |
| 98 |
); |
| 99 |
say $out "Added display permissions"; |
| 100 |
|
| 101 |
# Add ft_display_group column to library_groups table |
| 102 |
unless ( column_exists( 'library_groups', 'ft_display_group' ) ) { |
| 103 |
$dbh->do( |
| 104 |
q{ |
| 105 |
ALTER TABLE library_groups |
| 106 |
ADD COLUMN `ft_display_group` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group to identify libraries that can share display items' AFTER `ft_local_float_group` |
| 107 |
} |
| 108 |
); |
| 109 |
say $out "Added ft_display_group column to library_groups table"; |
| 110 |
} |
| 111 |
}, |
| 112 |
}; |