|
Lines 9608-9613
if ( CheckVersion($DBversion) ) {
Link Here
|
| 9608 |
SetVersion ($DBversion); |
9608 |
SetVersion ($DBversion); |
| 9609 |
} |
9609 |
} |
| 9610 |
|
9610 |
|
|
|
9611 |
$DBversion = "3.19.00.XXX"; |
| 9612 |
if(CheckVersion($DBversion)) { |
| 9613 |
$dbh->do(q{ |
| 9614 |
INSERT INTO authorised_values (category, authorised_value, lib) VALUES |
| 9615 |
('ORDER_CANCELLATION_REASON', 0, 'No reason'), |
| 9616 |
('ORDER_CANCELLATION_REASON', 1, 'Sold out'), |
| 9617 |
('ORDER_CANCELLATION_REASON', 2, 'Restocking') |
| 9618 |
}); |
| 9619 |
|
| 9620 |
my $already_existing_reasons = $dbh->selectcol_arrayref(q{ |
| 9621 |
SELECT DISTINCT( cancellationreason ) |
| 9622 |
FROM aqorders; |
| 9623 |
}, { Slice => {} }); |
| 9624 |
|
| 9625 |
my $update_orders_sth = $dbh->prepare(q{ |
| 9626 |
UPDATE aqorders |
| 9627 |
SET cancellationreason = ? |
| 9628 |
WHERE cancellationreason = ? |
| 9629 |
}); |
| 9630 |
|
| 9631 |
my $insert_av_sth = $dbh->prepare(q{ |
| 9632 |
INSERT INTO authorised_values (category, authorised_value, lib) VALUES |
| 9633 |
('ORDER_CANCELLATION_REASON', ?, ?) |
| 9634 |
}); |
| 9635 |
my $i = 3; |
| 9636 |
for my $reason ( @$already_existing_reasons ) { |
| 9637 |
next unless $reason; |
| 9638 |
$insert_av_sth->execute( $i, $reason ); |
| 9639 |
$update_orders_sth->execute( $i, $reason ); |
| 9640 |
$i++; |
| 9641 |
} |
| 9642 |
print "Upgrade to $DBversion done (Bug XXXXX - Add the ORDER_CANCELLATION_REASON authorised value)\n"; |
| 9643 |
SetVersion($DBversion); |
| 9644 |
} |
| 9645 |
|
| 9611 |
=head1 FUNCTIONS |
9646 |
=head1 FUNCTIONS |
| 9612 |
|
9647 |
|
| 9613 |
=head2 TableExists($table) |
9648 |
=head2 TableExists($table) |