]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from MOODLE_14_STABLE: Indexes for chat and version bump
authormjollnir_ <mjollnir_>
Wed, 17 Nov 2004 22:54:16 +0000 (22:54 +0000)
committermjollnir_ <mjollnir_>
Wed, 17 Nov 2004 22:54:16 +0000 (22:54 +0000)
mod/chat/db/mysql.php
mod/chat/db/mysql.sql
mod/chat/db/postgres7.php
mod/chat/db/postgres7.sql
mod/chat/version.php

index 76608fe3de38aa5bfa2a79d211c4b4ae9796dc74..bea62ca47aedbb0335c00b37b995adfbc0416595 100644 (file)
@@ -37,6 +37,22 @@ function chat_upgrade($oldversion) {
         modify_database("", "INSERT INTO prefix_log_display VALUES ('chat', 'talk', 'chat', 'name');");
     }
 
+    if ($oldversion < 2004111200) {
+        execute_sql('ALTER TABLE prefix_chat DROP INDEX `course`;',false);
+        execute_sql('ALTER TABLE prefix_chat_messages DROP INDEX  `chatid`;',false);
+        execute_sql('ALTER TABLE prefix_chat_messages DROP INDEX `userid`;',false); 
+        execute_sql('ALTER TABLE prefix_chat_messages DROP INDEX `groupid`;',false);
+        execute_sql('ALTER TABLE prefix_chat_users DROP INDEX  `chatid`;',false); 
+        execute_sql('ALTER TABLE prefix_chat_users DROP INDEX  `groupid`;',false);
+
+        modify_database('','ALTER TABLE prefix_chat ADD INDEX `course` (`course`);');
+        modify_database('','ALTER TABLE prefix_chat_messages ADD INDEX  `chatid` (`chatid`);');
+        modify_database('','ALTER TABLE prefix_chat_messages ADD INDEX `userid` (`userid`);');
+        modify_database('','ALTER TABLE prefix_chat_messages ADD INDEX `groupid` (`groupid`);');
+        modify_database('','ALTER TABLE prefix_chat_users ADD INDEX  `chatid` (`chatid`);');
+        modify_database('','ALTER TABLE prefix_chat_users ADD INDEX  `groupid` (`groupid`);');
+    }
+
     return true;
 }
 
index 6efe107078d4f9d2de5f8d6569272f31d85a3a62..68365a8dd808198a5c71537aac54dfdb93df39cd 100644 (file)
@@ -12,7 +12,8 @@ CREATE TABLE `prefix_chat` (
   `chattime` int(10) unsigned NOT NULL default '0',
   `schedule` int(4) NOT NULL default '0',
   `timemodified` int(10) unsigned NOT NULL default '0',
-  PRIMARY KEY  (`id`)
+  PRIMARY KEY  (`id`),
+  KEY `course` (`course`)
 ) TYPE=MyISAM COMMENT='Each of these is a chat room';
 # --------------------------------------------------------
 
@@ -29,7 +30,10 @@ CREATE TABLE `prefix_chat_messages` (
   `message` text NOT NULL,
   `timestamp` int(10) unsigned NOT NULL default '0',
   PRIMARY KEY  (`id`),
-  KEY `timemodifiedchat` (`timestamp`,`chatid`)
+  KEY `timemodifiedchat` (`timestamp`,`chatid`),
+  KEY `chatid` (`chatid`),
+  KEY `userid` (`userid`),
+  KEY `groupid` (`groupid`)
 ) TYPE=MyISAM COMMENT='Stores all the actual chat messages';
 # --------------------------------------------------------
 
@@ -50,7 +54,9 @@ CREATE TABLE `prefix_chat_users` (
   `sid` varchar(32) NOT NULL default '',
   PRIMARY KEY  (`id`),
   KEY `userid` (`userid`),
-  KEY `lastping` (`lastping`)
+  KEY `lastping` (`lastping`),
+  KEY `chatid` (`chatid`),
+  KEY `groupid` (`groupid`)
 ) TYPE=MyISAM COMMENT='Keeps track of which users are in which chat rooms';
 
 
index 311f95fe62bf0cbf77c1499ef49d57ac27f14152..a726b9b04d9f58dd259e3eb6a9a7ff1bf1437e05 100644 (file)
@@ -20,6 +20,28 @@ function chat_upgrade($oldversion) {
         modify_database("", "INSERT INTO prefix_log_display VALUES ('chat', 'talk', 'chat', 'name');");
     }
 
