Lines 4930-4935
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
4930 |
SetVersion($DBversion); |
4930 |
SetVersion($DBversion); |
4931 |
} |
4931 |
} |
4932 |
|
4932 |
|
|
|
4933 |
<<<<<<< HEAD |
4933 |
$DBversion = "3.07.00.028"; |
4934 |
$DBversion = "3.07.00.028"; |
4934 |
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { |
4935 |
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { |
4935 |
$dbh->do(qq{ |
4936 |
$dbh->do(qq{ |
Lines 5212-5217
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
Link Here
|
5212 |
SetVersion($DBversion); |
5213 |
SetVersion($DBversion); |
5213 |
} |
5214 |
} |
5214 |
|
5215 |
|
|
|
5216 |
$DBversion = "3.07.00.XXX"; |
5217 |
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { |
5218 |
my $i = 1; |
5219 |
|
5220 |
my ( $query_update, $sth_update, $query_select, $sth_select ); |
5221 |
|
5222 |
$dbh->do("ALTER TABLE reserves ADD reserve_id INT NOT NULL FIRST"); |
5223 |
$dbh->do("ALTER TABLE old_reserves ADD reserve_id INT NOT NULL FIRST"); |
5224 |
|
5225 |
$query_select = "SELECT * FROM old_reserves ORDER BY timestamp ASC"; |
5226 |
$sth_select = $dbh->prepare( $query_select ); |
5227 |
$sth_select->execute(); |
5228 |
while( my @r = $sth_select->fetchrow_array() ) { |
5229 |
my ( $reserve_id, $borrowernumber, $reservedate, $biblionumber, $constrainttype, $branchcode, |
5230 |
$notificationdate, $reminderdate, $cancellationdate, $reservenotes, $priority, $found, |
5231 |
$timestamp, $itemnumber, $waitingdate, $expirationdate, $lowestPriority, $suspend, $suspend_until ) = @r; |
5232 |
|
5233 |
$query_update = "UPDATE old_reserves SET reserve_id = $i WHERE "; |
5234 |
$query_update .= ( defined $borrowernumber ) ? "borrowernumber = '$borrowernumber'" : "borrowernumber IS NULL"; |
5235 |
$query_update .= " AND "; |
5236 |
$query_update .= ( defined $reservedate ) ? "reservedate = '$reservedate'" : "reservedate IS NULL"; |
5237 |
$query_update .= " AND "; |
5238 |
$query_update .= ( defined $biblionumber ) ? "biblionumber = '$biblionumber'" : "biblionumber IS NULL"; |
5239 |
$query_update .= " AND "; |
5240 |
$query_update .= ( defined $constrainttype ) ? "constrainttype = '$constrainttype'" : "constrainttype IS NULL"; |
5241 |
$query_update .= " AND "; |
5242 |
$query_update .= ( defined $branchcode ) ? "branchcode = '$branchcode'" : "branchcode IS NULL"; |
5243 |
$query_update .= " AND "; |
5244 |
$query_update .= ( defined $notificationdate ) ? "notificationdate = '$notificationdate'" : "notificationdate IS NULL"; |
5245 |
$query_update .= " AND "; |
5246 |
$query_update .= ( defined $reminderdate ) ? "reminderdate = '$reminderdate'" : "reminderdate IS NULL"; |
5247 |
$query_update .= " AND "; |
5248 |
$query_update .= ( defined $cancellationdate ) ? "cancellationdate = '$cancellationdate'" : "cancellationdate IS NULL"; |
5249 |
$query_update .= " AND "; |
5250 |
$query_update .= ( defined $reservenotes ) ? "reservenotes = '$reservenotes'" : "reservenotes IS NULL"; |
5251 |
$query_update .= " AND "; |
5252 |
$query_update .= ( defined $priority ) ? "priority = '$priority'" : "priority IS NULL"; |
5253 |
$query_update .= " AND "; |
5254 |
$query_update .= ( defined $found ) ? "found = '$found'" : "found IS NULL"; |
5255 |
$query_update .= " AND "; |
5256 |
$query_update .= "timestamp = '$timestamp'"; |
5257 |
$query_update .= " AND "; |
5258 |
$query_update .= ( defined $itemnumber ) ? "itemnumber = '$itemnumber'" : "itemnumber IS NULL"; |
5259 |
$query_update .= " AND "; |
5260 |
$query_update .= ( defined $waitingdate ) ? "waitingdate = '$waitingdate'" : "waitingdate IS NULL"; |
5261 |
$query_update .= " AND "; |
5262 |
$query_update .= ( defined $expirationdate ) ? "expirationdate = '$expirationdate'" : "expirationdate IS NULL"; |
5263 |
$query_update .= " AND "; |
5264 |
$query_update .= "lowestPriority = '$lowestPriority'"; |
5265 |
$query_update .= "AND reserve_id = 0 LIMIT 1"; |
5266 |
|
5267 |
$dbh->do( $query_update ); |
5268 |
$i++; |
5269 |
} |
5270 |
|
5271 |
$query_select = "SELECT * FROM reserves ORDER BY timestamp ASC"; |
5272 |
$sth_select = $dbh->prepare( $query_select ); |
5273 |
$sth_select->execute(); |
5274 |
while( my @r = $sth_select->fetchrow_array() ) { |
5275 |
my ( $reserve_id, $borrowernumber, $reservedate, $biblionumber, $constrainttype, $branchcode, |
5276 |
$notificationdate, $reminderdate, $cancellationdate, $reservenotes, $priority, $found, |
5277 |
$timestamp, $itemnumber, $waitingdate, $expirationdate, $lowestPriority, $suspend, $suspend_until ) = @r; |
5278 |
|
5279 |
$query_update = "UPDATE reserves SET reserve_id = $i WHERE "; |
5280 |
$query_update .= ( defined $borrowernumber ) ? "borrowernumber = '$borrowernumber'" : "borrowernumber IS NULL"; |
5281 |
$query_update .= " AND "; |
5282 |
$query_update .= ( defined $reservedate ) ? "reservedate = '$reservedate'" : "reservedate IS NULL"; |
5283 |
$query_update .= " AND "; |
5284 |
$query_update .= ( defined $biblionumber ) ? "biblionumber = '$biblionumber'" : "biblionumber IS NULL"; |
5285 |
$query_update .= " AND "; |
5286 |
$query_update .= ( defined $constrainttype ) ? "constrainttype = '$constrainttype'" : "constrainttype IS NULL"; |
5287 |
$query_update .= " AND "; |
5288 |
$query_update .= ( defined $branchcode ) ? "branchcode = '$branchcode'" : "branchcode IS NULL"; |
5289 |
$query_update .= " AND "; |
5290 |
$query_update .= ( defined $notificationdate ) ? "notificationdate = '$notificationdate'" : "notificationdate IS NULL"; |
5291 |
$query_update .= " AND "; |
5292 |
$query_update .= ( defined $reminderdate ) ? "reminderdate = '$reminderdate'" : "reminderdate IS NULL"; |
5293 |
$query_update .= " AND "; |
5294 |
$query_update .= ( defined $cancellationdate ) ? "cancellationdate = '$cancellationdate'" : "cancellationdate IS NULL"; |
5295 |
$query_update .= " AND "; |
5296 |
$query_update .= ( defined $reservenotes ) ? "reservenotes = '$reservenotes'" : "reservenotes IS NULL"; |
5297 |
$query_update .= " AND "; |
5298 |
$query_update .= ( defined $priority ) ? "priority = '$priority'" : "priority IS NULL"; |
5299 |
$query_update .= " AND "; |
5300 |
$query_update .= ( defined $found ) ? "found = '$found'" : "found IS NULL"; |
5301 |
$query_update .= " AND "; |
5302 |
$query_update .= "timestamp = '$timestamp'"; |
5303 |
$query_update .= " AND "; |
5304 |
$query_update .= ( defined $itemnumber ) ? "itemnumber = '$itemnumber'" : "itemnumber IS NULL"; |
5305 |
$query_update .= " AND "; |
5306 |
$query_update .= ( defined $waitingdate ) ? "waitingdate = '$waitingdate'" : "waitingdate IS NULL"; |
5307 |
$query_update .= " AND "; |
5308 |
$query_update .= ( defined $expirationdate ) ? "expirationdate = '$expirationdate'" : "expirationdate IS NULL"; |
5309 |
$query_update .= " AND "; |
5310 |
$query_update .= "lowestPriority = '$lowestPriority'"; |
5311 |
$query_update .= "AND reserve_id = 0 LIMIT 1"; |
5312 |
|
5313 |
$dbh->do( $query_update ); |
5314 |
$i++; |
5315 |
} |
5316 |
|
5317 |
$dbh->do("ALTER TABLE reserves ADD PRIMARY KEY ( reserve_id )"); |
5318 |
$dbh->do("ALTER TABLE old_reserves ADD PRIMARY KEY ( reserve_id )"); |
5319 |
|
5320 |
$dbh->do("ALTER TABLE reserves CHANGE reserve_id reserve_id INT( 11 ) NOT NULL AUTO_INCREMENT"); |
5321 |
|
5322 |
print "Upgrade to $DBversion done ( add reserve_id to reserves and old_reserves tables )\n"; |
5323 |
SetVersion($DBversion); |
5324 |
} |
5325 |
|
5215 |
=head1 FUNCTIONS |
5326 |
=head1 FUNCTIONS |
5216 |
|
5327 |
|
5217 |
=head2 TableExists($table) |
5328 |
=head2 TableExists($table) |
5218 |
- |
|
|