Skip to content
Browse files

Indexes for chat and version bump

  • Loading branch information...
1 parent eca6441 commit 7bf8395be7b670390f9e8a083b8fc21914fc1030 mjollnir_ committed Nov 17, 2004
Showing with 44 additions and 4 deletions.
  1. +9 −0 mod/chat/db/mysql.php
  2. +9 −3 mod/chat/db/mysql.sql
  3. +12 −0 mod/chat/db/postgres7.php
  4. +13 −0 mod/chat/db/postgres7.sql
  5. +1 −1 mod/chat/version.php
View
9 mod/chat/db/mysql.php
@@ -37,6 +37,15 @@ function chat_upgrade($oldversion) {
modify_database("", "INSERT INTO prefix_log_display VALUES ('chat', 'talk', 'chat', 'name');");
}
+ if ($oldversion < 2004111200) {
+ 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;
}
View
12 mod/chat/db/mysql.sql
@@ -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';
View
12 mod/chat/db/postgres7.php
@@ -20,6 +20,18 @@ function chat_upgrade($oldversion) {
modify_database("", "INSERT INTO prefix_log_display VALUES ('chat', 'talk', 'chat', 'name');");
}
+ if ($oldversion < 2004111200) {
+ 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;
}
View
13 mod/chat/db/postgres7.sql
@@ -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');
View
2 mod/chat/version.php
@@ -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)?

0 comments on commit 7bf8395

Please sign in to comment.
Something went wrong with that request. Please try again.