Bug 17600: Standardize our EXPORT_OK
[srvgit] / installer / data / mysql / update22to30.pl
index 76bb3c2..c5a183d 100755 (executable)
 
 # NOTE:  If you do something more than once in here, make it table driven.
 use strict;
-#use warnings; FIXME - Bug 2505
 
 # CPAN modules
-use DBI;
-use Getopt::Long;
+use Getopt::Long qw( GetOptions );
 # Koha modules
 use C4::Context;
 
-use MARC::Record;
 use MARC::File::XML ( BinaryEncoding => 'utf8' );
  
 # FIXME - The user might be installing a new database, so can't rely
@@ -36,7 +33,6 @@ my (
     $table,
     $column,
     $type, $null, $key, $default, $extra,
-    $prefitem,          # preference item in systempreferences table
 );
 
 my $silent;
@@ -3022,7 +3018,7 @@ my $DBversion = "3.00.00.000";
         next if $table->{Name} eq 'auth_subfield_table';
         if ($table->{Engine} ne 'InnoDB') {
             print "moving $table->{Name} to InnoDB\n";
-            $dbh->do("ALTER TABLE $table->{Name} TYPE = innodb");
+            $dbh->do("ALTER TABLE $table->{Name} ENGINE = innodb");
         }
         unless ($table->{Collation} =~ /^utf8/) {
             print "moving $table->{Name} to utf8\n";
@@ -3049,7 +3045,7 @@ my $DBversion = "3.00.00.000";
                              ],
     );
 
-    foreach $table ( keys %required_prereq_fields ) {
+    foreach my $table ( keys %required_prereq_fields ) {
         print "Check table $table\n" if $debug and not $silent;
         $sth = $dbh->prepare("show columns from $table");
         $sth->execute();
@@ -3158,7 +3154,7 @@ my $DBversion = "3.00.00.000";
     
     
     # Now add any missing tables
-    foreach $table ( keys %requiretables ) {
+    foreach my $table ( keys %requiretables ) {
         unless ( $existingtables{$table} ) {
         print "Adding $table table...\n" unless $silent;
             my $sth = $dbh->prepare("create table $table $requiretables{$table} ENGINE=InnoDB DEFAULT CHARSET=utf8");
@@ -3173,7 +3169,7 @@ my $DBversion = "3.00.00.000";
     #---------------------------------
     # Columns
     
-    foreach $table ( keys %requirefields ) {
+    foreach my $table ( keys %requirefields ) {
         print "Check table $table\n" if $debug and not $silent;
         $sth = $dbh->prepare("show columns from $table");
         $sth->execute();
@@ -3182,7 +3178,7 @@ my $DBversion = "3.00.00.000";
         {
             $types{$column} = $type;
         }    # while
-        foreach $column ( keys %{ $requirefields{$table} } ) {
+        foreach my $column ( keys %{ $requirefields{$table} } ) {
             print "  Check column $column  [$types{$column}]\n" if $debug and not $silent;
             if ( !$types{$column} ) {
     
@@ -3201,7 +3197,7 @@ my $DBversion = "3.00.00.000";
         }    # foreach column
     }    # foreach table
     
-    foreach $table ( sort keys %fielddefinitions ) {
+    foreach my $table ( sort keys %fielddefinitions ) {
         print "Check table $table\n" if $debug;
         $sth = $dbh->prepare("show columns from $table");
         $sth->execute();
@@ -3443,7 +3439,7 @@ my $DBversion = "3.00.00.000";
                 $dbh->do($sql);
                 if ($dbh->err) {
                     print "====================
-    An error occured during :
+    An error occurred during :
     \t$sql
     It probably means there is something wrong in your DB : a row ($table.$row->{key}) refers to a value in $row->{foreigntable}.$row->{foreignkey} that does not exist. solve the problem and run updater again (or just the previous SQL statement).
     You can find those values with select
@@ -3455,7 +3451,7 @@ my $DBversion = "3.00.00.000";
         }
     }
     # now drop useless tables
-    foreach $table ( @TableToDelete ) {
+    foreach my $table ( @TableToDelete ) {
         if ( $existingtables{$table} ) {
             print "Dropping unused table $table\n" if $debug and not $silent;
             $dbh->do("drop table $table");
@@ -3500,9 +3496,8 @@ my $DBversion = "3.00.00.000";
     }
     
     # at last, remove useless fields
-    foreach $table ( keys %uselessfields ) {
+    foreach my $table ( keys %uselessfields ) {
         my @fields = split (/,/,$uselessfields{$table});
-        my $fields;
         my $exists;
         foreach my $fieldtodrop (@fields) {
             $fieldtodrop =~ s/\t//g;