diff --git a/install.sql b/install.sql index 604efe1..26f040f 100644 --- a/install.sql +++ b/install.sql @@ -1,11 +1,11 @@ ----- +-- -- -- Database Structure for Tims Chat -- -- @author Tim Düsterhus -- @copyright 2010-2012 Tim Düsterhus -- @license Creative Commons Attribution-NonCommercial-ShareAlike -- @package be.bastelstu.wcf.chat ----- +-- -- DROP TABLE IF EXISTS wcf1_chat_message; CREATE TABLE wcf1_chat_message ( @@ -40,16 +40,17 @@ CREATE TABLE wcf1_chat_room ( KEY owner (owner) ); -DROP TABLE IF EXISTS wcf1_chat_room_suspension; -CREATE TABLE wcf1_chat_room_suspension ( - userID INT(10) NOT NULL, - roomID INT(10) DEFAULT NULL, - type TINYINT(3) NOT NULL, - time INT(10) NOT NULL, +DROP TABLE IF EXISTS wcf1_chat_suspension; +CREATE TABLE wcf1_chat_suspension ( + 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, - UNIQUE KEY main (userID, roomID), + UNIQUE KEY suspension (userID, roomID, type), KEY roomID (roomID), - KEY type (type, time), + KEY type (type), KEY time (time) ); @@ -59,8 +60,8 @@ ALTER TABLE wcf1_chat_message ADD FOREIGN KEY (sender) REFERENCES wcf1_user (use 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; +ALTER TABLE wcf1_chat_suspension ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE; +ALTER TABLE wcf1_chat_suspension ADD FOREIGN KEY (roomID) REFERENCES wcf1_chat_room (roomID) ON DELETE CASCADE; INSERT INTO wcf1_chat_room (title, topic, position) VALUES ('wcf.chat.room.title1', 'wcf.chat.room.topic1', 1); INSERT INTO wcf1_chat_room (title, topic, position) VALUES ('Testroom 2', 'Topic of Testroom 2', 2);