2012-05-19 18:07:35 +00:00
|
|
|
-- --
|
2012-03-12 16:18:15 +00:00
|
|
|
-- Database Structure for Tims Chat
|
|
|
|
--
|
|
|
|
-- @author Tim Düsterhus
|
2013-01-19 19:36:40 +00:00
|
|
|
-- @copyright 2010-2013 Tim Düsterhus
|
2012-03-12 16:18:15 +00:00
|
|
|
-- @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
2013-01-19 19:36:40 +00:00
|
|
|
-- @package be.bastelstu.chat
|
2012-05-19 18:07:35 +00:00
|
|
|
-- --
|
2012-03-12 16:18:15 +00:00
|
|
|
|
2013-01-19 19:36:40 +00:00
|
|
|
DROP TABLE IF EXISTS chat1_message;
|
|
|
|
CREATE TABLE chat1_message (
|
2012-03-04 17:45:17 +00:00
|
|
|
messageID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
roomID INT(10) NOT NULL,
|
|
|
|
sender INT(10) DEFAULT NULL,
|
|
|
|
username VARCHAR(255) DEFAULT NULL,
|
|
|
|
receiver INT(10) DEFAULT NULL,
|
|
|
|
time INT(10) NOT NULL,
|
|
|
|
type TINYINT(3) NOT NULL DEFAULT 1,
|
|
|
|
message MEDIUMTEXT NOT NULL,
|
|
|
|
enableSmilies TINYINT(1) NOT NULL DEFAULT 1,
|
2013-01-09 20:34:30 +00:00
|
|
|
enableBBCodes TINYINT(1) NOT NULL DEFAULT 0,
|
2012-03-04 17:45:17 +00:00
|
|
|
enableHTML TINYINT(1) NOT NULL DEFAULT 0,
|
|
|
|
color1 INT(10) NOT NULL DEFAULT 0,
|
|
|
|
color2 INT(10) NOT NULL DEFAULT 0,
|
|
|
|
|
2012-02-05 18:27:38 +00:00
|
|
|
KEY roomID (roomID),
|
|
|
|
KEY sender (sender),
|
|
|
|
KEY receiver (receiver)
|
2011-11-26 14:12:16 +00:00
|
|
|
);
|
|
|
|
|
2013-01-19 19:36:40 +00:00
|
|
|
DROP TABLE IF EXISTS chat1_room;
|
|
|
|
CREATE TABLE chat1_room (
|
2012-03-04 17:45:17 +00:00
|
|
|
roomID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
title VARCHAR(255) NOT NULL,
|
|
|
|
topic VARCHAR(255) NOT NULL,
|
|
|
|
position INT(10) NOT NULL DEFAULT 0,
|
|
|
|
permanent TINYINT(1) NOT NULL DEFAULT 1,
|
|
|
|
owner INT(10) DEFAULT NULL,
|
|
|
|
|
2012-02-05 18:27:38 +00:00
|
|
|
KEY positionKey (position),
|
|
|
|
KEY owner (owner)
|
2011-11-26 14:12:16 +00:00
|
|
|
);
|
|
|
|
|
2013-01-19 19:36:40 +00:00
|
|
|
DROP TABLE IF EXISTS chat1_suspension;
|
|
|
|
CREATE TABLE chat1_suspension (
|
2012-05-19 18:07:35 +00:00
|
|
|
suspensionID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
userID INT(10) NOT NULL,
|
|
|
|
roomID INT(10) DEFAULT NULL,
|
|
|
|
type TINYINT(3) NOT NULL,
|
|
|
|
time INT(10) NOT NULL,
|
2012-03-04 17:45:17 +00:00
|
|
|
|
2012-05-19 18:07:35 +00:00
|
|
|
UNIQUE KEY suspension (userID, roomID, type),
|
2012-02-05 18:57:39 +00:00
|
|
|
KEY roomID (roomID),
|
2012-05-19 18:07:35 +00:00
|
|
|
KEY type (type),
|
2012-02-05 18:27:38 +00:00
|
|
|
KEY time (time)
|
2011-11-28 20:52:37 +00:00
|
|
|
);
|
2011-11-26 14:12:16 +00:00
|
|
|
|
2013-01-19 19:36:40 +00:00
|
|
|
ALTER TABLE chat1_message ADD FOREIGN KEY (receiver) REFERENCES wcf1_user (userID) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE chat1_message ADD FOREIGN KEY (roomID) REFERENCES chat1_room (roomID) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE chat1_message ADD FOREIGN KEY (sender) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
|
2011-11-26 14:12:16 +00:00
|
|
|
|
2013-01-19 19:36:40 +00:00
|
|
|
ALTER TABLE chat1_room ADD FOREIGN KEY (owner) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
|
2011-11-28 20:52:37 +00:00
|
|
|
|
2013-01-19 19:36:40 +00:00
|
|
|
ALTER TABLE chat1_suspension ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE chat1_suspension ADD FOREIGN KEY (roomID) REFERENCES chat1_room (roomID) ON DELETE CASCADE;
|
2012-01-14 11:09:07 +00:00
|
|
|
|
2013-01-28 21:28:22 +00:00
|
|
|
INSERT INTO chat1_room (title, topic, position) VALUES ('chat.room.title1', 'chat.room.topic1', 1);
|
2013-01-19 19:36:40 +00:00
|
|
|
INSERT INTO chat1_room (title, topic, position) VALUES ('Testroom 2', 'Topic of Testroom 2', 2);
|
|
|
|
INSERT INTO chat1_room (title, topic, position) VALUES ('Testroom with a very long', 'The topic of this room is rather loing as well!', 3);
|
|
|
|
INSERT INTO chat1_room (title, topic, position) VALUES ('Room w/o topic', '', 4);
|