5936: Remove some obsolete db columns from aqbooksellers and aqbudgets if needed
authorMarcel de Rooy <M.de.Rooy@rijksmuseum.nl>
Wed, 6 Apr 2011 11:35:37 +0000 (11:35 +0000)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 7 Apr 2011 04:30:16 +0000 (16:30 +1200)
Removes obsolete columns from aqbooksellers and aqbudgets if needed.
aqbooksellers: deliverydays followupdays followupscancel invoicedisc nocalc
specialty
aqbudgets: budget_description

These columns should not exist in a fresh install from kohastructure.sql, but
originate from older 3.0 versions.
One line in acqui/updatesupplier.pl referring to one of these columns is
removed too.

This patch therefore does not change functionality, but only keeps your db in
shape.

Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Rebased April 6.
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
acqui/updatesupplier.pl
installer/data/mysql/updatedatabase.pl

index 7c7aa2c..6bc978f 100755 (executable)
@@ -92,7 +92,7 @@ $data{'contnotes'}=$input->param('contact_notes');
 # warn "".$data{'contnotes'};
 $data{'notes'}=$input->param('notes');
 $data{'active'}=$input->param('status');
-$data{'specialty'}=$input->param('publishers_imprints');
+
 $data{'listprice'}=$input->param('list_currency');
 $data{'invoiceprice'}=$input->param('invoice_currency');
 $data{'gstreg'}=$input->param('gst');
index 7931029..a4bdb20 100755 (executable)
@@ -4234,6 +4234,24 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = '3.03.00.XXX';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    #Remove obsolete columns from aqbooksellers if needed
+    my $a = $dbh->selectall_hashref('SHOW columns from aqbooksellers','Field');
+    my $sqldrop="ALTER TABLE aqbooksellers DROP COLUMN ";
+    foreach(qw/deliverydays followupdays followupscancel invoicedisc nocalc specialty/) {
+      $dbh->do($sqldrop.$_) if exists $a->{$_};
+    }
+    #Remove obsolete column from aqbudgets if needed
+    #The correct column is budget_notes
+    $a = $dbh->selectall_hashref('SHOW columns from aqbudgets','Field');
+    if(exists $a->{budget_description}) {
+      $dbh->do("ALTER TABLE aqbudgets DROP COLUMN budget_description");
+    }
+    print "Upgrade to $DBversion done (Remove obsolete columns from aqbooksellers and aqbudgets if needed)\n";
+    SetVersion ($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 DropAllForeignKeys($table)