Bug #6147 - Upgrade from 1.5.x breaks with Postgres 7.4.x

Even though Postgres 7.4.x is officially supported, several upgrade scripts use syntax that only works in Postgres 8.x. and it's impossible to finish the upgrade.

The attached patch fixes those scripts.

Saludos. Iñaki.

Author: Iñaki Arenaza
Review: Jun Yamog, Martin Langhoff
This commit is contained in:
martinlanghoff
2006-07-31 05:38:20 +00:00
parent 3ad4a1097b
commit 4b8df782c6
6 changed files with 52 additions and 52 deletions
+7 -17
View File
@@ -51,24 +51,14 @@ function backup_upgrade($oldversion=0) {
}
if ($oldversion < 2006042801) {
modify_database('', 'ALTER TABLE prefix_backup_log
ALTER COLUMN "time" TYPE integer,
ALTER COLUMN "time" SET DEFAULT 0,
ALTER COLUMN laststarttime TYPE integer,
ALTER COLUMN laststarttime SET DEFAULT 0,
ALTER COLUMN courseid TYPE integer,
ALTER COLUMN courseid SET DEFAULT 0');
modify_database('', 'ALTER TABLE mdl_backup_courses
ALTER COLUMN lastendtime TYPE integer,
ALTER COLUMN lastendtime SET DEFAULT 0,
ALTER COLUMN laststarttime TYPE integer,
ALTER COLUMN laststarttime SET DEFAULT 0,
ALTER COLUMN courseid TYPE integer,
ALTER COLUMN courseid SET DEFAULT 0,
ALTER COLUMN nextstarttime TYPE integer,
ALTER COLUMN nextstarttime SET DEFAULT 0');
table_column('backup_log', 'time', 'time', 'integer', '', '', '0');
table_column('backup_log', 'laststarttime', 'laststarttime', 'integer', '', '', '0');
table_column('backup_log', 'courseid', 'courseid', 'integer', '', '', '0');
table_column('backup_courses', 'lastendtime', 'lastendtime', 'integer', '', '', '0');
table_column('backup_courses', 'laststarttime', 'laststarttime', 'integer', '', '', '0');
table_column('backup_courses', 'courseid', 'courseid', 'integer', '', '', '0');
table_column('backup_courses', 'nextstarttime', 'nextstarttime', 'integer', '', '', '0');
}
//Finally, return result
+3 -7
View File
@@ -1544,18 +1544,14 @@ function main_upgrade($oldversion=0) {
}
}
modify_database('', 'ALTER TABLE prefix_course_request
ALTER COLUMN "password" TYPE varchar(50),
ALTER COLUMN "password" SET DEFAULT \'\'');
table_column('course_request', 'password', 'password', 'varchar', '50', '', '');
modify_database('', 'ALTER TABLE prefix_course
ALTER COLUMN currency TYPE varchar(3)');
table_column('course', 'currency', 'currency', 'varchar', '3');
modify_database('', 'ALTER TABLE prefix_course_categories
ALTER COLUMN path SET DEFAULT \'\'');
modify_database('', 'ALTER TABLE prefix_log_display
ALTER COLUMN module TYPE varchar(20)');
table_column('log_display', 'module', 'module', 'varchar', '20');
modify_database("","DROP INDEX id_user_idx");
modify_database("","DROP INDEX post_lastmodified_idx");
+24 -16
View File
@@ -318,30 +318,38 @@ function lesson_upgrade($oldversion) {
execute_sql('DROP TABLE '.$CFG->prefix.'lesson_essay', false);
// properly set the correct default values
modify_database('', 'ALTER TABLE prefix_lesson
ALTER COLUMN activitylink TYPE int8,
ALTER COLUMN activitylink SET DEFAULT 0,
ALTER COLUMN dependency TYPE int8,
ALTER COLUMN dependency SET DEFAULT 0');
table_column('lesson', 'activitylink', 'activitylink', 'integer', '8', '', '0');
table_column('lesson', 'dependency', 'dependency', 'integer', '8', '', '0');
modify_database('', 'ALTER TABLE prefix_lesson_timer
ALTER COLUMN lessontime SET DEFAULT 0,
ALTER COLUMN lessonid SET DEFAULT 0,
ALTER COLUMN userid SET DEFAULT 0,
ALTER COLUMN lessontime SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_timer
ALTER COLUMN lessonid SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_timer
ALTER COLUMN userid SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_timer
ALTER COLUMN starttime SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_branch
ALTER COLUMN lessonid SET DEFAULT 0,
ALTER COLUMN timeseen SET DEFAULT 0,
ALTER COLUMN userid SET DEFAULT 0,
ALTER COLUMN retry SET DEFAULT 0,
ALTER COLUMN pageid SET DEFAULT 0,
ALTER COLUMN lessonid SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_branch
ALTER COLUMN timeseen SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_branch
ALTER COLUMN userid SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_branch
ALTER COLUMN retry SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_branch
ALTER COLUMN pageid SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_branch
ALTER COLUMN flag SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_high_scores
ALTER COLUMN nickname SET DEFAULT \'\',
ALTER COLUMN lessonid SET DEFAULT 0,
ALTER COLUMN gradeid SET DEFAULT 0,
ALTER COLUMN nickname SET DEFAULT \'\'');
modify_database('', 'ALTER TABLE prefix_lesson_high_scores
ALTER COLUMN lessonid SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_high_scores
ALTER COLUMN gradeid SET DEFAULT 0');
modify_database('', 'ALTER TABLE prefix_lesson_high_scores
ALTER COLUMN userid SET DEFAULT 0');
}
+10 -8
View File
@@ -1216,16 +1216,10 @@ function quiz_upgrade($oldversion) {
id SERIAL PRIMARY KEY,
modulename varchar(20) NOT NULL default 'quiz'
);");
// create one entry for all the existing quiz attempts
modify_database ("", "INSERT INTO prefix_question_attempts (id)
SELECT uniqueid
FROM prefix_quiz_attempts;");
}
if ($oldversion < 2006042802) {
// this block is taken from mysql.php 2005070202
// add new unique id to prepare the way for lesson module to have its own attempts table
table_column('quiz_attempts', '', 'uniqueid', 'integer', '10', 'unsigned', '0', 'not null', 'id');
// create one entry for all the existing quiz attempts
// initially we can use the id as the unique id because no other modules use attempts yet.
execute_sql("UPDATE {$CFG->prefix}quiz_attempts SET uniqueid = id", false);
// we set $CFG->attemptuniqueid to the next available id
@@ -1235,6 +1229,13 @@ function quiz_upgrade($oldversion) {
modify_database('','CREATE UNIQUE INDEX prefix_quiz_attempts_uniqueid_uk ON prefix_quiz_attempts (uniqueid);');
modify_database ("", "INSERT INTO prefix_question_attempts (id)
SELECT uniqueid
FROM prefix_quiz_attempts;");
}
if ($oldversion < 2006042802) {
// Copy the teacher comments from the question_essay_states table to the new
// question_sessions table.
@@ -1275,7 +1276,8 @@ function quiz_upgrade($oldversion) {
execute_sql('DROP TABLE '.$CFG->prefix.'quiz_attemptonlast_datasets');
modify_database('', 'ALTER TABLE prefix_question
ALTER COLUMN qtype SET DEFAULT \'0\',
ALTER COLUMN qtype SET DEFAULT \'0\'');
modify_database('', 'ALTER TABLE prefix_question
ALTER COLUMN version SET DEFAULT \'\'');
// recreate the indexes that was not moved while quiz was transitioning to question lib
+2 -1
View File
@@ -232,7 +232,8 @@ function scorm_upgrade($oldversion) {
if ($oldversion < 2006021401) {
table_column("scorm", "", "version", "VARCHAR", "9", "", "", "NOT NULL", "reference");
modify_database('', 'ALTER TABLE prefix_scorm ALTER COLUMN width SET DEFAULT 100, ALTER COLUMN height SET DEFAULT 500');
modify_database('', 'ALTER TABLE prefix_scorm ALTER COLUMN width SET DEFAULT 100');
modify_database('', 'ALTER TABLE prefix_scorm ALTER COLUMN height SET DEFAULT 500');
// there is an extra constraint key1, we should drop this
modify_database('', 'ALTER TABLE prefix_scorm_scoes_track DROP CONSTRAINT prefix_scorm_scoes_track_userid_key1');
modify_database('', 'ALTER TABLE prefix_scorm_scoes_track DROP CONSTRAINT prefix_scorm_scoes_track_userid_key');
+6 -3
View File
@@ -147,9 +147,12 @@ function wiki_upgrade($oldversion) {
if ($oldversion < 2006042801) {
modify_database('', 'ALTER TABLE prefix_wiki_pages
ALTER COLUMN content SET DEFAULT \'\',
ALTER COLUMN refs SET DEFAULT \'\',
ALTER COLUMN content DROP NOT NULL,
ALTER COLUMN content SET DEFAULT \'\'');
modify_database('', 'ALTER TABLE prefix_wiki_pages
ALTER COLUMN refs SET DEFAULT \'\'');
modify_database('', 'ALTER TABLE prefix_wiki_pages
ALTER COLUMN content DROP NOT NULL');
modify_database('', 'ALTER TABLE prefix_wiki_pages
ALTER COLUMN refs DROP NOT NULL');
}