error_log("In $dbUserForm, executed: $query", 0);
                    } else {
                        $res = Database::query($query);
                    }
                }
            }
        }
        // The SCORM database doesn't need a change in the pre-migrate part - ignore
    }

    $prefix = '';
    if ($singleDbForm) {
        $prefix = $_configuration['table_prefix'];
    }
    // Get the courses databases queries list (c_q_list)
    $c_q_list = get_sql_file_contents('migrate-db-1.8.0-1.8.2-pre.sql', 'course');
    if (count($c_q_list) > 0) {
        // Get the courses list
        if (strlen($dbNameForm) > 40) {
            error_log('Database name ' . $dbNameForm . ' is too long, skipping', 0);
        } elseif (!in_array($dbNameForm, $dblist)) {
            error_log('Database ' . $dbNameForm . ' was not found, skipping', 0);
        } else {
            Database::select_db($dbNameForm);
            $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
            if ($res === false) {
                die('Error while querying the courses list in update_db-1.8.0-1.8.2.inc.php');
            }
            if (Database::num_rows($res) > 0) {
                $i = 0;
                $list = array();
					} else {
						$res = iDatabase::query($query);
					}
				}
			}
		}
		// The SCORM database doesn't need a change in the pre-migrate part - ignore
	}

	$prefix = '';
	if ($singleDbForm) {
		$prefix =  get_config_param ('table_prefix');
	}

	// Get the courses databases queries list (c_q_list)
	$c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-pre.sql', 'course');

	if (count($c_q_list) > 0) {
		// Get the courses list
		if (strlen($dbNameForm) > 40) {
			 Log::error('Database name '.$dbNameForm.' is too long, skipping');
		} elseif (!in_array($dbNameForm, $dblist)) {
			 Log::error('Database '.$dbNameForm.' was not found, skipping');
		} else {
			iDatabase::select_db($dbNameForm);
			$res = iDatabase::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");

			if ($res === false) { die('Error while querying the courses list in update_db-1.8.6-1.8.6.1.inc.php'); }

			if (iDatabase::num_rows($res) > 0) {
				$i = 0;
                    if ($only_test) {
                        error_log("Database::query($dbUserForm,$query)", 0);
                    } else {
                        $res = Database::query($query);
                        if ($log) {
                            error_log("In $dbUserForm, executed: $query", 0);
                        }
                    }
                }
            }
        }
        // The SCORM database should need a drop in the post-migrate part. However, we will keep these tables a bit more, just in case...
    }

    // Get the courses databases queries list (c_q_list)
    $c_q_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'course');
    if (count($c_q_list) > 0) {
        // Get the courses list
        if (strlen($dbNameForm) > 40) {
            error_log('Database name ' . $dbNameForm . ' is too long, skipping', 0);
        } elseif (!in_array($dbNameForm, $dblist)) {
            error_log('Database ' . $dbNameForm . ' was not found, skipping', 0);
        } else {
            Database::select_db($dbNameForm);
            $res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
            if ($res === false) {
                die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php');
            }
            if (Database::num_rows($res) > 0) {
                $i = 0;
                while ($row = Database::fetch_array($res)) {