Line 0
Link Here
|
|
|
1 |
use Modern::Perl; |
2 |
|
3 |
return { |
4 |
bug_number => "23681", |
5 |
description => "Add customisable patron restriction types", |
6 |
up => sub { |
7 |
my ($args) = @_; |
8 |
my ($dbh, $out) = @$args{qw(dbh out)}; |
9 |
|
10 |
$dbh->do(q{ |
11 |
CREATE TABLE IF NOT EXISTS debarment_types ( |
12 |
code varchar(50) NOT NULL PRIMARY KEY, |
13 |
display_text text NOT NULL, |
14 |
is_system tinyint(1) NOT NULL DEFAULT 0, |
15 |
default_value tinyint(1) NOT NULL DEFAULT 0, |
16 |
can_be_added_manually tinyint(1) NOT NULL DEFAULT 0 |
17 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |
18 |
}); |
19 |
say $out "Added debarment_types table"; |
20 |
|
21 |
$dbh->do(q{ |
22 |
INSERT IGNORE INTO debarment_types (code, display_text, is_system, default_value, can_be_added_manually) VALUES |
23 |
('MANUAL', 'Manual', 1, 1, 0), |
24 |
('OVERDUES', 'Overdues', 1, 0, 0), |
25 |
('SUSPENSION', 'Suspension', 1, 0, 0), |
26 |
('DISCHARGE', 'Discharge', 1, 0, 0); |
27 |
}); |
28 |
say $out "Added system debarment_types"; |
29 |
|
30 |
unless ( foreign_key_exists('borrower_debarments', 'borrower_debarments_ibfk_2') ) { |
31 |
$dbh->do(q{ |
32 |
ALTER TABLE borrower_debarments |
33 |
MODIFY COLUMN type varchar(50) NOT NULL |
34 |
}); |
35 |
$dbh->do(q{ |
36 |
ALTER TABLE borrower_debarments |
37 |
ADD CONSTRAINT borrower_debarments_ibfk_2 FOREIGN KEY (type) REFERENCES debarment_types(code) ON DELETE NO ACTION ON UPDATE CASCADE; |
38 |
}); |
39 |
say $out "Added borrower_debarments relation"; |
40 |
} |
41 |
|
42 |
$dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 3, 'manage_patron_restrictions', 'Manage patron restrictions')}); |
43 |
say $out "Added manage_patron_restrictions permission"; |
44 |
|
45 |
$dbh->do(q{INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('PatronRestrictionTypes', '0', 'If enabled, it is possible to specify the "type" of patron restriction being applied.', '', 'YesNo');}); |
46 |
say $out "Added PatronRestrictionTypes preference"; |
47 |
}, |
48 |
}; |