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

(-)a/installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursWhenIssuing_syspref.perl (-5 lines)
Lines 1-5 Link Here
1
$DBversion = 'XXX';
2
if ( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{ INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ( 'ConsiderLibraryHoursWhenIssuing', 'ignore', 'close|open|ignore', "Take library opening hours into consideration to calculate due date when issuing.", 'Choice' ) });
4
    NewVersion( $DBversion, 6796, "Add ConsiderLibraryHoursWhenIssuing system preference" );
5
}
(-)a/installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursWhenIssuing_syspref.pl (+14 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "6796",
5
    description => "Overnight checkouts taking into account opening and closing hours",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        $dbh->do(q{ INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ( 'ConsiderLibraryHoursWhenIssuing', 'ignore', 'close|open|ignore', "Take library opening hours into consideration to calculate due date when issuing.", 'Choice' ) });
11
12
        say $out "Added system preference 'ConsiderLibraryHoursWhenIssuing'";
13
    },
14
};
(-)a/installer/data/mysql/atomicupdate/bug_6796_-_add_branch_hours_table.perl (-20 lines)
Lines 1-20 Link Here
1
$DBversion = 'XXX';
2
if ( CheckVersion( $DBversion ) ) {
3
    $dbh->do(q{ DROP TABLE IF EXISTS branch_hours });
4
    $dbh->do(q{
5
        CREATE TABLE branch_hours (
6
            branchcode varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
7
            day int(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 0,
8
            open_time time COLLATE utf8mb4_unicode_ci DEFAULT NULL,
9
            close_time time COLLATE utf8mb4_unicode_ci DEFAULT NULL,
10
            PRIMARY KEY (branchcode, day),
11
            CONSTRAINT branch_hours_ibfk_1 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
12
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
13
    });
14
15
    my @indexes = (0..6);
16
    for my $i (@indexes) {
17
        $dbh->do(q{ INSERT INTO branch_hours (branchcode, day) SELECT branchcode, ? FROM branches }, undef, $i);
18
    }
19
    NewVersion( $DBversion, 6796, "Add branch_hours table" );
20
}
(-)a/installer/data/mysql/atomicupdate/bug_6796_-_add_branch_hours_table.pl (-1 / +30 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
return {
4
    bug_number => "6796",
5
    description => "Overnight checkouts taking into account opening and closing hours",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        unless( TableExists('branch_hours') ) {
11
            $dbh->do(q{
12
                CREATE TABLE branch_hours (
13
                    branchcode varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL,
14
                    day int(1) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 0,
15
                    open_time time COLLATE utf8mb4_unicode_ci DEFAULT NULL,
16
                    close_time time COLLATE utf8mb4_unicode_ci DEFAULT NULL,
17
                    PRIMARY KEY (branchcode, day),
18
                    CONSTRAINT branch_hours_ibfk_1 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
19
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
20
            });
21
22
            my @indexes = (0..6);
23
            for my $i (@indexes) {
24
                $dbh->do(q{ INSERT INTO branch_hours (branchcode, day) SELECT branchcode, ? FROM branches }, undef, $i);
25
            }
26
27
            say $out "Added table `branch_hours`";
28
        }
29
    },
30
};

Return to bug 6796