]> WPIA git - gigi.git/blob - src/org/cacert/gigi/database/tableStructure.sql
e72c2701734fbc6228b7599db7c62bc0bfc0a864
[gigi.git] / src / org / cacert / gigi / database / tableStructure.sql
1 DROP TABLE IF EXISTS `certOwners`;
2 CREATE TABLE `certOwners` (
3   `id` int(11) NOT NULL AUTO_INCREMENT,
4   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
5   `modified` timestamp NULL DEFAULT NULL,
6   `deleted` timestamp NULL DEFAULT NULL,
7   PRIMARY KEY (`id`)
8 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
9
10 DROP TABLE IF EXISTS `users`;
11 CREATE TABLE `users` (
12   `id` int(11) NOT NULL,
13   `email` varchar(255) NOT NULL DEFAULT '',
14   `password` varchar(255) NOT NULL DEFAULT '',
15   `fname` varchar(255) NOT NULL DEFAULT '',
16   `mname` varchar(255) NOT NULL DEFAULT '',
17   `lname` varchar(255) NOT NULL DEFAULT '',
18   `suffix` varchar(50) NOT NULL DEFAULT '',
19   `dob` date NOT NULL DEFAULT '0000-00-00',
20   `verified` int(1) NOT NULL DEFAULT '0',
21   `ccid` int(3) NOT NULL DEFAULT '0',
22   `regid` int(5) NOT NULL DEFAULT '0',
23   `locid` int(7) NOT NULL DEFAULT '0',
24   `listme` int(1) NOT NULL DEFAULT '0',
25   `contactinfo` varchar(255) NOT NULL DEFAULT '',
26   `language` varchar(5) NOT NULL DEFAULT '',
27   PRIMARY KEY (`id`),
28   KEY `ccid` (`ccid`),
29   KEY `regid` (`regid`),
30   KEY `locid` (`locid`),
31   KEY `email` (`email`),
32   KEY `stats_users_verified` (`verified`)
33 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
34
35
36 DROP TABLE IF EXISTS `organisations`;
37 CREATE TABLE IF NOT EXISTS `organisations` (
38   `id` int(11) NOT NULL,
39   `name` varchar(100) NOT NULL,
40   `state` varchar(2) NOT NULL,
41   `province` varchar(100) NOT NULL,
42   `city` varchar(100) NOT NULL,
43   `contactEmail` varchar(100) NOT NULL,
44   `creator` int(11) NOT NULL,
45   PRIMARY KEY (`id`)
46 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
47
48 DROP TABLE IF EXISTS `domains`;
49 CREATE TABLE `domains` (
50   `id` int(11) NOT NULL AUTO_INCREMENT,
51   `memid` int(11) NOT NULL,
52   `domain` varchar(255) NOT NULL,
53   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
54   `modified` datetime NULL DEFAULT NULL,
55   `deleted` datetime NULL DEFAULT NULL,
56   PRIMARY KEY (`id`),
57   KEY `memid` (`memid`),
58   KEY `domain` (`domain`),
59   KEY `stats_domains_deleted` (`deleted`)
60 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
61
62 DROP TABLE IF EXISTS `emails`;
63 CREATE TABLE `emails` (
64   `id` int(11) NOT NULL AUTO_INCREMENT,
65   `memid` int(11) NOT NULL DEFAULT '0',
66   `email` varchar(255) NOT NULL DEFAULT '',
67   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
68   `modified` datetime NULL DEFAULT NULL,
69   `deleted` datetime NULL DEFAULT NULL,
70   `hash` varchar(50) NOT NULL DEFAULT '',
71   `attempts` int(1) NOT NULL DEFAULT '0',
72   PRIMARY KEY (`id`),
73   KEY `memid` (`memid`),
74   KEY `stats_email_hash` (`hash`),
75   KEY `stats_email_deleted` (`deleted`),
76   KEY `email` (`email`)
77 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
78
79 DROP TABLE IF EXISTS `emailPinglog`;
80 CREATE TABLE `emailPinglog` (
81   `when` datetime NOT NULL,
82   `uid` int(11) NOT NULL,
83   `email` varchar(255) NOT NULL,
84   `type` enum('fast', 'active') NOT NULL,
85   `status` enum('open', 'success', 'failed') NOT NULL,
86   `result` varchar(255) NOT NULL
87 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
88
89 DROP TABLE IF EXISTS `pingconfig`;
90 CREATE TABLE `pingconfig` (
91   `id` int(13) NOT NULL AUTO_INCREMENT,
92   `domainid` int(11) NOT NULL,
93   `type` enum('email', 'ssl', 'http', 'dns') NOT NULL,
94   `info` varchar(255) NOT NULL,
95   PRIMARY KEY (`id`)
96 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
97
98
99 DROP TABLE IF EXISTS `domainPinglog`;
100 CREATE TABLE `domainPinglog` (
101   `when` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
102   `configId` int(13) NOT NULL,
103   `state` enum('open', 'success', 'failed') NOT NULL,
104   `challenge` varchar(16),
105   `result` varchar(255)
106 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
107
108 DROP TABLE IF EXISTS `baddomains`;
109 CREATE TABLE `baddomains` (
110   `domain` varchar(255) NOT NULL DEFAULT ''
111 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
112
113
114 DROP TABLE IF EXISTS `alerts`;
115 CREATE TABLE `alerts` (
116   `memid` int(11) NOT NULL DEFAULT '0',
117   `general` tinyint(1) NOT NULL DEFAULT '0',
118   `country` tinyint(1) NOT NULL DEFAULT '0',
119   `regional` tinyint(1) NOT NULL DEFAULT '0',
120   `radius` tinyint(1) NOT NULL DEFAULT '0',
121   PRIMARY KEY (`memid`)
122 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
123
124 DROP TABLE IF EXISTS `user_agreements`;
125 CREATE TABLE `user_agreements` (
126   `id` int(11) NOT NULL AUTO_INCREMENT,
127   `memid` int(11) NOT NULL,
128   `secmemid` int(11) DEFAULT NULL,
129   `document` varchar(50) DEFAULT NULL,
130   `date` datetime DEFAULT NULL,
131   `active` int(1) NOT NULL,
132   `method` varchar(100) NOT NULL,
133   `comment` varchar(100) DEFAULT NULL,
134   PRIMARY KEY (`id`)
135 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
136
137 DROP TABLE IF EXISTS `certs`;
138 CREATE TABLE `certs` (
139   `id` int(11) NOT NULL AUTO_INCREMENT,
140   `memid` int(11) NOT NULL DEFAULT '0',
141   `serial` varchar(50) NOT NULL DEFAULT '',
142   `keytype` char(2) NOT NULL DEFAULT 'NS',
143   `codesign` tinyint(1) NOT NULL DEFAULT '0',
144   `md` enum('md5','sha1','sha256','sha512') NOT NULL DEFAULT 'sha512',
145   `profile` int(3) NOT NULL,
146   `caid` int(3) NULL DEFAULT NULL,
147
148   `csr_name` varchar(255) NOT NULL DEFAULT '',
149   `csr_type` enum('CSR', 'SPKAC') NOT NULL,
150   `crt_name` varchar(255) NOT NULL DEFAULT '',
151   `created` timestamp NULL DEFAULT NULL,
152   `modified` datetime NULL DEFAULT NULL,
153   `revoked` datetime NULL DEFAULT NULL,
154   `expire` datetime NULL DEFAULT NULL,
155   `renewed` tinyint(1) NOT NULL DEFAULT '0',
156   `disablelogin` int(1) NOT NULL DEFAULT '0',
157   `pkhash` char(40) DEFAULT NULL,
158   `certhash` char(40) DEFAULT NULL,
159   `description` varchar(100) NOT NULL DEFAULT '',
160   PRIMARY KEY (`id`),
161   KEY `emailcerts_pkhash` (`pkhash`),
162   KEY `revoked` (`revoked`),
163   KEY `created` (`created`),
164   KEY `memid` (`memid`),
165   KEY `serial` (`serial`),
166   KEY `stats_emailcerts_expire` (`expire`),
167   KEY `emailcrt` (`crt_name`)
168 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
169
170
171 DROP TABLE IF EXISTS `certAvas`;
172 CREATE TABLE `certAvas` (
173   `certid` int(11) NOT NULL,
174   `name` varchar(20) NOT NULL,
175   `value` varchar(255) NOT NULL,
176
177   PRIMARY KEY (`certid`, `name`)
178 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
179
180 DROP TABLE IF EXISTS `clientcerts`;
181 CREATE TABLE `clientcerts` (
182   `id` int(11) NOT NULL,
183   `disablelogin` int(1) NOT NULL DEFAULT '0',
184
185   PRIMARY KEY (`id`)
186 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
187
188 DROP TABLE IF EXISTS `profiles`;
189 CREATE TABLE `profiles` (
190   `id` int(3) NOT NULL AUTO_INCREMENT,
191   `keyname` varchar(60) NOT NULL,
192   `keyUsage` varchar(100) NOT NULL,
193   `extendedKeyUsage` varchar(100) NOT NULL,
194   `rootcert` int(2) NOT NULL DEFAULT '1',
195   `name` varchar(100) NOT NULL,
196   PRIMARY KEY (`id`),
197   UNIQUE (`keyname`)
198 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
199
200 INSERT INTO `profiles` SET rootcert=0, keyname='client', name='ssl-client (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
201 INSERT INTO `profiles` SET rootcert=0, keyname='mail',  name='mail (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
202 INSERT INTO `profiles` SET rootcert=0, keyname='client-mail', name='ssl-client + mail (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
203 INSERT INTO `profiles` SET rootcert=0, keyname='server', name='ssl-server (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
204
205 INSERT INTO `profiles` SET rootcert=1, keyname='client-a', name='ssl-client (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
206 INSERT INTO `profiles` SET rootcert=1, keyname='mail-a',  name='mail (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
207 INSERT INTO `profiles` SET rootcert=1, keyname='client-mail-a', name='ssl-client + mail(assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
208 INSERT INTO `profiles` SET rootcert=1, keyname='server-a', name='ssl-server (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
209 INSERT INTO `profiles` SET rootcert=2, keyname='code-a', name='codesign (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='codeSigning, msCodeInd, msCodeCom';
210
211 INSERT INTO `profiles` SET rootcert=3, keyname='client-orga', name='ssl-client (orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
212 INSERT INTO `profiles` SET rootcert=3, keyname='mail-orga',  name='mail (orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
213 INSERT INTO `profiles` SET rootcert=3, keyname='client-mail-orga', name='ssl-client + mail(orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
214 INSERT INTO `profiles` SET rootcert=3, keyname='server-orga', name='ssl-server (orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
215 INSERT INTO `profiles` SET rootcert=4, keyname='code-orga', name='codesign (orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='codeSigning, msCodeInd, msCodeCom';
216
217 -- 0=unassured, 1=assured, 2=codesign, 3=orga, 4=orga-sign
218 DROP TABLE IF EXISTS `subjectAlternativeNames`;
219 CREATE TABLE `subjectAlternativeNames` (
220   `certId` int(11) NOT NULL,
221   `contents` varchar(50) NOT NULL,
222   `type` enum('email','DNS') NOT NULL
223 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
224
225 DROP TABLE IF EXISTS `cacerts`;
226 CREATE TABLE `cacerts` (
227   `id` int(3) NOT NULL AUTO_INCREMENT,
228   `keyname` varchar(60) NOT NULL,
229   `subroot` int(2) NOT NULL,
230   `validFrom` datetime NULL DEFAULT NULL,
231   `validTo` datetime NULL DEFAULT NULL,
232   PRIMARY KEY (`id`),
233   UNIQUE (`keyname`)
234 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
235
236
237 DROP TABLE IF EXISTS `jobs`;
238 CREATE TABLE `jobs` (
239   `id` int(11) NOT NULL AUTO_INCREMENT,
240   `targetId` int(11) NOT NULL,
241   `task` enum('sign','revoke') NOT NULL,
242   `state` enum('open', 'done', 'error') NOT NULL DEFAULT 'open',
243   `warning` int(2) NOT NULL DEFAULT '0',
244   `executeFrom` DATE,
245   `executeTo` VARCHAR(11),
246   PRIMARY KEY (`id`),
247   KEY `state` (`state`)
248 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
249
250
251 DROP TABLE IF EXISTS `notary`;
252 CREATE TABLE `notary` (
253   `id` int(11) NOT NULL AUTO_INCREMENT,
254   `from` int(11) NOT NULL DEFAULT '0',
255   `to` int(11) NOT NULL DEFAULT '0',
256 # total points that have been entered
257   `points` int(3) NOT NULL DEFAULT '0',
258 # awarded and the "experience points" are calculated virtually
259 # Face to Face is default, TOPUP is for the remaining 30Points after two TTP
260 # TTP is default ttp assurance
261   `method` enum('Face to Face Meeting', 'TOPUP', 'TTP-Assisted') NOT NULL DEFAULT 'Face to Face Meeting',
262   `location` varchar(255) NOT NULL DEFAULT '',
263   `date` varchar(255) NOT NULL DEFAULT '',
264 # date when assurance was entered
265   `when` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
266 #?
267   `expire` datetime NULL DEFAULT NULL,
268 #?????????????????
269   `sponsor` int(11) NOT NULL DEFAULT '0',
270 # date when assurance was deleted (or 0)
271   `deleted` datetime NULL DEFAULT NULL,
272   PRIMARY KEY (`id`),
273   KEY `from` (`from`),
274   KEY `to` (`to`),
275   KEY `stats_notary_when` (`when`),
276   KEY `stats_notary_method` (`method`)
277 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
278
279
280 DROP TABLE IF EXISTS `cats_passed`;
281 CREATE TABLE `cats_passed` (
282   `id` int(11) NOT NULL AUTO_INCREMENT,
283   `user_id` int(11) NOT NULL,
284   `variant_id` int(11) NOT NULL,
285   `pass_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
286   PRIMARY KEY (`id`),
287   UNIQUE KEY `test_passed` (`user_id`,`variant_id`,`pass_date`)
288 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
289
290 # --------------------------------------------------------
291
292 #
293 # Table structure for table `cats_type`
294 #
295
296 DROP TABLE IF EXISTS `cats_type`;
297 CREATE TABLE `cats_type` (
298   `id` int(11) NOT NULL AUTO_INCREMENT,
299   `type_text` varchar(255) NOT NULL,
300   PRIMARY KEY (`id`),
301   UNIQUE KEY `type_text` (`type_text`)
302 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
303
304 DROP TABLE IF EXISTS `arbitrations`;
305 CREATE TABLE IF NOT EXISTS `arbitrations` (
306   `user` int(11) NOT NULL,
307   `arbitration` varchar(20) NOT NULL,
308   PRIMARY KEY (`user`,`arbitration`)
309 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
310
311 DROP TABLE IF EXISTS `user_groups`;
312 CREATE TABLE IF NOT EXISTS `user_groups` (
313   `id` int(11) NOT NULL AUTO_INCREMENT,
314   `user` int(11) NOT NULL,
315   `permission` enum('supporter','arbitrator','blockedassuree','blockedassurer','blockedlogin','ttp-assurer','ttp-applicant', 'codesigning', 'orgassurer') NOT NULL,
316   `granted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
317   `deleted` timestamp NULL DEFAULT NULL,
318   `grantedby` int(11) NOT NULL,
319   `revokedby` int(11) DEFAULT NULL,
320   PRIMARY KEY (`id`)
321 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
322
323 DROP TABLE IF EXISTS `org_admin`;
324 CREATE TABLE IF NOT EXISTS `org_admin` (
325   `orgid` int(11) NOT NULL,
326   `memid` int(11) NOT NULL,
327   `master` enum('y', 'n') NOT NULL,
328   `creator` int(11) NOT NULL,
329   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
330   `deleter` int(11) NULL DEFAULT NULL,
331   `deleted` timestamp NULL DEFAULT NULL,
332   KEY (`orgid`, `memid`)
333 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
334
335 DROP TABLE IF EXISTS `adminLog`;
336 CREATE TABLE `adminLog` (
337   `when` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
338   `uid` int(11) unsigned NOT NULL,
339   `admin` int(11) unsigned NOT NULL,
340   `type` varchar(100) NOT NULL DEFAULT '',
341   `information` varchar(50) NOT NULL DEFAULT '',
342   PRIMARY KEY (`when`)
343 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
344
345 DROP TABLE IF EXISTS `schemeVersion`;
346 CREATE TABLE `schemeVersion` (
347   `version` int(5) NOT NULL,
348   PRIMARY KEY (`version`)
349 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
350 INSERT INTO schemeVersion(version)  VALUES(1);