Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing the mass migrate postgres upgrade to be silent in quiz. Added …

…a fix to a previous rename table that breaks pg_dump & pg_restore (incorrectly named sequence)
  • Loading branch information...
commit dde5cbbdfda1be200c925be5b64e5e4a56d81d70 1 parent 38f78e1
mjollnir_ authored
Showing with 41 additions and 34 deletions.
  1. +40 −33 mod/quiz/db/postgres7.php
  2. +1 −1  mod/quiz/version.php
View
73 mod/quiz/db/postgres7.php
@@ -922,41 +922,48 @@ function quiz_upgrade($oldversion) {
}
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');
+ execute_sql('CREATE UNIQUE INDEX '.$CFG->prefix.'quiz_newest_states_attempt_idx ON '.$CFG->prefix.'quiz_newest_states (attemptid, questionid)',false);
+ execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_attemptonlast_datasets DROP CONSTRAINT '.$CFG->prefix.'quiz_category_userid_unique',false);
+ execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_attemptonlast_datasets ADD CONSTRAINT '.$CFG->prefix.'quiz_attemptonlast_datasets_category_userid UNIQUE (category, userid)',false);
+ execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_question_instances DROP CONSTRAINT '.$CFG->prefix.'quiz_question_grades_pkey',false);
+ execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_question_instances ADD CONSTRAINT '.$CFG->prefix.'quiz_question_instances_pkey PRIMARY KEY (id)',false);
+ execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_question_versions DROP CONSTRAINT '.$CFG->prefix.'quiz_question_version_pkey',false);
+ execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_question_versions ADD CONSTRAINT '.$CFG->prefix.'quiz_question_versions_pkey PRIMARY KEY (id)',false);
+ execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_states DROP CONSTRAINT '.$CFG->prefix.'quiz_responses_pkey',false);
+ execute_sql('ALTER TABLE ONLY '.$CFG->prefix.'quiz_states ADD CONSTRAINT '.$CFG->prefix.'quiz_states_pkey PRIMARY KEY (id)',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER decimalpoints SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER optionflags SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER penaltyscheme SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER popup SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER questionsperpage SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz ALTER review SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_answers ALTER answer SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_attempts ALTER layout SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_attempts ALTER preview SET NOT NULL',false);
+
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');
+
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_categories ALTER parent SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_categories ALTER sortorder SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_grades ALTER grade SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_multianswers ALTER sequence SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_numerical ALTER tolerance SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_questions ALTER hidden SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_questions ALTER length SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_questions ALTER parent SET NOT NULL',false);
+
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');
+
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER answer SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER event SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER originalquestion SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER penalty SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER raw_grade SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER seq_number SET NOT NULL',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_states ALTER timestamp SET NOT NULL',false);
+ // clean up an old mistake.
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_question_version_id_seq RENAME TO '.$CFG->prefix.'quiz_question_versions_id_seq',false);
+ execute_sql('ALTER TABLE '.$CFG->prefix.'quiz_question_versions ALTER COLUMN id SET DEFAULT nextval(\''.$CFG->prefix.'quiz_question_versions_id_seq\')',false);
}
return true;
View
2  mod/quiz/version.php
@@ -5,7 +5,7 @@
// This fragment is called by moodle_needs_upgrading() and /admin/index.php
////////////////////////////////////////////////////////////////////////////////
-$module->version = 2005060301; // The (date) version of this module
+$module->version = 2005060302; // The (date) version of this module
$module->requires = 2005021600; // Requires this Moodle version
$module->cron = 0; // How often should cron check this module (seconds)?
Please sign in to comment.
Something went wrong with that request. Please try again.