Permalink
Browse files

Mass cleanup of bad postgres upgrade scripts

  • Loading branch information...
1 parent 0b7c884 commit a3c092c96debe098d1d22c5258e6c8ebc20fbd40 patrickslee committed Aug 15, 2005
View
@@ -138,6 +138,14 @@ function blocks_upgrade($oldversion=0) {
}
}
+ if ($oldversion < 2005022401 && $result) { // Mass cleanup of bad upgrade scripts
+ modify_database('','CREATE INDEX prefix_block_instance_pageid_idx ON prefix_block_instance (pageid)');
+ modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET DEFAULT \'\'');
+ modify_database('','ALTER TABLE prefix_block_instance ALTER position SET DEFAULT \'\'');
+ modify_database('','ALTER TABLE prefix_block_instance ALTER pagetype SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_block_instance ALTER position SET NOT NULL');
+ }
+
//Finally, return result
return $result;
}
View
@@ -10,7 +10,7 @@ CREATE TABLE prefix_block (
cron INT8 NOT NULL default '0',
lastcron INT8 NOT NULL default '0',
visible int NOT NULL default '1',
- multiple int NOT NULL default '1'
+ multiple int NOT NULL default '0'
) ;
CREATE TABLE prefix_block_instance (
@@ -23,5 +23,7 @@ CREATE TABLE prefix_block_instance (
visible int not null default '0',
configdata text not null default ''
) ;
+
+CREATE INDEX prefix_block_instance_pageid_idx ON prefix_block_instance (pageid);
# --------------------------------------------------------
View
@@ -1179,6 +1179,30 @@ function main_upgrade($oldversion=0) {
execute_sql("DROP TABLE {$CFG->prefix}currencies",false); // drop silently
}
+ if ($oldversion < 2005060223) { // Mass cleanup of bad postgres upgrade scripts
+ execute_sql("DROP TABLE {$CFG->prefix}attendance_roll", false); // There are no attendance module anymore
+ modify_database('','ALTER TABLE prefix_config ALTER value SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_course ALTER metacourse SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_course ALTER theme SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_event ALTER repeatid SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_groups ALTER password SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_groups ALTER theme SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_message ALTER format SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_message_read ALTER format SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_groups ALTER theme SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_user ALTER aim DROP DEFAULT');
+ modify_database('','ALTER TABLE prefix_user ALTER idnumber DROP DEFAULT');
+ modify_database('','ALTER TABLE prefix_user ALTER msn DROP DEFAULT');
+ modify_database('','ALTER TABLE prefix_user ALTER policyagreed SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_user ALTER skype DROP DEFAULT');
+ modify_database('','ALTER TABLE prefix_user ALTER theme SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_user ALTER timezone SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_user ALTER trackforums SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_user ALTER yahoo DROP DEFAULT');
+ modify_database('','ALTER TABLE prefix_user_students ALTER enrol SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_user_teachers ALTER enrol SET NOT NULL');
+ }
+
return $result;
}
View
@@ -444,6 +444,7 @@ CREATE TABLE prefix_user_students (
CREATE UNIQUE INDEX prefix_user_students_courseuserid_uk ON prefix_user_students (course,userid);
CREATE INDEX prefix_user_students_userid_idx ON prefix_user_students (userid);
CREATE INDEX prefix_user_students_enrol_idx ON prefix_user_students (enrol);
+CREATE INDEX prefix_user_students_timeaccess_idx ON prefix_user_students (timeaccess);
CREATE TABLE prefix_user_teachers (
id SERIAL PRIMARY KEY,
@@ -468,6 +469,8 @@ CREATE TABLE prefix_user_coursecreators (
userid int8 NOT NULL default '0'
);
+CREATE INDEX prefix_user_coursecreators_userid_idx ON prefix_user_coursecreators (userid);
+
CREATE TABLE adodb_logsql (
created timestamp NOT NULL,
sql0 varchar(250) NOT NULL,
@@ -157,6 +157,15 @@ function assignment_upgrade($oldversion) {
assignment_refresh_events();
}
+ if ($oldversion < 2005060101) { // Mass cleanup of bad upgrade scripts
+ modify_database('','ALTER TABLE prefix_assignment ALTER assignmenttype SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_assignment ALTER emailteachers SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_assignment ALTER preventlate SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_assignment ALTER timeavailable SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_assignment_submissions ALTER data1 SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_assignment_submissions ALTER data2 SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_assignment_submissions ALTER format SET NOT NULL');
+ }
/// These lines ALWAYS need to be here at the end of this file. Don't mess with them. :-)
include_once("$CFG->dirroot/mod/assignment/lib.php");
@@ -47,6 +47,11 @@ function chat_upgrade($oldversion) {
table_column('chat_users', '', 'lang' , 'varchar', '10', '' , '' , 'not null', '');
}
+ if ($oldversion < 2005031001) { // Mass cleanup of bad upgrade scripts
+ modify_database('','ALTER TABLE prefix_chat_users ALTER course SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_chat_users ALTER lang SET NOT NULL');
+ }
+
return true;
}
@@ -90,6 +90,15 @@ function choice_upgrade($oldversion) {
table_column('choice', '', 'limitanswers', 'INTEGER', '2', 'unsigned', 0, 'not null', 'showunanswered');
table_column('choice_options', '', 'maxanswers', 'INTEGER', '10', 'unsigned', 0, 'null', 'text');
}
+
+ if ($oldversion < 2005041501) { // Mass cleanup of bad upgrade scripts
+ modify_database('','CREATE INDEX prefix_choice_answers_choice_idx ON prefix_choice_answers (choiceid)');
+ modify_database('','ALTER TABLE prefix_choice ALTER display SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_choice ALTER limitanswers SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_choice_answers ALTER choiceid SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_choice_answers ALTER optionid SET NOT NULL');
+ }
+
return true;
}
@@ -20,6 +20,11 @@ function dialogue_upgrade($oldversion) {
modify_database('','CREATE INDEX prefix_dialogue_entries_userid_idx ON prefix_dialogue_entries (userid);');
}
+ if ($oldversion < 2005031001) { // Mass cleanup of bad postgres upgrade scripts
+ modify_database('','ALTER TABLE prefix_dialogue ALTER name SET DEFAULT \'\'');
+ modify_database('','ALTER TABLE prefix_dialogue ALTER name SET NOT NULL');
+ }
+
$result = true;
return $result;
}
@@ -146,6 +146,9 @@ function forum_upgrade($oldversion) {
modify_database('','CREATE INDEX prefix_forum_track_user_forum_idx ON prefix_forum_track_prefs (userid, forumid);');
}
+ if ($oldversion < 2005042601) { // Mass cleanup of bad postgres upgrade scripts
+ modify_database('','ALTER TABLE prefix_forum ALTER trackingtype SET NOT NULL');
+ }
return true;
@@ -178,6 +178,10 @@ function glossary_upgrade($oldversion) {
$wtm->update( 'glossary_comments','text','format',$sql );
}
+ if ($oldversion < 2005041901) { // Mass cleanup of bad postgres upgrade scripts
+ table_column('glossary','allowprintview','allowprintview','smallint','4','unsigned','1');
+ }
+
return true;
}
@@ -216,6 +216,36 @@ function lesson_upgrade($oldversion) {
table_column('lesson_grades', 'grade', 'grade', 'real', '', 'unsigned', '0', 'not null');
}
+ if ($oldversion < 2005060901) { // Mass cleanup of bad postgres upgrade scripts
+ modify_database('','ALTER TABLE prefix_lesson ALTER bgcolor SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER custom SET NOT NULL');
+ table_column('lesson','height','height','integer','16','unsigned','480');
+ modify_database('','ALTER TABLE prefix_lesson ALTER highscores SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER maxattempts SET DEFAULT 5');
+ table_column('lesson','maxhighscores','maxhighscores','integer','16');
+ modify_database('','ALTER TABLE prefix_lesson ALTER displayleft SET NOT NULL');
+ table_column('lesson','','minquestions','integer','8');
+ table_column('lesson','maxtime','maxtime','integer','16');
+ modify_database('','ALTER TABLE prefix_lesson ALTER ongoing SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER password SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER practice SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER review SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER slideshow SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER timed SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER tree SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER usepassword SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson ALTER width SET NOT NULL');
+ table_column('lesson','width','width','integer','16','unsigned','640');
+ table_column('lesson_answers','flags','flags','integer','8');
+ table_column('lesson_answers','grade','grade','integer','8');
+ table_column('lesson_answers','score','score','integer','16');
+ modify_database('','ALTER TABLE prefix_lesson_grades ALTER grade SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson_pages ALTER display SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_lesson_pages ALTER layout SET NOT NULL');
+ table_column('lesson_pages','qoption','qoption','integer','8');
+ table_column('lesson_pages','qtype','qtype','integer','8');
+ }
+
return true;
}
View
@@ -920,6 +920,44 @@ function quiz_upgrade($oldversion) {
execute_sql('CREATE UNIQUE INDEX '.$CFG->prefix.'quiz_rqp_types_name_uk ON '.$CFG->prefix.'quiz_rqp_types (name);');
}
+
+ if ($oldversion < 2005060302) { // Mass cleanup of bad postgres upgrade scripts
+ modify_database('','CREATE UNIQUE INDEX prefix_quiz_newest_states_attempt_idx ON prefix_quiz_newest_states (attemptid, questionid)');
+ modify_database('','ALTER TABLE ONLY prefix_quiz_attemptonlast_datasets DROP CONSTRAINT prefix_quiz_category_userid_unique');
+ modify_database('','ALTER TABLE ONLY prefix_quiz_attemptonlast_datasets ADD CONSTRAINT prefix_quiz_attemptonlast_datasets_category_userid UNIQUE (category, userid)');
+ modify_database('','ALTER TABLE ONLY prefix_quiz_question_instances DROP CONSTRAINT prefix_quiz_question_grades_pkey');
+ modify_database('','ALTER TABLE ONLY prefix_quiz_question_instances ADD CONSTRAINT prefix_quiz_question_instances_pkey PRIMARY KEY (id)');
+ modify_database('','ALTER TABLE ONLY prefix_quiz_question_versions DROP CONSTRAINT prefix_quiz_question_version_pkey');
+ modify_database('','ALTER TABLE ONLY prefix_quiz_question_versions ADD CONSTRAINT prefix_quiz_question_versions_pkey PRIMARY KEY (id)');
+ modify_database('','ALTER TABLE ONLY prefix_quiz_states DROP CONSTRAINT prefix_quiz_responses_pkey');
+ modify_database('','ALTER TABLE ONLY prefix_quiz_states ADD CONSTRAINT prefix_quiz_states_pkey PRIMARY KEY (id)');
+ modify_database('','ALTER TABLE prefix_quiz ALTER decimalpoints SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz ALTER optionflags SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz ALTER penaltyscheme SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz ALTER popup SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz ALTER questionsperpage SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz ALTER review SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_answers ALTER answer SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_attempts ALTER layout SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_attempts ALTER preview SET NOT NULL');
+ table_column('quiz_calculated','correctanswerformat','correctanswerformat','integer','16','unsigned','2');
+ modify_database('','ALTER TABLE prefix_quiz_categories ALTER parent SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_categories ALTER sortorder SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_grades ALTER grade SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_multianswers ALTER sequence SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_numerical ALTER tolerance SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_questions ALTER hidden SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_questions ALTER length SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_questions ALTER parent SET NOT NULL');
+ table_column('quiz_questions','penalty','penalty','real','','UNSIGNED','0.1');
+ modify_database('','ALTER TABLE prefix_quiz_states ALTER answer SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_states ALTER event SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_states ALTER originalquestion SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_states ALTER penalty SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_states ALTER raw_grade SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_states ALTER seq_number SET NOT NULL');
+ modify_database('','ALTER TABLE prefix_quiz_states ALTER timestamp SET NOT NULL');
+ }
return true;
}
@@ -88,7 +88,7 @@ CREATE TABLE prefix_quiz_attempts (
timestart integer NOT NULL default '0',
timefinish integer NOT NULL default '0',
timemodified integer NOT NULL default '0',
- layout text NOT NULL,
+ layout text NOT NULL default '',
preview integer NOT NULL default '0'
);
@@ -272,6 +272,7 @@ CREATE TABLE prefix_quiz_numerical (
tolerance varchar(255) NOT NULL default '0.0'
);
+CREATE INDEX prefix_quiz_numerical_answer_idx ON prefix_quiz_numerical (answer);
CREATE INDEX prefix_quiz_numerical_question_idx ON prefix_quiz_numerical (question);
# --------------------------------------------------------
@@ -448,7 +449,7 @@ CREATE TABLE prefix_quiz_states (
question integer NOT NULL default '0',
originalquestion integer NOT NULL default '0',
seq_number integer NOT NULL default '0',
- answer text NOT NULL,
+ answer text NOT NULL default '',
timestamp integer NOT NULL default '0',
event integer NOT NULL default '0',
grade varchar(10) NOT NULL default '0.0',
View
@@ -174,6 +174,23 @@ function scorm_upgrade($oldversion) {
table_column("scorm_scoes_track", "", "timemodified", "integer", "", "", "0", "NOT NULL", "value");
}
+ if ($oldversion < 2005052301) { // Mass cleanup of bad upgrade scripts
+ execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_scormid_idx", false);
+ execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_userid_idx", false);
+ execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_scoid_idx", false);
+ modify_database('','CREATE INDEX prefix_scorm_scoes_track_scorm_idx ON prefix_scorm_scoes_track (scormid);');
+ modify_database('','CREATE INDEX prefix_scorm_scoes_track_user_idx ON prefix_scorm_scoes_track (userid);');
+ modify_database('','CREATE INDEX prefix_scorm_scoes_track_sco_idx ON prefix_scorm_scoes_track (scoid);');
+ execute_sql("DROP INDEX {$CFG->prefix}scorm_scoes_track_track_idx", false);
+ modify_database('','ALTER TABLE ONLY prefix_scorm_scoes_track DROP CONSTRAINT prefix_scorm_scoes_track_pkey');
+ modify_database('','ALTER TABLE ONLY prefix_scorm_scoes_track ADD CONSTRAINT prefix_scorm_scoes_track_pkey PRIMARY KEY (id)');
+ modify_database('','ALTER TABLE ONLY prefix_scorm_scoes_track ADD UNIQUE (userid, scormid, scoid, element)');
+ modify_database('','ALTER TABLE prefix_scorm ALTER browsemode SET DEFAULT 0');
+ modify_database('','ALTER TABLE prefix_scorm DROP version');
+ table_column('scorm_scoes','datafromlms','datafromlms','VARCHAR','255','','');
+ table_column('scorm_scoes','maxtimeallowed','maxtimeallowed','VARCHAR','19','','');
+ }
+
return true;
}
?>
@@ -207,6 +207,36 @@ function workshop_upgrade($oldversion) {
$wtm->update( 'workshop','description','format' );
}
+ if ($oldversion < 2005041201) { // Mass cleanup of bad upgrade scripts
+ // Some of those steps might fail, it is normal.
+ table_column('workshop','assessmentend','assessmentend','integer','16');
+ table_column('workshop','assessmentstart','assessmentstart','integer','16');
+ table_column('workshop','','phase','integer','4');
+ table_column('workshop','','showleaguetable','integer','8');
+ table_column('workshop','releasegrades','releasegrades','integer','16');
+ table_column('workshop','submissionend','submissionend','integer','16');
+ table_column('workshop','submissionstart','submissionstart','integer','16');
+ modify_database('','ALTER TABLE prefix_workshop ALTER teacherweight SET DEFAULT 1');
+ modify_database('','ALTER TABLE prefix_workshop DROP timeagreed');
+ modify_database('','ALTER TABLE prefix_workshop RENAME inalgrade TO finalgrade');
+ table_column('workshop_assessments','','donotuse','integer','8');
+ table_column('workshop_assessments','','timeagreed','integer','16');
+ modify_database('','ALTER TABLE prefix_workshop_assessments DROP teachergraded');
+ modify_database('','ALTER TABLE prefix_workshop_elements RENAME totalrassesments TO totalassessments');
+ modify_database('','ALTER TABLE prefix_workshop_submissions ALTER description DROP DEFAULT');
+ table_column('workshop_submissions','nassessments','nassessments','integer','16');
+ table_column('workshop_elements','totalassessments','totalassessments','integer','16');
+ execute_sql("
+ CREATE TABLE {$CFG->prefix}workshop_rubrics (
+ id SERIAL PRIMARY KEY,
+ workshopid int8 NOT NULL default '0',
+ elementno int8 NOT NULL default '0',
+ rubricno int4 NOT NULL default '0',
+ description text NOT NULL
+ )
+ ");
+ }
+
return true;
}
@@ -55,8 +55,8 @@ CREATE TABLE prefix_workshop_submissions (
description TEXT,
gradinggrade INT NOT NULL default '0',
late INT NOT NULL DEFAULT '0',
- inalgrade INT NOT NULL default '0',
- nassessments INT8 NOT NULL default 0
+ finalgrade INT NOT NULL default '0',
+ nassessments INT8 NOT NULL default '0'
);
CREATE INDEX prefix_workshop_submissions_title_idx on prefix_workshop_submissions (title);
@@ -108,7 +108,7 @@ CREATE TABLE prefix_workshop_elements (
maxscore INT NOT NULL default '1',
weight INT4 NOT NULL default '11',
stddev FLOAT NOT NULL default '0',
- totalrassesments INT8 NOT NULL DEFAULT '0'
+ totalassessments INT8 NOT NULL DEFAULT '0'
);
CREATE INDEX prefix_workshop_elements_workshopid_idx ON prefix_workshop_elements (workshopid);

0 comments on commit a3c092c

Please sign in to comment.