From 15e0081234ab0f6edfda5c30f5f5f3672669d142 Mon Sep 17 00:00:00 2001 From: mjollnir_ Date: Wed, 17 Nov 2004 23:03:56 +0000 Subject: [PATCH] Merged from MOODLE_14_STABLE: Indexes and version bump for choice --- mod/choice/db/mysql.php | 9 +++++++++ mod/choice/db/mysql.sql | 7 +++++-- mod/choice/db/postgres7.php | 10 ++++++++++ mod/choice/db/postgres7.sql | 4 ++++ mod/choice/version.php | 2 +- 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/mod/choice/db/mysql.php b/mod/choice/db/mysql.php index 5a5449d04b..68438233db 100644 --- a/mod/choice/db/mysql.php +++ b/mod/choice/db/mysql.php @@ -43,6 +43,15 @@ function choice_upgrade($oldversion) { modify_database("", "UPDATE prefix_choice SET publish = publish - 1 WHERE publish > 0;"); } + if ($oldversion < 2004111200){ // drop first to avoid conflicts when upgrading from 1.4+ + execute_sql('ALTER TABLE prefix_choice DROP INDEX course;',false); + execute_sql('ALTER TABLE prefix_choice_answers DROP INDEX choice;',false); + execute_sql('ALTER TABLE prefix_choice_answers DROP INDEX userid;',false); + + modify_database('','ALTER TABLE prefix_choice ADD INDEX course (course);'); + modify_database('','ALTER TABLE prefix_choice_answers ADD INDEX choice (choice);'); + modify_database('','ALTER TABLE prefix_choice_answers ADD INDEX userid (userid);'); + } return true; } diff --git a/mod/choice/db/mysql.sql b/mod/choice/db/mysql.sql index 8c2cbea745..40640e3806 100755 --- a/mod/choice/db/mysql.sql +++ b/mod/choice/db/mysql.sql @@ -34,7 +34,8 @@ CREATE TABLE prefix_choice ( timeclose int(10) unsigned NOT NULL default '0', timemodified int(10) unsigned NOT NULL default '0', PRIMARY KEY (id), - UNIQUE KEY id (id) + UNIQUE KEY id (id), + KEY course (course) ) TYPE=MyISAM COMMENT='Available choices are stored here.'; @@ -51,7 +52,9 @@ CREATE TABLE prefix_choice_answers ( answer tinyint(4) NOT NULL default '0', timemodified int(10) NOT NULL default '0', PRIMARY KEY (id), - UNIQUE KEY id (id) + UNIQUE KEY id (id), + KEY userid (userid), + KEY choice (choice) ) TYPE=MyISAM; # diff --git a/mod/choice/db/postgres7.php b/mod/choice/db/postgres7.php index 75440914f5..4c126e2d9c 100644 --- a/mod/choice/db/postgres7.php +++ b/mod/choice/db/postgres7.php @@ -29,6 +29,16 @@ function choice_upgrade($oldversion) { modify_database("", "UPDATE prefix_choice SET publish = publish - 1 WHERE publish > 0;"); } + if ($oldversion < 2004111200) { // drop first to avoid conflicts when upgrading from 1.4+ + execute_sql('DROP INDEX prefix_choice_course_idx;',false); + execute_sql('DROP INDEX prefix_choice_answers_choice_idx;',false); + execute_sql('DROP INDEX prefix_choice_answers_userid_idx;',false); + + modify_database('','CREATE INDEX prefix_choice_course_idx ON prefix_choice (course);'); + modify_database('','CREATE INDEX prefix_choice_answers_choice_idx ON prefix_choice_answers (choice);'); + modify_database('','CREATE INDEX prefix_choice_answers_userid_idx ON prefix_choice_answers (userid);'); + } + return true; } diff --git a/mod/choice/db/postgres7.sql b/mod/choice/db/postgres7.sql index 114425c294..8243254f73 100755 --- a/mod/choice/db/postgres7.sql +++ b/mod/choice/db/postgres7.sql @@ -35,6 +35,7 @@ CREATE TABLE prefix_choice ( timemodified integer NOT NULL default '0' ); +CREATE INDEX prefix_choice_course_idx ON prefix_choice (course); # -------------------------------------------------------- @@ -50,6 +51,9 @@ CREATE TABLE prefix_choice_answers ( timemodified integer NOT NULL default '0' ); +CREATE INDEX prefix_choice_answers_choice_idx ON prefix_choice_answers (choice); +CREATE INDEX prefix_choice_answers_userid_idx ON prefix_choice_answers (userid); + # # Dumping data for table `log_display` # diff --git a/mod/choice/version.php b/mod/choice/version.php index 29f584bf03..d5c7b29cd3 100644 --- a/mod/choice/version.php +++ b/mod/choice/version.php @@ -5,7 +5,7 @@ // This fragment is called by /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2004070102; +$module->version = 2004111200; $module->requires = 2004052505; // Requires this Moodle version $module->cron = 0; -- 2.39.5