+    if ($oldversion < 2004111200) { //drop them first to avoid collisions with upgrades from 1.4.2+
+        execute_sql('DROP INDEX prefix_chat_course_idx;',false);
+        execute_sql('DROP INDEX prefix_chat_messages_chatid_idx;',false); 
+        execute_sql('DROP INDEX prefix_chat_messages_userid_idx;',false); 
+        execute_sql('DROP INDEX prefix_chat_messages_groupid_idx;',false);
+        execute_sql('DROP INDEX prefix_chat_messages_timemodifiedchatid_idx;',false); 
+        execute_sql('DROP INDEX prefix_chat_users_chatid_idx;',false); 
+        execute_sql('DROP INDEX prefix_chat_users_userid_idx;',false); 
+        execute_sql('DROP INDEX prefix_chat_users_groupid_idx;',false); 
+        execute_sql('DROP INDEX prefix_chat_users_lastping_idx;',false);
+
+        modify_database('','CREATE INDEX prefix_chat_course_idx ON prefix_chat(course);');
+        modify_database('','CREATE INDEX prefix_chat_messages_chatid_idx ON prefix_chat_messages (chatid);');
+        modify_database('','CREATE INDEX prefix_chat_messages_userid_idx ON prefix_chat_messages (userid);');
+        modify_database('','CREATE INDEX prefix_chat_messages_groupid_idx ON prefix_chat_messages (groupid);');
+        modify_database('','CREATE INDEX prefix_chat_messages_timemodifiedchatid_idx ON prefix_chat_messages(timestamp,chatid);');
+        modify_database('','CREATE INDEX prefix_chat_users_chatid_idx ON prefix_chat_users (chatid);');
+        modify_database('','CREATE INDEX prefix_chat_users_userid_idx ON prefix_chat_users (userid);');
+        modify_database('','CREATE INDEX prefix_chat_users_groupid_idx ON prefix_chat_users (groupid);');
+        modify_database('','CREATE INDEX prefix_chat_users_lastping_idx ON prefix_chat_users (lastping);');
+    }
+
     return true;
 }
 
index b77d1187f1d5dc2d4f82dcf112a299b9e32c802e..c1928e4af9751aab1a8a19afc81ce6784bb8d3db 100644 (file)
@@ -14,6 +14,9 @@ CREATE TABLE prefix_chat (
   timemodified INTEGER NOT NULL default '0',
   PRIMARY KEY  (id)
 );
+
+CREATE INDEX prefix_chat_course_idx ON prefix_chat(course);
+
 # --------------------------------------------------------
 
 #
@@ -30,6 +33,12 @@ CREATE TABLE prefix_chat_messages (
   timestamp integer NOT NULL default '0',
   PRIMARY KEY  (id)
 );
+
+CREATE INDEX prefix_chat_messages_chatid_idx ON prefix_chat_messages (chatid);
+CREATE INDEX prefix_chat_messages_userid_idx ON prefix_chat_messages (userid);
+CREATE INDEX prefix_chat_messages_groupid_idx ON prefix_chat_messages (groupid);
+CREATE INDEX prefix_chat_messages_timemodifiedchatid_idx ON prefix_chat_messages(timestamp,chatid);
+
 # --------------------------------------------------------
 
 #
@@ -50,6 +59,10 @@ CREATE TABLE prefix_chat_users (
   PRIMARY KEY  (id)
 );
 
+CREATE INDEX prefix_chat_users_chatid_idx ON prefix_chat_users (chatid);
+CREATE INDEX prefix_chat_users_userid_idx ON prefix_chat_users (userid);
+CREATE INDEX prefix_chat_users_groupid_idx ON prefix_chat_users (groupid);
+CREATE INDEX prefix_chat_users_lastping_idx ON prefix_chat_users (lastping);
 
 INSERT INTO prefix_log_display VALUES ('chat', 'view', 'chat', 'name');
 INSERT INTO prefix_log_display VALUES ('chat', 'add', 'chat', 'name');
index f3bc17e9549afc09db324202b404afe777c02a42..923d476740defb370b176d06763330d83960d050 100644 (file)
@@ -5,7 +5,7 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004060400;   // The (date) version of this module
+$module->version  = 2004121100;   // The (date) version of this module
 $module->requires = 2004052505;  // Requires this Moodle version
 $module->cron     = 300;          // How often should cron check this module (seconds)?