Lines 4923-4928
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
4923 |
SetVersion($DBversion); |
4923 |
SetVersion($DBversion); |
4924 |
} |
4924 |
} |
4925 |
|
4925 |
|
|
|
4926 |
$DBversion = "3.07.00.XXX"; |
4927 |
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { |
4928 |
my $i = 1; |
4929 |
|
4930 |
my ( $query_update, $sth_update, $query_select, $sth_select ); |
4931 |
|
4932 |
$dbh->do("ALTER TABLE reserves ADD reservenumber INT NOT NULL FIRST"); |
4933 |
$dbh->do("ALTER TABLE old_reserves ADD reservenumber INT NOT NULL FIRST"); |
4934 |
|
4935 |
$query_select = "SELECT * FROM old_reserves ORDER BY timestamp ASC"; |
4936 |
$sth_select = $dbh->prepare( $query_select ); |
4937 |
$sth_select->execute(); |
4938 |
while( my @r = $sth_select->fetchrow_array() ) { |
4939 |
my ( $reservenumber, $borrowernumber, $reservedate, $biblionumber, $constrainttype, $branchcode, |
4940 |
$notificationdate, $reminderdate, $cancellationdate, $reservenotes, $priority, $found, |
4941 |
$timestamp, $itemnumber, $waitingdate, $expirationdate, $lowestPriority, $suspend, $suspend_until ) = @r; |
4942 |
|
4943 |
$query_update = "UPDATE old_reserves SET reservenumber = $i WHERE "; |
4944 |
$query_update .= ( defined $borrowernumber ) ? "borrowernumber = '$borrowernumber'" : "borrowernumber IS NULL"; |
4945 |
$query_update .= " AND "; |
4946 |
$query_update .= ( defined $reservedate ) ? "reservedate = '$reservedate'" : "reservedate IS NULL"; |
4947 |
$query_update .= " AND "; |
4948 |
$query_update .= ( defined $biblionumber ) ? "biblionumber = '$biblionumber'" : "biblionumber IS NULL"; |
4949 |
$query_update .= " AND "; |
4950 |
$query_update .= ( defined $constrainttype ) ? "constrainttype = '$constrainttype'" : "constrainttype IS NULL"; |
4951 |
$query_update .= " AND "; |
4952 |
$query_update .= ( defined $branchcode ) ? "branchcode = '$branchcode'" : "branchcode IS NULL"; |
4953 |
$query_update .= " AND "; |
4954 |
$query_update .= ( defined $notificationdate ) ? "notificationdate = '$notificationdate'" : "notificationdate IS NULL"; |
4955 |
$query_update .= " AND "; |
4956 |
$query_update .= ( defined $reminderdate ) ? "reminderdate = '$reminderdate'" : "reminderdate IS NULL"; |
4957 |
$query_update .= " AND "; |
4958 |
$query_update .= ( defined $cancellationdate ) ? "cancellationdate = '$cancellationdate'" : "cancellationdate IS NULL"; |
4959 |
$query_update .= " AND "; |
4960 |
$query_update .= ( defined $reservenotes ) ? "reservenotes = '$reservenotes'" : "reservenotes IS NULL"; |
4961 |
$query_update .= " AND "; |
4962 |
$query_update .= ( defined $priority ) ? "priority = '$priority'" : "priority IS NULL"; |
4963 |
$query_update .= " AND "; |
4964 |
$query_update .= ( defined $found ) ? "found = '$found'" : "found IS NULL"; |
4965 |
$query_update .= " AND "; |
4966 |
$query_update .= "timestamp = '$timestamp'"; |
4967 |
$query_update .= " AND "; |
4968 |
$query_update .= ( defined $itemnumber ) ? "itemnumber = '$itemnumber'" : "itemnumber IS NULL"; |
4969 |
$query_update .= " AND "; |
4970 |
$query_update .= ( defined $waitingdate ) ? "waitingdate = '$waitingdate'" : "waitingdate IS NULL"; |
4971 |
$query_update .= " AND "; |
4972 |
$query_update .= ( defined $expirationdate ) ? "expirationdate = '$expirationdate'" : "expirationdate IS NULL"; |
4973 |
$query_update .= " AND "; |
4974 |
$query_update .= "lowestPriority = '$lowestPriority'"; |
4975 |
$query_update .= " LIMIT 1"; |
4976 |
|
4977 |
$dbh->do( $query_update ); |
4978 |
$i++; |
4979 |
} |
4980 |
|
4981 |
$query_select = "SELECT * FROM reserves ORDER BY timestamp ASC"; |
4982 |
$sth_select = $dbh->prepare( $query_select ); |
4983 |
$sth_select->execute(); |
4984 |
while( my @r = $sth_select->fetchrow_array() ) { |
4985 |
my ( $reservenumber, $borrowernumber, $reservedate, $biblionumber, $constrainttype, $branchcode, |
4986 |
$notificationdate, $reminderdate, $cancellationdate, $reservenotes, $priority, $found, |
4987 |
$timestamp, $itemnumber, $waitingdate, $expirationdate, $lowestPriority, $suspend, $suspend_until ) = @r; |
4988 |
|
4989 |
$query_update = "UPDATE reserves SET reservenumber = $i WHERE "; |
4990 |
$query_update .= ( defined $borrowernumber ) ? "borrowernumber = '$borrowernumber'" : "borrowernumber IS NULL"; |
4991 |
$query_update .= " AND "; |
4992 |
$query_update .= ( defined $reservedate ) ? "reservedate = '$reservedate'" : "reservedate IS NULL"; |
4993 |
$query_update .= " AND "; |
4994 |
$query_update .= ( defined $biblionumber ) ? "biblionumber = '$biblionumber'" : "biblionumber IS NULL"; |
4995 |
$query_update .= " AND "; |
4996 |
$query_update .= ( defined $constrainttype ) ? "constrainttype = '$constrainttype'" : "constrainttype IS NULL"; |
4997 |
$query_update .= " AND "; |
4998 |
$query_update .= ( defined $branchcode ) ? "branchcode = '$branchcode'" : "branchcode IS NULL"; |
4999 |
$query_update .= " AND "; |
5000 |
$query_update .= ( defined $notificationdate ) ? "notificationdate = '$notificationdate'" : "notificationdate IS NULL"; |
5001 |
$query_update .= " AND "; |
5002 |
$query_update .= ( defined $reminderdate ) ? "reminderdate = '$reminderdate'" : "reminderdate IS NULL"; |
5003 |
$query_update .= " AND "; |
5004 |
$query_update .= ( defined $cancellationdate ) ? "cancellationdate = '$cancellationdate'" : "cancellationdate IS NULL"; |
5005 |
$query_update .= " AND "; |
5006 |
$query_update .= ( defined $reservenotes ) ? "reservenotes = '$reservenotes'" : "reservenotes IS NULL"; |
5007 |
$query_update .= " AND "; |
5008 |
$query_update .= ( defined $priority ) ? "priority = '$priority'" : "priority IS NULL"; |
5009 |
$query_update .= " AND "; |
5010 |
$query_update .= ( defined $found ) ? "found = '$found'" : "found IS NULL"; |
5011 |
$query_update .= " AND "; |
5012 |
$query_update .= "timestamp = '$timestamp'"; |
5013 |
$query_update .= " AND "; |
5014 |
$query_update .= ( defined $itemnumber ) ? "itemnumber = '$itemnumber'" : "itemnumber IS NULL"; |
5015 |
$query_update .= " AND "; |
5016 |
$query_update .= ( defined $waitingdate ) ? "waitingdate = '$waitingdate'" : "waitingdate IS NULL"; |
5017 |
$query_update .= " AND "; |
5018 |
$query_update .= ( defined $expirationdate ) ? "expirationdate = '$expirationdate'" : "expirationdate IS NULL"; |
5019 |
$query_update .= " AND "; |
5020 |
$query_update .= "lowestPriority = '$lowestPriority'"; |
5021 |
$query_update .= " LIMIT 1"; |
5022 |
|
5023 |
$dbh->do( $query_update ); |
5024 |
$i++; |
5025 |
} |
5026 |
|
5027 |
$dbh->do("ALTER TABLE reserves ADD PRIMARY KEY ( reservenumber )"); |
5028 |
$dbh->do("ALTER TABLE old_reserves ADD PRIMARY KEY ( reservenumber )"); |
5029 |
|
5030 |
$dbh->do("ALTER TABLE reserves CHANGE reservenumber reservenumber INT( 11 ) NOT NULL AUTO_INCREMENT"); |
5031 |
|
5032 |
print "Upgrade to $DBversion done ( add reservenumber to reserves and old_reserves tables )\n"; |
5033 |
SetVersion($DBversion); |
5034 |
} |
4926 |
|
5035 |
|
4927 |
=head1 FUNCTIONS |
5036 |
=head1 FUNCTIONS |
4928 |
|
5037 |
|
4929 |
- |
|
|