Koha/installer/data/mysql/db_revs/231200039.pl
Katrin Fischer 7edc3652f0
Bug 36002: DBRev 23.12.00.039
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
2024-04-30 17:09:45 +02:00

30 lines
1,022 B
Perl
Executable file

use Modern::Perl;
return {
bug_number => 36002,
description => "Remove aqorders.purchaseordernumber",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
if ( column_exists( 'aqorders', 'purchaseordernumber' ) ) {
my ($cnt) = $dbh->selectrow_array(
q|
SELECT count(*) FROM aqorders
WHERE purchaseordernumber IS NOT NULL|
);
if ($cnt) {
say $out "We found $cnt order lines where field purchaseordernumber was filled!";
$dbh->do(
q|
CREATE TABLE zzaqorders_purchaseordernumber AS
SELECT ordernumber,purchaseordernumber FROM aqorders WHERE purchaseordernumber IS NOT NULL|
);
say $out q|These records have been copied to table: zzaqorders_purchaseordernumber.
Please examine the data and remove this table.|;
}
$dbh->do(q{ALTER TABLE aqorders DROP COLUMN purchaseordernumber});
}
},
};