Bug 36002: (follow-up) Save purchaseordernumbers from aqorders

We copy them here to another (temporary) table.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Marcel de Rooy 2024-04-30 11:41:55 +00:00 committed by Katrin Fischer
parent 1014bd131e
commit 52c6177ed9
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 17 additions and 0 deletions

View File

@ -6,7 +6,24 @@ return {
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});
}
},