forked from WoltLab/com.woltlab.wcf.conversation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sql
86 lines (73 loc) · 3.44 KB
/
install.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
DROP TABLE IF EXISTS wcf1_conversation;
CREATE TABLE wcf1_conversation (
conversationID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
subject VARCHAR(255) NOT NULL DEFAULT '',
time INT(10) NOT NULL DEFAULT 0,
firstMessageID INT(10),
userID INT(10),
username VARCHAR(255) NOT NULL DEFAULT '',
lastPostTime INT(10) NOT NULL DEFAULT 0,
lastPosterID INT(10),
lastPoster VARCHAR(255) NOT NULL DEFAULT '',
replies MEDIUMINT(7) NOT NULL DEFAULT 0,
attachments SMALLINT(5) NOT NULL DEFAULT 0,
participants MEDIUMINT(7) NOT NULL DEFAULT 0,
participantSummary TEXT,
participantCanInvite TINYINT(1) NOT NULL DEFAULT 0,
isClosed TINYINT(1) NOT NULL DEFAULT 0,
isDraft TINYINT(1) NOT NULL DEFAULT 0,
draftData MEDIUMTEXT,
KEY (userID, isDraft)
);
DROP TABLE IF EXISTS wcf1_conversation_to_user;
CREATE TABLE wcf1_conversation_to_user (
conversationID INT(10) NOT NULL,
participantID INT(10),
username VARCHAR(255) NOT NULL DEFAULT '',
hideConversation TINYINT(1) NOT NULL DEFAULT 0,
isInvisible TINYINT(1) NOT NULL DEFAULT 0,
lastVisitTime INT(10) NOT NULL DEFAULT 0,
UNIQUE KEY (participantID, conversationID),
KEY (participantID, hideConversation)
);
DROP TABLE IF EXISTS wcf1_conversation_message;
CREATE TABLE wcf1_conversation_message (
messageID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
conversationID INT(10) NOT NULL,
userID INT(10),
username VARCHAR(255) NOT NULL DEFAULT '',
message MEDIUMTEXT NOT NULL,
time INT(10) NOT NULL DEFAULT 0,
attachments SMALLINT(5) NOT NULL DEFAULT 0,
enableSmilies TINYINT(1) NOT NULL DEFAULT 1,
enableHtml TINYINT(1) NOT NULL DEFAULT 0,
enableBBCodes TINYINT(1) NOT NULL DEFAULT 1,
showSignature TINYINT(1) NOT NULL DEFAULT 1,
ipAddress VARCHAR(39) NOT NULL DEFAULT '',
KEY (conversationID, userID),
KEY (ipAddress)
);
-- labels
DROP TABLE IF EXISTS wcf1_conversation_label;
CREATE TABLE wcf1_conversation_label (
labelID INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
userID INT(10) NOT NULL,
label VARCHAR(80) NOT NULL DEFAULT '',
cssClassName VARCHAR(255) NOT NULL DEFAULT ''
);
DROP TABLE IF EXISTS wcf1_conversation_label_to_object;
CREATE TABLE wcf1_conversation_label_to_object (
labelID INT(10) NOT NULL,
conversationID INT(10) NOT NULL,
UNIQUE KEY (labelID, conversationID)
);
ALTER TABLE wcf1_conversation ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
ALTER TABLE wcf1_conversation ADD FOREIGN KEY (lastPosterID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
ALTER TABLE wcf1_conversation ADD FOREIGN KEY (firstMessageID) REFERENCES wcf1_conversation_message (messageID) ON DELETE SET NULL;
ALTER TABLE wcf1_conversation_to_user ADD FOREIGN KEY (conversationID) REFERENCES wcf1_conversation (conversationID) ON DELETE CASCADE;
ALTER TABLE wcf1_conversation_to_user ADD FOREIGN KEY (participantID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
ALTER TABLE wcf1_conversation_message ADD FOREIGN KEY (conversationID) REFERENCES wcf1_conversation (conversationID) ON DELETE CASCADE;
ALTER TABLE wcf1_conversation_message ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE SET NULL;
ALTER TABLE wcf1_conversation_label ADD FOREIGN KEY (userID) REFERENCES wcf1_user (userID) ON DELETE CASCADE;
ALTER TABLE wcf1_conversation_label_to_object ADD FOREIGN KEY (labelID) REFERENCES wcf1_conversation_label (labelID) ON DELETE CASCADE;
ALTER TABLE wcf1_conversation_label_to_object ADD FOREIGN KEY (conversationID) REFERENCES wcf1_conversation (conversationID) ON DELETE CASCADE;