Another fix for metacourses (lost auto_increment). This will preserve data.

This commit is contained in:
mjollnir_ 2005-02-01 04:47:04 +00:00
parent d897c9c416
commit 8a4e77ae1b
2 changed files with 35 additions and 1 deletions

View File

@ -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;
}

View File

@ -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