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

(-)a/installer/data/mysql/atomicupdate/bug_8367.perl (+23 lines)
Line 0 Link Here
1
my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay
2
$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; });
3
$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; });
4
#        //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait
5
#        //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules.
6
$dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; });
7
$dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; });
8
$dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; });
9
my $sth = $dbh->prepare(q{
10
    UPDATE issuingrules SET holdspickupwait = ?
11
});
12
$sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all!
13
##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay'
14
print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n";
15
$sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; });
16
$sth->execute( );
17
my $dtdur = DateTime::Duration->new( days => 0 );
18
19
while ( my $res = $sth->fetchrow_hashref ) {
20
     C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB.
21
}
22
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";
23
(-)a/installer/data/mysql/updatedatabase.pl (-30 lines)
Lines 16066-16100 if ( CheckVersion($DBversion) ) { Link Here
16066
    print "Upgrade to $DBversion done (18.05.02 release)\n";
16066
    print "Upgrade to $DBversion done (18.05.02 release)\n";
16067
}
16067
}
16068
16068
16069
16070
$DBversion = "18.06.00.XXX";
16071
if ( CheckVersion($DBversion) ) {
16072
    my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay
16073
    $dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; });
16074
    $dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; });
16075
    #        //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait
16076
    #        //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules.
16077
    $dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; });
16078
    $dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; });
16079
    $dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; });
16080
    my $sth = $dbh->prepare(q{
16081
        UPDATE issuingrules SET holdspickupwait = ?
16082
    });
16083
    $sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all!
16084
16085
    ##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay'
16086
    print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n";
16087
    $sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; });
16088
    $sth->execute( );
16089
    my $dtdur = DateTime::Duration->new( days => 0 );
16090
16091
    while ( my $res = $sth->fetchrow_hashref ) {
16092
         C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB.
16093
    }
16094
    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";
16095
    SetVersion($DBversion);
16096
}
16097
16098
# SEE bug 13068
16069
# SEE bug 13068
16099
# if there is anything in the atomicupdate, read and execute it.
16070
# if there is anything in the atomicupdate, read and execute it.
16100
16071
16101
- 

Return to bug 8367