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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
-- This schema was adopted from the oracle schema by
-- Andre Koppel.
-- Version 0.2 Date 2003.10.21
-- The work is still in progress
CREATE TABLE Attachments (
id SERIAL,
TransactionId INTEGER NOT NULL,
Parent INTEGER DEFAULT 0 NOT NULL,
MessageId VARCHAR(160),
Subject VARCHAR(255),
Filename VARCHAR(255),
ContentType VARCHAR(80),
ContentEncoding VARCHAR(80),
Content BYTE,
Headers BYTE,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE INDEX Attachments1 ON Attachments (Parent);
CREATE INDEX Attachments2 ON Attachments (TransactionId);
CREATE INDEX Attachments3 ON Attachments (Parent, TransactionId);
CREATE TABLE Queues (
id SERIAL,
Name VARCHAR(200) DEFAULT '' NOT NULL,
Description VARCHAR(255) DEFAULT NULL,
CorrespondAddress VARCHAR(120) DEFAULT NULL,
CommentAddress VARCHAR(120) DEFAULT NULL,
InitialPriority INTEGER DEFAULT 0 NOT NULL,
FinalPriority INTEGER DEFAULT 0 NOT NULL,
DefaultDueIn INTEGER DEFAULT 0 NOT NULL,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
Disabled INTEGER DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX Queues1 ON Queues (Name);
CREATE INDEX Queues2 ON Queues (Disabled);
CREATE TABLE Links (
id SERIAL,
Base VARCHAR(240) DEFAULT NULL,
Target VARCHAR(240) DEFAULT NULL,
Type VARCHAR(20) DEFAULT '' NOT NULL,
LocalTarget INTEGER DEFAULT 0 NOT NULL,
LocalBase INTEGER DEFAULT 0 NOT NULL,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
-- CREATE UNIQUE INDEX Links1 ON Links (Base, Target, Type);
CREATE INDEX Links2 ON Links (Base, Type);
CREATE INDEX Links3 ON Links (Target, Type);
CREATE INDEX Links4 ON Links(Type,LocalBase);
CREATE TABLE Principals (
id SERIAL,
PrincipalType VARCHAR(16) DEFAULT '' NOT NULL,
ObjectId INTEGER DEFAULT 0,
Disabled INTEGER DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX Principals2 ON Principals (ObjectId);
CREATE TABLE Groups (
id SERIAL,
Name VARCHAR(200) DEFAULT NULL,
Description VARCHAR(255) DEFAULT NULL,
Domain VARCHAR(64) DEFAULT '',
Type VARCHAR(64) DEFAULT '',
Instance INTEGER DEFAULT 0 NOT NULL,
-- Instance VARCHAR(64) DEFAULT '' NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX Groups1 ON Groups (Domain, Instance, Type, id);
CREATE INDEX Groups2 ON Groups (Type, Instance, Domain);
CREATE TABLE ScripConditions (
id SERIAL,
Name VARCHAR(200),
Description VARCHAR(255),
ExecModule VARCHAR(60),
Argument VARCHAR(255),
ApplicableTransTypes VARCHAR(60),
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE TABLE Transactions (
id SERIAL,
ObjectType VARCHAR(255),
ObjectId INTEGER DEFAULT 0 NOT NULL,
TimeTaken INTEGER DEFAULT 0 NOT NULL,
Type VARCHAR(20),
Field VARCHAR(40),
OldValue VARCHAR(255),
NewValue VARCHAR(255),
ReferenceType VARCHAR(255),
OldReference INTEGER DEFAULT 0,
NewReference INTEGER DEFAULT 0,
Data VARCHAR(255),
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE INDEX Transactions1 ON Transactions (ObjectType, ObjectId);
CREATE TABLE Scrips (
id SERIAL,
Description VARCHAR(255) DEFAULT '',
ScripCondition INTEGER DEFAULT 0 NOT NULL,
ScripAction INTEGER DEFAULT 0 NOT NULL,
ConditionRules BYTE,
ActionRules BYTE,
CustomIsApplicableCode BYTE,
CustomPrepareCode BYTE,
CustomCommitCode BYTE,
Stage VARCHAR(32),
Queue INTEGER DEFAULT 0 NOT NULL,
Template INTEGER DEFAULT 0 NOT NULL,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE TABLE ACL (
id SERIAL,
PrincipalType VARCHAR(25) NOT NULL,
PrincipalId INTEGER NOT NULL,
RightName VARCHAR(25) NOT NULL,
ObjectType VARCHAR(25) NOT NULL,
ObjectId INTEGER DEFAULT 0 NOT NULL,
DelegatedBy INTEGER DEFAULT 0 NOT NULL,
DelegatedFrom INTEGER DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX ACL1 ON ACL(RightName, ObjectType, ObjectId, PrincipalType, PrincipalId);
CREATE TABLE GroupMembers (
id SERIAL,
GroupId INTEGER DEFAULT 0 NOT NULL,
MemberId INTEGER DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX GroupMembers1 ON GroupMembers (GroupId, MemberId);
CREATE TABLE CachedGroupMembers (
id SERIAL,
GroupId INTEGER DEFAULT 0,
MemberId INTEGER DEFAULT 0,
Via INTEGER DEFAULT 0,
ImmediateParentId INTEGER DEFAULT 0,
Disabled INTEGER DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX DisGrouMem ON CachedGroupMembers (GroupId, MemberId, Disabled);
CREATE INDEX GrouMem ON CachedGroupMembers (GroupId, MemberId);
CREATE TABLE Users (
id SERIAL,
Name VARCHAR(200) NOT NULL,
Password VARCHAR(40),
Comments BYTE,
Signature BYTE,
EmailAddress VARCHAR(120),
FreeFormContactInfo BYTE,
Organization VARCHAR(200),
RealName VARCHAR(120),
NickName VARCHAR(16),
Lang VARCHAR(16),
EmailEncoding VARCHAR(16),
WebEncoding VARCHAR(16),
ExternalContactInfoId VARCHAR(100),
ContactInfoSystem VARCHAR(30),
ExternalAuthId VARCHAR(100),
AuthSystem VARCHAR(30),
Gecos VARCHAR(16),
HomePhone VARCHAR(30),
WorkPhone VARCHAR(30),
MobilePhone VARCHAR(30),
PagerPhone VARCHAR(30),
Address1 VARCHAR(200),
Address2 VARCHAR(200),
City VARCHAR(100),
State VARCHAR(100),
Zip VARCHAR(16),
Country VARCHAR(50),
Timezone VARCHAR(50),
PGPKey BYTE,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
-- CREATE UNIQUE INDEX Users1 ON Users (Name);
CREATE INDEX Users2 ON Users (Name);
CREATE INDEX Users3 ON Users (id, EmailAddress);
CREATE INDEX Users4 ON Users (EmailAddress);
CREATE TABLE Tickets (
id SERIAL,
EffectiveId INTEGER DEFAULT 0 NOT NULL,
Queue INTEGER DEFAULT 0 NOT NULL,
Type VARCHAR(16),
IssueStatement INTEGER DEFAULT 0 NOT NULL,
Resolution INTEGER DEFAULT 0 NOT NULL,
Owner INTEGER DEFAULT 0 NOT NULL,
Subject VARCHAR(200) DEFAULT '[no subject]',
InitialPriority INTEGER DEFAULT 0 NOT NULL,
FinalPriority INTEGER DEFAULT 0 NOT NULL,
Priority INTEGER DEFAULT 0 NOT NULL,
TimeEstimated INTEGER DEFAULT 0 NOT NULL,
TimeWorked INTEGER DEFAULT 0 NOT NULL,
Status VARCHAR(10),
TimeLeft INTEGER DEFAULT 0 NOT NULL,
Told DATETIME YEAR TO SECOND,
Starts DATETIME YEAR TO SECOND,
Started DATETIME YEAR TO SECOND,
Due DATETIME YEAR TO SECOND,
Resolved DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
Disabled INTEGER DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
CREATE INDEX Tickets1 ON Tickets (Queue, Status);
CREATE INDEX Tickets2 ON Tickets (Owner);
CREATE INDEX Tickets3 ON Tickets (EffectiveId);
CREATE INDEX Tickets4 ON Tickets (id, Status);
CREATE INDEX Tickets5 ON Tickets (id, EffectiveId);
CREATE INDEX Tickets6 ON Tickets (EffectiveId, Type);
CREATE TABLE ScripActions (
id SERIAL,
Name VARCHAR(200),
Description VARCHAR(255),
ExecModule VARCHAR(60),
Argument VARCHAR(255),
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE TABLE Templates (
id SERIAL,
Queue INTEGER DEFAULT 0 NOT NULL,
Name VARCHAR(200) NOT NULL,
Description VARCHAR(255),
Type VARCHAR(16),
Language VARCHAR(16),
TranslationOf INTEGER DEFAULT 0 NOT NULL,
Content BYTE,
LastUpdated DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE TABLE TicketCustomFieldValues (
id SERIAL,
Ticket INTEGER NOT NULL,
CustomField INTEGER NOT NULL,
Content VARCHAR(255),
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE INDEX TicketCustomFieldValues1 ON TicketCustomFieldValues (CustomField,Ticket,Content);
CREATE INDEX TicketCustomFieldValues2 ON TicketCustomFieldValues (CustomField,Ticket);
CREATE TABLE CustomFields (
id SERIAL,
Name VARCHAR(200),
Type VARCHAR(200),
MaxValues INTEGER DEFAULT 0 NOT NULL,
Pattern VARCHAR(255),
LookupType VARCHAR(255),
Description VARCHAR(255),
SortOrder INTEGER DEFAULT 0 NOT NULL,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
Disabled SMALLINT DEFAULT 0 NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE CustomFieldValues (
id SERIAL,
CustomField INTEGER NOT NULL,
Name VARCHAR(200),
Description VARCHAR(255),
SortOrder INTEGER DEFAULT 0 NOT NULL,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE INDEX CustomFieldValues1 ON CustomFieldValues (CustomField);
CREATE TABLE Attributes (
id SERIAL,
Name VARCHAR(255) DEFAULT '' NOT NULL,
Description VARCHAR(255) DEFAULT NULL,
Content BYTE,
ContentType VARCHAR(16),
ObjectType VARCHAR(25) NOT NULL,
ObjectId INTEGER DEFAULT 0 NOT NULL,
Creator INTEGER DEFAULT 0 NOT NULL,
Created DATETIME YEAR TO SECOND,
LastUpdatedBy INTEGER DEFAULT 0 NOT NULL,
LastUpdated DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
CREATE INDEX Attributes1 on Attributes(Name);
CREATE INDEX Attributes2 on Attributes(ObjectType, ObjectId);
CREATE TABLE sessions (
id VARCHAR(32) NOT NULL,
a_session BYTE,
LastUpdated DATETIME YEAR TO SECOND,
PRIMARY KEY (id)
);
|