From 688a551e70321f06414c112e576e25e8ea3fd795 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 12 Feb 2024 15:21:08 +0000 Subject: [PATCH] Bug 6796: Merge and correct database update Sponsored-by: PTFS Europe Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- ...nsiderLibraryHoursInCirculation_syspref.pl | 16 ------------- .../bug_6796_-_add_library_hours_table.pl | 24 ++++++++++++++----- 2 files changed, 18 insertions(+), 22 deletions(-) delete mode 100755 installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursInCirculation_syspref.pl diff --git a/installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursInCirculation_syspref.pl b/installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursInCirculation_syspref.pl deleted file mode 100755 index 823504319a..0000000000 --- a/installer/data/mysql/atomicupdate/bug_6796_-_add_ConsiderLibraryHoursInCirculation_syspref.pl +++ /dev/null @@ -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'"; - }, -}; diff --git a/installer/data/mysql/atomicupdate/bug_6796_-_add_library_hours_table.pl b/installer/data/mysql/atomicupdate/bug_6796_-_add_library_hours_table.pl index f3a506c806..6832035255 100755 --- a/installer/data/mysql/atomicupdate/bug_6796_-_add_library_hours_table.pl +++ b/installer/data/mysql/atomicupdate/bug_6796_-_add_library_hours_table.pl @@ -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'"; } }, }; -- 2.39.5