|
Lines 9585-9590
if ( CheckVersion($DBversion) ) {
Link Here
|
| 9585 |
SetVersion ($DBversion); |
9585 |
SetVersion ($DBversion); |
| 9586 |
} |
9586 |
} |
| 9587 |
|
9587 |
|
|
|
9588 |
$DBversion = "3.19.00.XXX"; |
| 9589 |
if(CheckVersion($DBversion)) { |
| 9590 |
$dbh->do(q{ |
| 9591 |
INSERT INTO authorised_values (category, authorised_value, lib) VALUES |
| 9592 |
('ORDER_CANCELLATION_REASON', 0, 'No reason'), |
| 9593 |
('ORDER_CANCELLATION_REASON', 1, 'Sold out'), |
| 9594 |
('ORDER_CANCELLATION_REASON', 2, 'Restocking') |
| 9595 |
}); |
| 9596 |
|
| 9597 |
my $already_existing_reasons = $dbh->selectcol_arrayref(q{ |
| 9598 |
SELECT DISTINCT( cancellationreason ) |
| 9599 |
FROM aqorders; |
| 9600 |
}, { Slice => {} }); |
| 9601 |
|
| 9602 |
my $update_orders_sth = $dbh->prepare(q{ |
| 9603 |
UPDATE aqorders |
| 9604 |
SET cancellationreason = ? |
| 9605 |
WHERE cancellationreason = ? |
| 9606 |
}); |
| 9607 |
|
| 9608 |
my $insert_av_sth = $dbh->prepare(q{ |
| 9609 |
INSERT INTO authorised_values (category, authorised_value, lib) VALUES |
| 9610 |
('ORDER_CANCELLATION_REASON', ?, ?) |
| 9611 |
}); |
| 9612 |
my $i = 3; |
| 9613 |
for my $reason ( @$already_existing_reasons ) { |
| 9614 |
next unless $reason; |
| 9615 |
$insert_av_sth->execute( $i, $reason ); |
| 9616 |
$update_orders_sth->execute( $i, $reason ); |
| 9617 |
$i++; |
| 9618 |
} |
| 9619 |
print "Upgrade to $DBversion done (Bug XXXXX - Add the ORDER_CANCELLATION_REASON authorised value)\n"; |
| 9620 |
SetVersion($DBversion); |
| 9621 |
} |
| 9622 |
|
| 9588 |
=head1 FUNCTIONS |
9623 |
=head1 FUNCTIONS |
| 9589 |
|
9624 |
|
| 9590 |
=head2 TableExists($table) |
9625 |
=head2 TableExists($table) |