2011-11-26 14:12:16 +00:00
|
|
|
DROP TABLE IF EXISTS wcf1_chat_message;
|
|
|
|
CREATE TABLE wcf1_chat_message (
|
|
|
|
messageID int(10) NOT NULL AUTO_INCREMENT,
|
|
|
|
roomID int(10) NOT NULL,
|
|
|
|
sender int(10) DEFAULT NULL,
|
2011-11-27 11:34:02 +00:00
|
|
|
username varchar(255) DEFAULT NULL,
|
|
|
|
receiver int(10) DEFAULT NULL,
|
|
|
|
time int(10) NOT NULL,
|
|
|
|
type tinyint(3) NOT NULL DEFAULT 1,
|
2011-11-26 14:12:16 +00:00
|
|
|
message mediumtext NOT NULL,
|
2011-11-27 11:34:02 +00:00
|
|
|
enableSmilies tinyint(1) NOT NULL DEFAULT 1,
|
|
|
|
enableHTML tinyint(1) NOT NULL DEFAULT 0,
|
|
|
|
color1 int(10) NOT NULL DEFAULT 0,
|
|
|
|
color2 int(10) NOT NULL DEFAULT 0,
|
2011-11-26 14:12:16 +00:00
|
|
|
PRIMARY KEY (messageID),
|
|
|
|
KEY roomID (roomID),
|
|
|
|
KEY sender (sender),
|
|
|
|
KEY receiver (receiver)
|
|
|
|
);
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS wcf1_chat_room;
|
|
|
|
CREATE TABLE wcf1_chat_room (
|
|
|
|
roomID int(10) NOT NULL AUTO_INCREMENT,
|
|
|
|
title varchar(255) NOT NULL,
|
|
|
|
topic varchar(255) NOT NULL,
|
2011-11-28 14:05:15 +00:00
|
|
|
position int(10) NOT NULL DEFAULT 0,
|
|
|
|
permanent tinyint(1) NOT NULL DEFAULT 1,
|
2011-11-27 11:34:02 +00:00
|
|
|
owner int(10) DEFAULT NULL,
|
2011-11-26 14:12:16 +00:00
|
|
|
PRIMARY KEY (roomID),
|
2011-11-27 18:18:36 +00:00
|
|
|
KEY positionKey (position),
|
2011-11-27 11:34:02 +00:00
|
|
|
KEY owner (owner)
|
2011-11-26 14:12:16 +00:00
|
|
|
);
|
|
|
|
|
2011-11-28 20:52:37 +00:00
|
|
|
DROP TABLE IF EXISTS wcf1_chat_room_suspension;
|
2011-11-30 20:43:38 +00:00
|
|
|
CREATE TABLE wcf1_chat_room_suspension (
|
2011-11-28 20:52:37 +00:00
|
|
|
roomID int(10) NOT NULL,
|
|
|
|
userID int(10) NOT NULL,
|
|
|
|
type tinyint(3) NOT NULL,
|
|
|
|
time int(10) NOT NULL,
|
|
|
|
PRIMARY KEY (roomID, userID),
|
|
|
|
KEY userID (userID),
|
|
|
|
KEY type (type, time),
|
|
|
|
KEY time (time)
|
|
|
|
);
|
2011-11-26 14:12:16 +00:00
|
|
|
|
|
|
|
ALTER TABLE wcf1_chat_message ADD FOREIGN KEY (receiver) REFERENCES wcf1_user (userID) ON DELETE CASCADE;
|
2011-11-27 11:34:02 +00:00
|
|
|
ALTER TABLE wcf1_chat_message ADD FOREIGN KEY (roomID) REFERENCES wcf1_chat_room (roomID) ON DELETE CASCADE;
|
2011-11-26 14:12:16 +00:00
|
|
|
ALTER TABLE wcf1_chat_message ADD FOREIGN KEY (sender) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
|
|
|
|
|
2011-11-28 20:52:37 +00:00
|
|
|
ALTER TABLE wcf1_chat_room ADD FOREIGN KEY (owner) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
|
|
|
|
|
|
|
|
ALTER TABLE wcf1_chat_room_suspension ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE wcf1_chat_room_suspension ADD FOREIGN KEY (roomID) REFERENCES wcf1_chat_room (roomID) ON DELETE CASCADE;
|