# 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
$table,
$column,
$type, $null, $key, $default, $extra,
- $prefitem, # preference item in systempreferences table
);
my $silent;
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";
],
);
- 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();
# 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");
#---------------------------------
# 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();
{
$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} ) {
} # 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();
$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
}
}
# 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");
}
# 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;