Bug 6796: Merge and correct database update

Sponsored-by: PTFS Europe
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Martin Renvoize 2024-02-12 15:21:08 +00:00 committed by Katrin Fischer
parent e2a48eff6d
commit 688a551e70
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 18 additions and 22 deletions

View File

@ -1,16 +0,0 @@
use Modern::Perl;
return {
bug_number => "6796",
description => "Overnight checkouts taking into account opening and closing hours",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
$dbh->do(
q{ INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ( 'ConsiderLibraryHoursInCirculation', 'ignore', 'close|open|ignore', "Take library opening hours into consideration to calculate due date when circulating.", 'Choice' ) }
);
say $out "Added system preference 'ConsiderLibraryHoursInCirculation'";
},
};

View File

@ -21,15 +21,27 @@ return {
}
);
my @indexes = ( 0 .. 6 );
for my $i (@indexes) {
$dbh->do(
q{ INSERT INTO library_hours (library_id, day) SELECT branchcode, ? FROM branches }, undef,
$i
);
my $branches =
$dbh->selectall_arrayref( "SELECT branchcode FROM branches", { Slice => {} } );
for my $branch (@$branches) {
my $branchcode = $branch->{branchcode};
my @indexes = ( 0 .. 6 );
for my $i (@indexes) {
$dbh->do(
q{ INSERT INTO library_hours (library_id, day) VALUES ( ?, ? ) }, undef, $branchcode,
$i
);
}
}
say $out "Added table `library_hours`";
$dbh->do(
q{ INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) VALUES ( 'ConsiderLibraryHoursInCirculation', 'ignore', 'close|open|ignore', "Take library opening hours into consideration to calculate due date when circulating.", 'Choice' ) }
);
say $out "Added system preference 'ConsiderLibraryHoursInCirculation'";
}
},
};