From 151090ddd2983c252bd00f16eecf3a7af136de2c Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Wed, 3 Oct 2018 09:25:45 +1300 Subject: [PATCH] Bug 8367: Moved database update out of updatedatabase.pl into atomicupdates dir --- installer/data/mysql/atomicupdate/bug_8367.perl | 21 +++++++++++++++++++ installer/data/mysql/updatedatabase.pl | 28 ------------------------- 2 files changed, 21 insertions(+), 28 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_8367.perl diff --git a/installer/data/mysql/atomicupdate/bug_8367.perl b/installer/data/mysql/atomicupdate/bug_8367.perl new file mode 100644 index 00000000000..59cad22cb97 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_8367.perl @@ -0,0 +1,21 @@ +my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay +$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; }); +$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; }); +# //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait +# //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules. +$dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; }); +$dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); +$dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); +my $sth = $dbh->prepare(q{ + UPDATE issuingrules SET holdspickupwait = ? +}); +$sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all! +##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay' +print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n"; +$sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; }); +$sth->execute( ); +my $dtdur = DateTime::Duration->new( days => 0 ); +while ( my $res = $sth->fetchrow_hashref ) { + C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB. +} +print "Upgrade to $DBversion done (8367: Add colum issuingrules.holdspickupwait and reserves.lastpickupdate. Populates introduced columns from the expiring ReservesMaxPickUpDelay. Deletes the ReservesMaxPickUpDelay and ExpireReservesOnHolidays -sysprefs)\n";>>>>>>> Bug 8367: Template fixes + fixes to C4/Reserves.pm and Koha/Hold.pm diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index c9f39be9e8f..4b5415cf1b2 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -16480,34 +16480,6 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 21403 - Add Indian Amazon Affiliate option to AmazonLocale setting)\n"; } -$DBversion = "18.06.00.XXX"; -if ( CheckVersion($DBversion) ) { - my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay - $dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; }); - $dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; }); - # //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait - # //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules. - $dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; }); - $dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); - $dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); - my $sth = $dbh->prepare(q{ - UPDATE issuingrules SET holdspickupwait = ? - }); - $sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all! - - ##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay' - print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n"; - $sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; }); - $sth->execute( ); - my $dtdur = DateTime::Duration->new( days => 0 ); - - while ( my $res = $sth->fetchrow_hashref ) { - C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB. - } - print "Upgrade to $DBversion done (8367: Add colum issuingrules.holdspickupwait and reserves.lastpickupdate. Populates introduced columns from the expiring ReservesMaxPickUpDelay. Deletes the ReservesMaxPickUpDelay and ExpireReservesOnHolidays -sysprefs)\n"; - SetVersion($DBversion); -} - # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.11.0