@@ -165,7 +165,7 @@ BEGIN
165165my $dbuser = shell_quote($ce -> {database_username });
166166my $dbpass = $ce -> {database_password };
167167
168- $ENV {' MYSQL_PWD' } = $dbpass ;
168+ local $ENV {MYSQL_PWD } = $dbpass ;
169169
170170if (!$no_backup ) {
171171 # Backup the database
@@ -212,7 +212,7 @@ BEGIN
212212 },
213213);
214214
215- my $db = new WeBWorK::DB($ce -> {dbLayouts }{ $ce -> {dbLayoutName } });
215+ my $db = WeBWorK::DB-> new ($ce -> {dbLayouts }{ $ce -> {dbLayoutName } });
216216my @table_types = sort (grep { !$db -> {$_ }{params }{non_native } } keys %$db );
217217
218218sub checkAndUpdateTableColumnTypes {
@@ -222,29 +222,30 @@ sub checkAndUpdateTableColumnTypes {
222222
223223 print " \t Checking '$table ' (pass $pass )\n " if $verbose ;
224224 my $schema_field_data = $db -> {$table_type }{record }-> FIELD_DATA;
225- for my $field (keys %$schema_field_data ) {
226- my $field_name = $db -> {$table_type }{params }{fieldOverride }{$field } || $field ;
227- my @name_type = @{
225+ for my $field_name (keys %$schema_field_data ) {
226+ my @name_type = @{
228227 $dbh -> selectall_arrayref(
229228 " SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS "
230229 . " WHERE TABLE_SCHEMA='$dbname ' AND TABLE_NAME='$table ' AND COLUMN_NAME='$field_name ';"
231230 )
232231 };
233232
234- print (" \t\t The '$field_name ' column is missing from '$table '.\n "
235- . " \t\t You should upgrade the course via course administration to fix this.\n "
236- . " \t\t You may need to run this script again after doing that.\n " ), next
237- if !exists ($name_type [0][0]);
233+ if (!exists ($name_type [0][0])) {
234+ print (" \t\t The '$field_name ' column is missing from '$table '.\n "
235+ . " \t\t You should upgrade the course via course administration to fix this.\n "
236+ . " \t\t You may need to run this script again after doing that.\n " );
237+ next ;
238+ }
238239
239240 my $data_type = $name_type [0][0];
240241 next if !$data_type ;
241242 $data_type =~ s /\(\d *\) $// if $data_type =~ / ^(big|small)?int\(\d *\) $ / ;
242243 $data_type = lc ($data_type );
243- my $schema_data_type = lc ($schema_field_data -> {$field }{type } =~ s / .*$// r );
244+ my $schema_data_type = lc ($schema_field_data -> {$field_name }{type } =~ s / .*$// r );
244245 if ($data_type ne $schema_data_type ) {
245246 print " \t\t Updating data type for column '$field_name ' in table '$table '\n " if $verbose ;
246247 print " \t\t\t $data_type -> $schema_data_type \n " if $verbose ;
247- eval { $dbh -> do(" ALTER TABLE `$table ` MODIFY $field_name $schema_field_data ->{$field }{type};" ); };
248+ eval { $dbh -> do(" ALTER TABLE `$table ` MODIFY $field_name $schema_field_data ->{$field_name }{type};" ); };
248249 my $indent = $verbose ? " \t\t " : " " ;
249250 die (" ${indent} Failed to modify '$field_name ' in '$table ' from '$data_type ' to '$schema_data_type .\n "
250251 . " ${indent} It is recommended that you restore a database backup. Make note of the\n "
@@ -286,8 +287,10 @@ sub checkAndChangeTableCharacterSet {
286287my $error = 0;
287288
288289for my $course (@courses ) {
289- print (" The course '$course ' does not exist on the server\n " ), next
290- if !grep ($course eq $_ , @server_courses );
290+ if (!grep { $course eq $_ } @server_courses ) {
291+ print (" The course '$course ' does not exist on the server\n " );
292+ next ;
293+ }
291294
292295 print " Checking tables for '$course '\n " if $verbose ;
293296 for my $table_type (@table_types ) {
0 commit comments