View | Details | Raw Unified | Return to bug 23681
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_23681.pl (+48 lines)
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
};
(-)a/installer/data/mysql/atomicupdate/bug_23681_add_PatronRestrictionTypes_syspref.pl (-14 lines)
Lines 1-14 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "23681",
5
    description => "Add PatronRestrictionTypes syspref",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        # Do you stuffs here
10
        $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');});
11
        # Print useful stuff here
12
        say $out "Update is going well so far";
13
    },
14
};
(-)a/installer/data/mysql/atomicupdate/bug_23681_add_debarment_types.pl (-37 lines)
Lines 1-37 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "23681",
5
    description => "Add debarment_types",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        # Do you stuffs here
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
        $dbh->do(q{
20
            INSERT IGNORE INTO debarment_types (code, display_text, is_system, default_value, can_be_added_manually) VALUES
21
            ('MANUAL', 'Manual', 1, 1, 0),
22
            ('OVERDUES', 'Overdues', 1, 0, 0),
23
            ('SUSPENSION', 'Suspension', 1, 0, 0),
24
            ('DISCHARGE', 'Discharge', 1, 0, 0);
25
        });
26
        $dbh->do(q{
27
            ALTER TABLE borrower_debarments
28
            MODIFY COLUMN type varchar(50) NOT NULL
29
        });
30
        $dbh->do(q{
31
            ALTER TABLE borrower_debarments
32
            ADD CONSTRAINT borrower_debarments_ibfk_2 FOREIGN KEY (type) REFERENCES debarment_types(code) ON DELETE NO ACTION ON UPDATE CASCADE;
33
        });
34
        # Print useful stuff here
35
        say $out "Update is going well so far";
36
    },
37
};
(-)a/installer/data/mysql/atomicupdate/bug_23681_add_manage_patron_restrictions_perm.pl (-15 lines)
Lines 1-14 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "23681",
5
    description => "Add manage_patron_restrictions_permission",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        # Do you stuffs here
10
        $dbh->do(q{ INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 3, 'manage_patron_restrictions', 'Manage patron restrictions')});
11
        # Print useful stuff here
12
        say $out "Update is going well so far";
13
    },
14
};
15
- 

Return to bug 23681