diff --git a/lib/db/mysql.php b/lib/db/mysql.php index da7a30a046f..bb9cb72940f 100644 --- a/lib/db/mysql.php +++ b/lib/db/mysql.php @@ -1146,6 +1146,40 @@ function main_upgrade($oldversion=0) { fix_course_sortorder(0, 1, 1); } + + if ($oldversion < 2005020101) { + // hopefully this is the LAST TIME we need to do this ;) + if ($rows = count_records("course_meta")) { + // we need to upgrade + modify_database("","CREATE TABLE `prefix_course_meta_tmp` ( + `parent_course` int(10) NOT NULL default 0, + `child_course` int(10) NOT NULL default 0);"); + + execute_sql("INSERT INTO {$CFG->prefix}course_meta_tmp (parent_course,child_course) + SELECT {$CFG->prefix}course_meta.parent_course, {$CFG->prefix}course_meta.child_course + FROM {$CFG->prefix}course_meta"); + $insertafter = true; + } + + execute_sql("DROP TABLE {$CFG->prefix}course_meta"); + + modify_database("","CREATE TABLE `prefix_course_meta` ( + `id` int(10) unsigned NOT NULL auto_increment, + `parent_course` int(10) unsigned NOT NULL default 0, + `child_course` int(10) unsigned NOT NULL default 0, + PRIMARY KEY (`id`), + KEY `parent_course` (parent_course), + KEY `child_course` (child_course));"); + + if (!empty($insertafter)) { + execute_sql("INSERT INTO {$CFG->prefix}course_meta (parent_course,child_course) + SELECT {$CFG->prefix}course_meta_tmp.parent_course, {$CFG->prefix}course_meta_tmp.child_course + FROM {$CFG->prefix}course_meta_tmp"); + + execute_sql("DROP TABLE {$CFG->prefix}course_meta_tmp"); + } + } + return $result; } diff --git a/version.php b/version.php index b85ed65cb61..2136dac4429 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2005020100; // YYYYMMDD = date of first major branch release 1.4 + $version = 2005020101; // YYYYMMDD = date of first major branch release 1.4 // XY = increments within a single day $release = '1.5 UNSTABLE DEVELOPMENT'; // Human-friendly version name