61b0e5e543f1c39395debbb66bad2cd265896889
[srvgit] / installer / data / mysql / atomicupdate / bug_18177.perl
1 $DBversion = 'XXX'; # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3
4     for my $column ( qw(othersupplier booksellerfax booksellerurl bookselleremail currency) ) {
5         if( column_exists( 'aqbooksellers', $column ) ) {
6             my ($count) = $dbh->selectrow_array(qq|
7                 SELECT COUNT(*)
8                 FROM aqbooksellers
9                 WHERE $column IS NOT NULL AND $column <> ""
10             |);
11             if ( $count ) {
12                 warn "Warning - Cannot remove column aqbooksellers.$column. At least one value exists";
13             } else {
14                 $dbh->do(qq|
15                     ALTER TABLE aqbooksellers
16                     DROP COLUMN $column
17                 |);
18             }
19         }
20     }
21
22     SetVersion( $DBversion );
23     print "Upgrade to $DBversion done (Bug 18177 - Remove some unused columns from aqbooksellers)\n";
24 }