Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 4b8df782c652e68bf14a44622bd8b26e71820ee5 1 parent 3ad4a10
martinlanghoff authored
View
24 backup/db/postgres7.php
@@ -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
View
10 lib/db/postgres7.php
@@ -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");
View
40 mod/lesson/db/postgres7.php
@@ -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');
}
View
18 mod/quiz/db/postgres7.php
@@ -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
View
3  mod/scorm/db/postgres7.php
@@ -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');
View
9 mod/wiki/db/postgres7.php
@@ -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');
}
Please sign in to comment.
Something went wrong with that request. Please try again.