2 #Each row represents a registered user, with privileges or without
3 id INT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,#Internal ID
4 email VARCHAR(255) <<CHARSET>> UNIQUE NOT NULL,#His email for notifications
5 xmpp TEXT <<CHARSET>>,#His XMPP address for notifications
6 login VARCHAR(50) <<CHARSET>> UNIQUE,#Login name
7 passwd VARCHAR(22) <<CHARSET>> NOT NULL,#Password hash
8 lastlog TEXT <<CHARSET>>,#Where did he logged in last time?
9 logtime TIMESTAMP,#When did he log in last time?
10 mailgather INT UNSIGNED NOT NULL DEFAULT 240,#How long to gather mail notifications before sending?
11 xmppgather INT UNSIGNED NOT NULL DEFAULT 15,#How long to gather xmpp notifications before sending?
12 nextmail TIMESTAMP,#When do we send pending email notifications next time?
13 nextxmpp TIMESTAMP#When do we send pending xmpp notifications?
16 #The locations are saved in a tree. ID of the location is created by
17 #appending the local IDs of the nodes on the path together (children of
18 #the root first), separated by '/'. Each node must know, how long are
19 #the local IDs of its children.
21 #(Note that the local IDs can contain '/', since it can be recognized
24 #The first part is 2-letter specifier of information type. The first
29 id VARCHAR(50) <<CHARSET>> NOT NULL UNIQUE PRIMARY KEY,#The name of the location, must be just node, no / at the end
30 parent VARCHAR(50) <<CHARSET>>,#To allow selecting of all node's children
31 maincomment INT UNSIGNED,#Reference for the main comment
32 name TINYTEXT <<CHARSET>>,#Should match the one of main comment, if any (if no main comment, name can be set too)
33 description TEXT <<CHARSET>>,#Should match the one of main comment (if no main comment, can be set too)
34 CONSTRAINT parent_ref FOREIGN KEY (parent) REFERENCES locations(id) ON DELETE CASCADE
37 #Which privileges the users have?
38 #It contains only the users with some extra privileges, not the normal ones
39 userId INT UNSIGNED NOT NULL,#Who has the privilege
40 rightId INT UNSIGNED NOT NULL,#What privilege
41 CONSTRAINT right_user FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE,
42 PRIMARY KEY (userId, rightId)
45 #Contains the comments in the discussion
46 id INT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE PRIMARY KEY,
47 owner INT UNSIGNED,#Who posted it?
48 location VARCHAR(50) <<CHARSET>> NOT NULL,#Where it belongs
49 text TEXT <<CHARSET>>,
50 time TIMESTAMP NOT NULL DEFAULT NOW(),#When this was added
51 nodename TINYTEXT <<CHARSET>>,#Modification of the location name
52 nodedescription TEXT <<CHARSET>>,#Modification of the location comment
53 seen BOOLEAN NOT NULL DEFAULT '0', #Did some admin see this, or is it still unseen?
54 CONSTRAINT history_location FOREIGN KEY (location) REFERENCES locations(id) ON DELETE CASCADE,
55 CONSTRAINT history_owner FOREIGN KEY (owner) REFERENCES users(id) ON DELETE SET NULL
58 #Contains hooks for notifications
59 user INT UNSIGNED NOT NULL,#Who wants it
60 location VARCHAR(50) <<CHARSET>> NOT NULL,#Where
61 recursive BOOLEAN NOT NULL DEFAULT '0',
62 type SMALLINT NOT NULL,#When to send
63 #0: Comment -- When a new comment is posted
64 #1: Description -- Name or comment changed
65 #2: MainComment -- The main comment changed
66 #All contains the less common events
67 notification SMALLINT NOT NULL,
71 CONSTRAINT notification_location FOREIGN KEY (location) REFERENCES locations(id) ON DELETE CASCADE,
72 CONSTRAINT notification_user FOREIGN KEY (user) REFERENCES users(id) ON DELETE CASCADE,
73 PRIMARY KEY (user, location)
76 #Contains the pending notifications
77 user INT UNSIGNED NOT NULL,
78 comment INT UNSIGNED NOT NULL,
79 notification SMALLINT NOT NULL,
82 #If a notification generates both, it splits to 2 of them
83 reason SMALLINT NOT NULL,
86 #2: Changed main article
87 CONSTRAINT pending_comment FOREIGN KEY (comment) REFERENCES history(id) ON DELETE CASCADE,
88 CONSTRAINT pending_user FOREIGN KEY (user) REFERENCES users(id) ON DELETE CASCADE