2012-05-19 20:07:35 +02:00
|
|
|
-- --
|
2012-03-12 17:18:15 +01:00
|
|
|
-- Database Structure for Tims Chat
|
|
|
|
--
|
|
|
|
-- @author Tim Düsterhus
|
2014-02-27 23:05:09 +01:00
|
|
|
-- @copyright 2010-2014 Tim Düsterhus
|
2012-03-12 17:18:15 +01:00
|
|
|
-- @license Creative Commons Attribution-NonCommercial-ShareAlike <http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode>
|
2013-01-19 20:36:40 +01:00
|
|
|
-- @package be.bastelstu.chat
|
2012-05-19 20:07:35 +02:00
|
|
|
-- --
|
2012-03-12 17:18:15 +01:00
|
|
|
|
2013-01-19 20:36:40 +01:00
|
|
|
DROP TABLE IF EXISTS chat1_message;
|
|
|
|
CREATE TABLE chat1_message (
|
2012-03-04 18:45:17 +01: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,
|
2013-08-02 18:22:42 +02:00
|
|
|
type TINYINT(3) NOT NULL DEFAULT 0,
|
2012-03-04 18:45:17 +01:00
|
|
|
message MEDIUMTEXT NOT NULL,
|
|
|
|
enableSmilies TINYINT(1) NOT NULL DEFAULT 1,
|
|
|
|
enableHTML TINYINT(1) NOT NULL DEFAULT 0,
|
2014-08-12 20:43:35 +02:00
|
|
|
color1 INT(10) DEFAULT NULL,
|
|
|
|
color2 INT(10) DEFAULT NULL,
|
2013-05-28 23:39:19 +02:00
|
|
|
additionalData TEXT DEFAULT NULL,
|
2013-10-16 15:40:29 +02:00
|
|
|
attachmentID INT(10) DEFAULT NULL,
|
2012-03-04 18:45:17 +01:00
|
|
|
|
2013-05-24 01:21:46 +02:00
|
|
|
KEY (roomID),
|
|
|
|
KEY (sender),
|
2013-10-16 15:40:29 +02:00
|
|
|
KEY (receiver),
|
|
|
|
KEY (attachmentID)
|
2011-11-26 15:12:16 +01:00
|
|
|
);
|
|
|
|
|
2013-01-19 20:36:40 +01:00
|
|
|
DROP TABLE IF EXISTS chat1_room;
|
|
|
|
CREATE TABLE chat1_room (
|
2012-03-04 18:45:17 +01:00
|
|
|
roomID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
title VARCHAR(255) NOT NULL,
|
2013-05-24 01:21:46 +02:00
|
|
|
topic VARCHAR(255) NOT NULL DEFAULT '',
|
2013-05-24 00:08:33 +02:00
|
|
|
showOrder INT(10) NOT NULL DEFAULT 0,
|
2012-03-04 18:45:17 +01:00
|
|
|
permanent TINYINT(1) NOT NULL DEFAULT 1,
|
|
|
|
owner INT(10) DEFAULT NULL,
|
2015-01-10 00:42:32 +01:00
|
|
|
maxUsers INT(10) NOT NULL DEFAULT 0
|
2012-03-04 18:45:17 +01:00
|
|
|
|
2013-05-24 01:21:46 +02:00
|
|
|
KEY (showOrder),
|
|
|
|
KEY (owner)
|
2011-11-26 15:12:16 +01:00
|
|
|
);
|
|
|
|
|
2013-01-19 20:36:40 +01:00
|
|
|
DROP TABLE IF EXISTS chat1_suspension;
|
|
|
|
CREATE TABLE chat1_suspension (
|
2012-05-19 20:07:35 +02:00
|
|
|
suspensionID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
userID INT(10) NOT NULL,
|
|
|
|
roomID INT(10) DEFAULT NULL,
|
2013-06-22 17:40:24 +02:00
|
|
|
type VARCHAR(15) NOT NULL,
|
2013-05-24 01:21:46 +02:00
|
|
|
expires INT(10) NOT NULL,
|
2013-06-08 16:28:40 +02:00
|
|
|
time INT(10) NOT NULL,
|
|
|
|
issuer INT(10) DEFAULT NULL,
|
2013-06-22 02:19:52 +02:00
|
|
|
reason VARCHAR(255) NOT NULL DEFAULT '',
|
2013-06-22 14:40:54 +02:00
|
|
|
revoker INT(10) DEFAULT NULL,
|
2012-03-04 18:45:17 +01:00
|
|
|
|
2013-06-22 14:40:54 +02:00
|
|
|
KEY suspension (userID, roomID, type),
|
2013-05-24 01:21:46 +02:00
|
|
|
KEY (roomID),
|
|
|
|
KEY (type),
|
2013-05-24 01:40:56 +02:00
|
|
|
KEY (expires)
|
2011-11-28 21:52:37 +01:00
|
|
|
);
|
2011-11-26 15:12:16 +01:00
|
|
|
|
2013-05-24 17:30:27 +02:00
|
|
|
ALTER TABLE wcf1_user ADD COLUMN chatRoomID INT(10) DEFAULT NULL;
|
2014-08-12 20:43:35 +02:00
|
|
|
ALTER TABLE wcf1_user ADD COLUMN chatColor1 INT(10) DEFAULT NULL;
|
|
|
|
ALTER TABLE wcf1_user ADD COLUMN chatColor2 INT(10) DEFAULT NULL;
|
2013-05-24 17:30:27 +02:00
|
|
|
ALTER TABLE wcf1_user ADD COLUMN chatLastActivity INT(10) NOT NULL DEFAULT 0;
|
|
|
|
ALTER TABLE wcf1_user ADD COLUMN chatAway TEXT DEFAULT NULL;
|
|
|
|
ALTER TABLE wcf1_user ADD COLUMN chatLastSeen INT(10) NOT NULL DEFAULT 0;
|
|
|
|
|
2013-01-19 20:36:40 +01: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;
|
2013-10-16 15:40:29 +02:00
|
|
|
ALTER TABLE chat1_message ADD FOREIGN KEY (attachmentID) REFERENCES wcf1_attachment (attachmentID) ON DELETE CASCADE;
|
2011-11-26 15:12:16 +01:00
|
|
|
|
2013-01-19 20:36:40 +01:00
|
|
|
ALTER TABLE chat1_room ADD FOREIGN KEY (owner) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
|
2011-11-28 21:52:37 +01:00
|
|
|
|
2013-01-19 20:36:40 +01: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;
|
2013-06-08 16:28:40 +02:00
|
|
|
ALTER TABLE chat1_suspension ADD FOREIGN KEY (issuer) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
|
2013-06-22 14:40:54 +02:00
|
|
|
ALTER TABLE chat1_suspension ADD FOREIGN KEY (revoker) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
|
2012-01-14 12:09:07 +01:00
|
|
|
|
2013-05-24 17:30:27 +02:00
|
|
|
ALTER TABLE wcf1_user ADD FOREIGN KEY (chatRoomID) REFERENCES chat1_room (roomID) ON DELETE SET NULL;
|
|
|
|
|
2013-05-24 00:08:33 +02:00
|
|
|
INSERT INTO chat1_room (title, topic, showOrder) VALUES ('chat.room.title1', 'chat.room.topic1', 1);
|