Permalink
Browse files

Indexes for lesson and version bump (honoring partial freeze)

  • Loading branch information...
1 parent b55be22 commit 0d3a8fa2805ac730eb041330e2d11da6139f42cd mjollnir_ committed Nov 19, 2004
Showing with 54 additions and 6 deletions.
  1. +10 −0 mod/lesson/db/mysql.php
  2. +12 −5 mod/lesson/db/mysql.sql
  3. +12 −0 mod/lesson/db/postgres7.php
  4. +19 −0 mod/lesson/db/postgres7.sql
  5. +1 −1 mod/lesson/version.php
View
@@ -39,6 +39,16 @@ function lesson_upgrade($oldversion) {
if ($oldversion < 2004032700) {
table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
}
+
+ if ($oldversion < 2004060401) {
+ modify_database('','ALTER TABLE prefix_lesson ADD INDEX course (course);');
+ modify_database('','ALTER TABLE prefix_lesson_answers ADD INDEX lessonid (lessonid);');
+ modify_database('','ALTER TABLE prefix_lesson_attempts ADD INDEX lessonid (lessonid);');
+ modify_database('','ALTER TABLE prefix_lesson_attempts ADD INDEX pageid (pageid);');
+ modify_database('','ALTER TABLE prefix_lesson_grades ADD INDEX lessonid (lessonid);');
+ modify_database('','ALTER TABLE prefix_lesson_grades ADD INDEX userid (userid);');
+ modify_database('','ALTER TABLE prefix_lesson_pages ADD INDEX lessonid (lessonid);');
+ }
return true;
}
View
@@ -19,7 +19,8 @@ CREATE TABLE `prefix_lesson` (
`available` int(10) unsigned NOT NULL default '0',
`deadline` int(10) unsigned NOT NULL default '0',
`timemodified` int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ KEY `course` (`course`)
) COMMENT='Defines lesson';
# --------------------------------------------------------
@@ -34,7 +35,8 @@ CREATE TABLE `prefix_lesson_pages` (
`timemodified` int(10) unsigned NOT NULL default '0',
`title` varchar(255) NOT NULL default '',
`contents` text NOT NULL default '',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ KEY `lessonid` (`lessonid`)
) COMMENT='Defines lesson_pages';
# --------------------------------------------------------
@@ -50,7 +52,8 @@ CREATE TABLE `prefix_lesson_answers` (
`answer` text NOT NULL default '',
`response` text NOT NULL default '',
PRIMARY KEY (`id`),
- KEY (`pageid`)
+ KEY (`pageid`),
+ KEY `lessonid` (`lessonid`)
) COMMENT='Defines lesson_answers';
# --------------------------------------------------------
@@ -64,7 +67,9 @@ CREATE TABLE `prefix_lesson_attempts` (
`correct` int(10) unsigned NOT NULL default '0',
`timeseen` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
- KEY (`userid`)
+ KEY (`userid`),
+ KEY `lessonid` (`lessonid`),
+ KEY `pageid` (`pageid`)
) COMMENT='Defines lesson_attempts';
# --------------------------------------------------------
@@ -75,7 +80,9 @@ CREATE TABLE `prefix_lesson_grades` (
`grade` int(3) unsigned NOT NULL default '0',
`late` int(3) unsigned NOT NULL default '0',
`completed` int(10) unsigned NOT NULL default '0',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ KEY `lessonid` (`lessonid`),
+ KEY `userid` (`userid`)
) COMMENT='Defines lesson_grades';
# --------------------------------------------------------
@@ -39,6 +39,18 @@ function lesson_upgrade($oldversion) {
if ($oldversion < 2004032700) {
table_column("lesson_answers", "", "flags", "INTEGER", "4", "UNSIGNED", "0", "NOT NULL", "grade");
}
+
+ if ($oldversion < 2004060401) {
+ modify_database('','CREATE INDEX prefix_lesson_course_idx ON prefix_lesson (course);');
+ modify_database('','CREATE INDEX prefix_lesson_answers_lessonid_idx ON prefix_lesson_answers (lessonid);');
+ modify_database('','CREATE INDEX prefix_lesson_answers_pageid_idx ON prefix_lesson_answers (pageid);');
+ modify_database('','CREATE INDEX prefix_lesson_attempts_lessonid_idx ON prefix_lesson_attempts (lessonid);');
+ modify_database('','CREATE INDEX prefix_lesson_attempts_pageid_idx ON prefix_lesson_attempts (pageid);');
+ modify_database('','CREATE INDEX prefix_lesson_attempts_userid_idx ON prefix_lesson_attempts (userid);');
+ modify_database('','CREATE INDEX prefix_lesson_grades_lessonid_idx ON prefix_lesson_grades (lessonid);');
+ modify_database('','CREATE INDEX prefix_lesson_grades_userid_idx ON prefix_lesson_grades (userid);');
+ modify_database('','CREATE INDEX prefix_lesson_pages_lessonid_idx ON prefix_lesson_pages (lessonid);');
+ }
return true;
}
@@ -19,6 +19,9 @@ CREATE TABLE prefix_lesson (
deadline INT8 NOT NULL default '0',
timemodified INT8 NOT NULL default '0'
);
+
+CREATE INDEX prefix_lesson_course_idx ON prefix_lesson (course);
+
# --------------------------------------------------------
CREATE TABLE prefix_lesson_pages (
@@ -33,6 +36,9 @@ CREATE TABLE prefix_lesson_pages (
title varchar(255) NOT NULL default '',
contents text NOT NULL default ''
);
+
+CREATE INDEX prefix_lesson_pages_lessonid_idx ON prefix_lesson_pages (lessonid);
+
# COMMENT='Defines lesson_pages';
# --------------------------------------------------------
@@ -48,6 +54,10 @@ CREATE TABLE prefix_lesson_answers (
answer text NOT NULL default '',
response text NOT NULL default ''
);
+
+CREATE INDEX prefix_lesson_answers_lessonid_idx ON prefix_lesson_answers (lessonid);
+CREATE INDEX prefix_lesson_answers_pageid_idx ON prefix_lesson_answers (pageid);
+
# COMMENT='Defines lesson_answers';
# --------------------------------------------------------
@@ -61,6 +71,11 @@ CREATE TABLE prefix_lesson_attempts (
correct INT8 NOT NULL default '0',
timeseen INT8 NOT NULL default '0'
);
+
+CREATE INDEX prefix_lesson_attempts_lessonid_idx ON prefix_lesson_attempts (lessonid);
+CREATE INDEX prefix_lesson_attempts_pageid_idx ON prefix_lesson_attempts (pageid);
+CREATE INDEX prefix_lesson_attempts_userid_idx ON prefix_lesson_attempts (userid);
+
#COMMENT='Defines lesson_attempts';
# --------------------------------------------------------
@@ -72,6 +87,10 @@ CREATE TABLE prefix_lesson_grades (
late INT NOT NULL default '0',
completed INT8 NOT NULL default '0'
);
+
+CREATE INDEX prefix_lesson_grades_lessonid_idx ON prefix_lesson_grades (lessonid);
+CREATE INDEX prefix_lesson_grades_userid_idx ON prefix_lesson_grades (userid);
+
# COMMENT='Defines lesson_grades';
# --------------------------------------------------------
View
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2004060400; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2004060401; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2004052505; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)

0 comments on commit 0d3a8fa

Please sign in to comment.