1 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
2 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
3 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
5 CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
8 -- -----------------------------------------------------
9 -- Table `mydb`.`ticket_category`
10 -- -----------------------------------------------------
11 DROP TABLE IF EXISTS `mydb`.`ticket_category` ;
13 CREATE TABLE IF NOT EXISTS `mydb`.`ticket_category` (
14 `TCategoryId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
15 `Name` VARCHAR(45) NOT NULL ,
16 PRIMARY KEY (`TCategoryId`) ,
17 UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) )
21 -- -----------------------------------------------------
22 -- Table `mydb`.`ticket_user`
23 -- -----------------------------------------------------
24 DROP TABLE IF EXISTS `mydb`.`ticket_user` ;
26 CREATE TABLE IF NOT EXISTS `mydb`.`ticket_user` (
27 `TUserId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
28 `Permission` INT(3) NOT NULL DEFAULT 1 ,
29 `ExternId` INT(10) UNSIGNED NOT NULL ,
30 PRIMARY KEY (`TUserId`) )
34 -- -----------------------------------------------------
35 -- Table `mydb`.`ticket`
36 -- -----------------------------------------------------
37 DROP TABLE IF EXISTS `mydb`.`ticket` ;
39 CREATE TABLE IF NOT EXISTS `mydb`.`ticket` (
40 `TId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
41 `Timestamp` TIMESTAMP NOT NULL ,
42 `Title` VARCHAR(120) NOT NULL ,
43 `Status` INT NULL DEFAULT 0 ,
44 `Queue` INT NULL DEFAULT 0 ,
45 `Ticket_Category` INT UNSIGNED NOT NULL ,
46 `Author` INT UNSIGNED NOT NULL ,
47 `Priority` INT(3) NULL DEFAULT 0 ,
49 INDEX `fk_ticket_ticket_category_idx` (`Ticket_Category` ASC) ,
50 INDEX `fk_ticket_ams_user_idx` (`Author` ASC) ,
51 CONSTRAINT `fk_ticket_ticket_category`
52 FOREIGN KEY (`Ticket_Category` )
53 REFERENCES `mydb`.`ticket_category` (`TCategoryId` )
56 CONSTRAINT `fk_ticket_ams_user`
57 FOREIGN KEY (`Author` )
58 REFERENCES `mydb`.`ticket_user` (`TUserId` )
64 -- -----------------------------------------------------
65 -- Table `mydb`.`assigned`
66 -- -----------------------------------------------------
67 DROP TABLE IF EXISTS `mydb`.`assigned` ;
69 CREATE TABLE IF NOT EXISTS `mydb`.`assigned` (
70 `Ticket` INT UNSIGNED NOT NULL ,
71 `User` INT UNSIGNED NOT NULL ,
72 INDEX `fk_assigned_ticket_idx` (`Ticket` ASC) ,
73 PRIMARY KEY (`Ticket`, `User`) ,
74 INDEX `fk_assigned_ams_user_idx` (`User` ASC) ,
75 CONSTRAINT `fk_assigned_ticket`
76 FOREIGN KEY (`Ticket` )
77 REFERENCES `mydb`.`ticket` (`TId` )
80 CONSTRAINT `fk_assigned_ams_user`
82 REFERENCES `mydb`.`ticket_user` (`TUserId` )
88 -- -----------------------------------------------------
90 -- -----------------------------------------------------
91 DROP TABLE IF EXISTS `mydb`.`tag` ;
93 CREATE TABLE IF NOT EXISTS `mydb`.`tag` (
94 `TagId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
95 `Value` VARCHAR(60) NOT NULL ,
96 PRIMARY KEY (`TagId`) ,
97 UNIQUE INDEX `Value_UNIQUE` (`Value` ASC) )
101 -- -----------------------------------------------------
102 -- Table `mydb`.`tagged`
103 -- -----------------------------------------------------
104 DROP TABLE IF EXISTS `mydb`.`tagged` ;
106 CREATE TABLE IF NOT EXISTS `mydb`.`tagged` (
107 `Ticket` INT UNSIGNED NOT NULL ,
108 `Tag` INT UNSIGNED NOT NULL ,
109 PRIMARY KEY (`Ticket`, `Tag`) ,
110 INDEX `fk_tagged_tag_idx` (`Tag` ASC) ,
111 CONSTRAINT `fk_tagged_ticket`
112 FOREIGN KEY (`Ticket` )
113 REFERENCES `mydb`.`ticket` (`TId` )
116 CONSTRAINT `fk_tagged_tag`
118 REFERENCES `mydb`.`tag` (`TagId` )
124 -- -----------------------------------------------------
125 -- Table `mydb`.`ticket_content`
126 -- -----------------------------------------------------
127 DROP TABLE IF EXISTS `mydb`.`ticket_content` ;
129 CREATE TABLE IF NOT EXISTS `mydb`.`ticket_content` (
130 `TContentId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
131 `Content` TEXT NULL ,
132 PRIMARY KEY (`TContentId`) )
134 DEFAULT CHARACTER SET = utf8;
137 -- -----------------------------------------------------
138 -- Table `mydb`.`ticket_reply`
139 -- -----------------------------------------------------
140 DROP TABLE IF EXISTS `mydb`.`ticket_reply` ;
142 CREATE TABLE IF NOT EXISTS `mydb`.`ticket_reply` (
143 `TReplyId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
144 `Ticket` INT UNSIGNED NOT NULL ,
145 `Author` INT UNSIGNED NOT NULL ,
146 `Content` INT UNSIGNED NOT NULL ,
147 `Timestamp` TIMESTAMP NULL ,
148 `Hidden` TINYINT(1) NULL DEFAULT 0 ,
149 PRIMARY KEY (`TReplyId`) ,
150 INDEX `fk_ticket_reply_ticket_idx` (`Ticket` ASC) ,
151 INDEX `fk_ticket_reply_ams_user_idx` (`Author` ASC) ,
152 INDEX `fk_ticket_reply_content_idx` (`Content` ASC) ,
153 CONSTRAINT `fk_ticket_reply_ticket`
154 FOREIGN KEY (`Ticket` )
155 REFERENCES `mydb`.`ticket` (`TId` )
158 CONSTRAINT `fk_ticket_reply_ams_user`
159 FOREIGN KEY (`Author` )
160 REFERENCES `mydb`.`ticket_user` (`TUserId` )
163 CONSTRAINT `fk_ticket_reply_ticket_content`
164 FOREIGN KEY (`Content` )
165 REFERENCES `mydb`.`ticket_content` (`TContentId` )
171 -- -----------------------------------------------------
172 -- Table `mydb`.`ticket_group`
173 -- -----------------------------------------------------
174 DROP TABLE IF EXISTS `mydb`.`ticket_group` ;
176 CREATE TABLE IF NOT EXISTS `mydb`.`ticket_group` (
177 `TGroupId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
178 `Title` VARCHAR(80) NOT NULL ,
179 PRIMARY KEY (`TGroupId`) ,
180 UNIQUE INDEX `Title_UNIQUE` (`Title` ASC) )
184 -- -----------------------------------------------------
185 -- Table `mydb`.`in_group`
186 -- -----------------------------------------------------
187 DROP TABLE IF EXISTS `mydb`.`in_group` ;
189 CREATE TABLE IF NOT EXISTS `mydb`.`in_group` (
190 `Ticket_Group` INT UNSIGNED NOT NULL ,
191 `Ticket` INT UNSIGNED NOT NULL ,
192 PRIMARY KEY (`Ticket_Group`, `Ticket`) ,
193 INDEX `fk_in_group_ticket_group_idx` (`Ticket_Group` ASC) ,
194 INDEX `fk_in_group_ticket_idx` (`Ticket` ASC) ,
195 CONSTRAINT `fk_in_group_ticket_group`
196 FOREIGN KEY (`Ticket_Group` )
197 REFERENCES `mydb`.`ticket_group` (`TGroupId` )
200 CONSTRAINT `fk_in_group_ticket`
201 FOREIGN KEY (`Ticket` )
202 REFERENCES `mydb`.`ticket` (`TId` )
208 -- -----------------------------------------------------
209 -- Table `mydb`.`ticket_log`
210 -- -----------------------------------------------------
211 DROP TABLE IF EXISTS `mydb`.`ticket_log` ;
213 CREATE TABLE IF NOT EXISTS `mydb`.`ticket_log` (
214 `TLogId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
215 `Timestamp` TIMESTAMP NOT NULL ,
216 `Query` VARCHAR(255) NOT NULL ,
217 `Ticket` INT UNSIGNED NOT NULL ,
218 `Author` INT(10) UNSIGNED NULL ,
219 PRIMARY KEY (`TLogId`) ,
220 INDEX `fk_ticket_log_ticket1` (`Ticket` ASC) ,
221 INDEX `fk_ticket_log_ticket_user1` (`Author` ASC) ,
222 CONSTRAINT `fk_ticket_log_ticket1`
223 FOREIGN KEY (`Ticket` )
224 REFERENCES `mydb`.`ticket` (`TId` )
227 CONSTRAINT `fk_ticket_log_ticket_user1`
228 FOREIGN KEY (`Author` )
229 REFERENCES `mydb`.`ticket_user` (`TUserId` )
235 -- -----------------------------------------------------
236 -- Table `mydb`.`support_group`
237 -- -----------------------------------------------------
238 DROP TABLE IF EXISTS `mydb`.`support_group` ;
240 CREATE TABLE IF NOT EXISTS `mydb`.`support_group` (
241 `SGroupId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
242 `Name` VARCHAR(22) NOT NULL ,
243 `Tag` VARCHAR(7) NOT NULL ,
244 `GroupEmail` VARCHAR(45) NULL ,
245 `IMAP_MailServer` VARCHAR(60) NULL ,
246 `IMAP_Username` VARCHAR(45) NULL ,
247 `IMAP_Password` VARCHAR(45) NULL ,
248 PRIMARY KEY (`SGroupId`) ,
249 UNIQUE INDEX `Name_UNIQUE` (`Name` ASC) ,
250 UNIQUE INDEX `Tag_UNIQUE` (`Tag` ASC) )
254 -- -----------------------------------------------------
255 -- Table `mydb`.`in_support_group`
256 -- -----------------------------------------------------
257 DROP TABLE IF EXISTS `mydb`.`in_support_group` ;
259 CREATE TABLE IF NOT EXISTS `mydb`.`in_support_group` (
260 `User` INT(10) UNSIGNED NOT NULL ,
261 `Group` INT(10) UNSIGNED NOT NULL ,
262 INDEX `fk_in_support_group_ticket_user1` (`User` ASC) ,
263 INDEX `fk_in_support_group_support_group1` (`Group` ASC) ,
264 CONSTRAINT `fk_in_support_group_ticket_user1`
265 FOREIGN KEY (`User` )
266 REFERENCES `mydb`.`ticket_user` (`TUserId` )
269 CONSTRAINT `fk_in_support_group_support_group1`
270 FOREIGN KEY (`Group` )
271 REFERENCES `mydb`.`support_group` (`SGroupId` )
277 -- -----------------------------------------------------
278 -- Table `mydb`.`forwarded`
279 -- -----------------------------------------------------
280 DROP TABLE IF EXISTS `mydb`.`forwarded` ;
282 CREATE TABLE IF NOT EXISTS `mydb`.`forwarded` (
283 `Group` INT(10) UNSIGNED NOT NULL ,
284 `Ticket` INT UNSIGNED NOT NULL ,
285 INDEX `fk_forwarded_support_group1` (`Group` ASC) ,
286 INDEX `fk_forwarded_ticket1` (`Ticket` ASC) ,
287 CONSTRAINT `fk_forwarded_support_group1`
288 FOREIGN KEY (`Group` )
289 REFERENCES `mydb`.`support_group` (`SGroupId` )
292 CONSTRAINT `fk_forwarded_ticket1`
293 FOREIGN KEY (`Ticket` )
294 REFERENCES `mydb`.`ticket` (`TId` )
300 -- -----------------------------------------------------
301 -- Table `mydb`.`email`
302 -- -----------------------------------------------------
303 DROP TABLE IF EXISTS `mydb`.`email` ;
305 CREATE TABLE IF NOT EXISTS `mydb`.`email` (
306 `MailId` INT NOT NULL AUTO_INCREMENT ,
307 `Recipient` VARCHAR(50) NULL ,
308 `Subject` VARCHAR(60) NULL ,
309 `Body` VARCHAR(400) NULL ,
310 `Status` VARCHAR(45) NULL ,
311 `Attempts` VARCHAR(45) NULL DEFAULT 0 ,
312 `UserId` INT(10) UNSIGNED NULL ,
313 `MessageId` VARCHAR(45) NULL ,
314 `TicketId` INT UNSIGNED NULL ,
315 `Sender` INT(10) UNSIGNED NULL ,
316 PRIMARY KEY (`MailId`) ,
317 INDEX `fk_email_ticket_user2` (`UserId` ASC) ,
318 INDEX `fk_email_ticket1` (`TicketId` ASC) ,
319 INDEX `fk_email_support_group1` (`Sender` ASC) ,
320 CONSTRAINT `fk_email_ticket_user2`
321 FOREIGN KEY (`UserId` )
322 REFERENCES `mydb`.`ticket_user` (`TUserId` )
325 CONSTRAINT `fk_email_ticket1`
326 FOREIGN KEY (`TicketId` )
327 REFERENCES `mydb`.`ticket` (`TId` )
330 CONSTRAINT `fk_email_support_group1`
331 FOREIGN KEY (`Sender` )
332 REFERENCES `mydb`.`support_group` (`SGroupId` )
338 -- -----------------------------------------------------
339 -- Table `mydb`.`ticket_info`
340 -- -----------------------------------------------------
341 DROP TABLE IF EXISTS `mydb`.`ticket_info` ;
343 CREATE TABLE IF NOT EXISTS `mydb`.`ticket_info` (
344 `TInfoId` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
345 `Ticket` INT UNSIGNED NOT NULL ,
347 `UserPosition` VARCHAR(65) NULL ,
348 `ViewPosition` VARCHAR(65) NULL ,
349 `ClientVersion` VARCHAR(65) NULL ,
350 `PatchVersion` VARCHAR(65) NULL ,
351 `ServerTick` VARCHAR(40) NULL ,
352 `ConnectState` VARCHAR(40) NULL ,
353 `LocalAddress` VARCHAR(60) NULL ,
354 `Memory` VARCHAR(60) NULL ,
355 `OS` VARCHAR(120) NULL ,
356 `Processor` VARCHAR(120) NULL ,
357 `CPUID` VARCHAR(50) NULL ,
358 `CpuMask` VARCHAR(50) NULL ,
359 `HT` VARCHAR(65) NULL ,
360 `NeL3D` VARCHAR(120) NULL ,
361 `PlayerName` VARCHAR(45) NULL ,
363 `TimeInGame` VARCHAR(50) NULL ,
364 PRIMARY KEY (`TInfoId`) ,
365 INDEX `fk_ticket_info_ticket1` (`Ticket` ASC) ,
366 CONSTRAINT `fk_ticket_info_ticket1`
367 FOREIGN KEY (`Ticket` )
368 REFERENCES `mydb`.`ticket` (`TId` )
375 SET SQL_MODE=@OLD_SQL_MODE;
376 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
377 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;