Bug 18177: Do not remove columns if at least one value exists
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
57788803e0
commit
f50fee2546
|
|
@ -3,10 +3,19 @@ if( CheckVersion( $DBversion ) ) {
|
|||
|
||||
for my $column ( qw(othersupplier booksellerfax booksellerurl bookselleremail currency) ) {
|
||||
if( column_exists( 'aqbooksellers', $column ) ) {
|
||||
$dbh->do(qq|
|
||||
ALTER TABLE aqbooksellers
|
||||
DROP COLUMN $column
|
||||
my ($count) = $dbh->selectrow_array(qq|
|
||||
SELECT COUNT(*)
|
||||
FROM aqbooksellers
|
||||
WHERE $column IS NOT NULL AND $column <> ""
|
||||
|);
|
||||
if ( $count ) {
|
||||
warn "Warning - Cannot remove column aqbooksellers.$column. At least one value exists";
|
||||
} else {
|
||||
$dbh->do(qq|
|
||||
ALTER TABLE aqbooksellers
|
||||
DROP COLUMN $column
|
||||
|);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue