]> WPIA git - gigi.git/blob - doc/tableStructure.sql
[DB]: Add orgAdmin management code
[gigi.git] / doc / 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   `creator` int(11) NOT NULL,
44   PRIMARY KEY (`id`)
45 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
46
47 DROP TABLE IF EXISTS `domains`;
48 CREATE TABLE `domains` (
49   `id` int(11) NOT NULL AUTO_INCREMENT,
50   `memid` int(11) NOT NULL,
51   `domain` varchar(255) NOT NULL,
52   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
53   `modified` datetime NULL DEFAULT NULL,
54   `deleted` datetime NULL DEFAULT NULL,
55   PRIMARY KEY (`id`),
56   KEY `memid` (`memid`),
57   KEY `domain` (`domain`),
58   KEY `stats_domains_deleted` (`deleted`)
59 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
60
61 DROP TABLE IF EXISTS `emails`;
62 CREATE TABLE `emails` (
63   `id` int(11) NOT NULL AUTO_INCREMENT,
64   `memid` int(11) NOT NULL DEFAULT '0',
65   `email` varchar(255) NOT NULL DEFAULT '',
66   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
67   `modified` datetime NULL DEFAULT NULL,
68   `deleted` datetime NULL DEFAULT NULL,
69   `hash` varchar(50) NOT NULL DEFAULT '',
70   `attempts` int(1) NOT NULL DEFAULT '0',
71   PRIMARY KEY (`id`),
72   KEY `memid` (`memid`),
73   KEY `stats_email_hash` (`hash`),
74   KEY `stats_email_deleted` (`deleted`),
75   KEY `email` (`email`)
76 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
77
78 DROP TABLE IF EXISTS `emailPinglog`;
79 CREATE TABLE `emailPinglog` (
80   `when` datetime NOT NULL,
81   `uid` int(11) NOT NULL,
82   `email` varchar(255) NOT NULL,
83   `type` enum('fast', 'active') NOT NULL,
84   `status` enum('open', 'success', 'failed') NOT NULL,
85   `result` varchar(255) NOT NULL
86 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
87
88 DROP TABLE IF EXISTS `pingconfig`;
89 CREATE TABLE `pingconfig` (
90   `id` int(13) NOT NULL AUTO_INCREMENT,
91   `domainid` int(11) NOT NULL,
92   `type` enum('email', 'ssl', 'http', 'dns') NOT NULL,
93   `info` varchar(255) NOT NULL,
94   `reping` enum('y','n') NOT NULL DEFAULT 'n',
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   `CN` varchar(255) NOT NULL DEFAULT '',
143   `subject` varchar(1024) NOT NULL,
144   `keytype` char(2) NOT NULL DEFAULT 'NS',
145   `codesign` tinyint(1) NOT NULL DEFAULT '0',
146   `md` enum('md5','sha1','sha256','sha512') NOT NULL DEFAULT 'sha512',
147   `profile` int(3) NOT NULL,
148
149   `csr_name` varchar(255) NOT NULL DEFAULT '',
150   `csr_type` enum('CSR', 'SPKAC') NOT NULL,
151   `crt_name` varchar(255) NOT NULL DEFAULT '',
152   `created` timestamp NULL DEFAULT NULL,
153   `modified` datetime NULL DEFAULT NULL,
154   `revoked` datetime NULL DEFAULT NULL,
155   `expire` datetime NULL DEFAULT NULL,
156   `renewed` tinyint(1) NOT NULL DEFAULT '0',
157   `disablelogin` int(1) NOT NULL DEFAULT '0',
158   `pkhash` char(40) DEFAULT NULL,
159   `certhash` char(40) DEFAULT NULL,
160   `description` varchar(100) NOT NULL DEFAULT '',
161   PRIMARY KEY (`id`),
162   KEY `emailcerts_pkhash` (`pkhash`),
163   KEY `revoked` (`revoked`),
164   KEY `created` (`created`),
165   KEY `memid` (`memid`),
166   KEY `serial` (`serial`),
167   KEY `stats_emailcerts_expire` (`expire`),
168   KEY `emailcrt` (`crt_name`)
169 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
170
171 DROP TABLE IF EXISTS `clientcerts`;
172 CREATE TABLE `clientcerts` (
173   `id` int(11) NOT NULL,
174   `disablelogin` int(1) NOT NULL DEFAULT '0',
175
176   PRIMARY KEY (`id`)
177 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
178
179 DROP TABLE IF EXISTS `profiles`;
180 CREATE TABLE `profiles` (
181   `id` int(3) NOT NULL AUTO_INCREMENT,
182   `keyname` varchar(60) NOT NULL,
183   `keyUsage` varchar(100) NOT NULL,
184   `extendedKeyUsage` varchar(100) NOT NULL,
185   `rootcert` int(2) NOT NULL DEFAULT '1',
186   `name` varchar(100) NOT NULL,
187   PRIMARY KEY (`id`),
188   UNIQUE (`keyname`)
189 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
190
191 INSERT INTO `profiles` SET rootcert=0, keyname='client', name='ssl-client (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
192 INSERT INTO `profiles` SET rootcert=0, keyname='mail',  name='mail (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
193 INSERT INTO `profiles` SET rootcert=0, keyname='client-mail', name='ssl-client + mail (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
194 INSERT INTO `profiles` SET rootcert=0, keyname='server', name='ssl-server (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
195
196 INSERT INTO `profiles` SET rootcert=1, keyname='client-a', name='ssl-client (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
197 INSERT INTO `profiles` SET rootcert=1, keyname='mail-a',  name='mail (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
198 INSERT INTO `profiles` SET rootcert=1, keyname='client-mail-a', name='ssl-client + mail(assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
199 INSERT INTO `profiles` SET rootcert=1, keyname='server-a', name='ssl-server (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
200 INSERT INTO `profiles` SET rootcert=2, keyname='code-a', name='codesign (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='codeSigning, msCodeInd, msCodeCom';
201
202 INSERT INTO `profiles` SET rootcert=3, keyname='client-orga', name='ssl-client (orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
203 INSERT INTO `profiles` SET rootcert=3, keyname='mail-orga',  name='mail (orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
204 INSERT INTO `profiles` SET rootcert=3, keyname='client-mail-orga', name='ssl-client + mail(orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
205 INSERT INTO `profiles` SET rootcert=3, keyname='server-orga', name='ssl-server (orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
206 INSERT INTO `profiles` SET rootcert=4, keyname='code-orga', name='codesign (orga)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='codeSigning, msCodeInd, msCodeCom';
207
208 -- 0=unassured, 1=assured, 2=codesign, 3=orga, 4=orga-sign
209 DROP TABLE IF EXISTS `subjectAlternativeNames`;
210 CREATE TABLE `subjectAlternativeNames` (
211   `certId` int(11) NOT NULL,
212   `contents` varchar(50) NOT NULL,
213   `type` enum('email','DNS') NOT NULL
214 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
215
216
217
218
219 DROP TABLE IF EXISTS `jobs`;
220 CREATE TABLE `jobs` (
221   `id` int(11) NOT NULL AUTO_INCREMENT,
222   `targetId` int(11) NOT NULL,
223   `task` enum('sign','revoke') NOT NULL,
224   `state` enum('open', 'done', 'error') NOT NULL DEFAULT 'open',
225   `warning` int(2) NOT NULL DEFAULT '0',
226   `executeFrom` DATE,
227   `executeTo` VARCHAR(11),
228   PRIMARY KEY (`id`),
229   KEY `state` (`state`)
230 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
231
232
233 DROP TABLE IF EXISTS `notary`;
234 CREATE TABLE `notary` (
235   `id` int(11) NOT NULL AUTO_INCREMENT,
236   `from` int(11) NOT NULL DEFAULT '0',
237   `to` int(11) NOT NULL DEFAULT '0',
238 # total points that have been entered
239   `points` int(3) NOT NULL DEFAULT '0',
240 # awarded and the "experience points" are calculated virtually
241 # Face to Face is default, TOPUP is for the remaining 30Points after two TTP
242 # TTP is default ttp assurance
243   `method` enum('Face to Face Meeting', 'TOPUP', 'TTP-Assisted') NOT NULL DEFAULT 'Face to Face Meeting',
244   `location` varchar(255) NOT NULL DEFAULT '',
245   `date` varchar(255) NOT NULL DEFAULT '',
246 # date when assurance was entered
247   `when` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
248 #?
249   `expire` datetime NULL DEFAULT NULL,
250 #?????????????????
251   `sponsor` int(11) NOT NULL DEFAULT '0',
252 # date when assurance was deleted (or 0)
253   `deleted` datetime NULL DEFAULT NULL,
254   PRIMARY KEY (`id`),
255   KEY `from` (`from`),
256   KEY `to` (`to`),
257   KEY `stats_notary_when` (`when`),
258   KEY `stats_notary_method` (`method`)
259 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
260
261
262 DROP TABLE IF EXISTS `cats_passed`;
263 CREATE TABLE `cats_passed` (
264   `id` int(11) NOT NULL AUTO_INCREMENT,
265   `user_id` int(11) NOT NULL,
266   `variant_id` int(11) NOT NULL,
267   `pass_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
268   PRIMARY KEY (`id`),
269   UNIQUE KEY `test_passed` (`user_id`,`variant_id`,`pass_date`)
270 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
271
272 # --------------------------------------------------------
273
274 #
275 # Table structure for table `cats_type`
276 #
277
278 DROP TABLE IF EXISTS `cats_type`;
279 CREATE TABLE `cats_type` (
280   `id` int(11) NOT NULL AUTO_INCREMENT,
281   `type_text` varchar(255) NOT NULL,
282   PRIMARY KEY (`id`),
283   UNIQUE KEY `type_text` (`type_text`)
284 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
285
286 DROP TABLE IF EXISTS `arbitrations`;
287 CREATE TABLE IF NOT EXISTS `arbitrations` (
288   `user` int(11) NOT NULL,
289   `arbitration` varchar(20) NOT NULL,
290   PRIMARY KEY (`user`,`arbitration`)
291 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
292
293 DROP TABLE IF EXISTS `user_groups`;
294 CREATE TABLE IF NOT EXISTS `user_groups` (
295   `id` int(11) NOT NULL AUTO_INCREMENT,
296   `user` int(11) NOT NULL,
297   `permission` enum('supporter','arbitrator','blockedassuree','blockedassurer','blockedlogin','ttp-assurer','ttp-applicant', 'codesigning') NOT NULL,
298   `granted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
299   `deleted` timestamp NULL DEFAULT NULL,
300   `grantedby` int(11) NOT NULL,
301   `revokedby` int(11) DEFAULT NULL,
302   PRIMARY KEY (`id`)
303 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
304
305 DROP TABLE IF EXISTS `org_admin`;
306 CREATE TABLE IF NOT EXISTS `org_admin` (
307   `orgid` int(11) NOT NULL,
308   `memid` int(11) NOT NULL,
309   `creator` int(11) NOT NULL,
310   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
311   `deleter` int(11) NULL DEFAULT NULL,
312   `deleted` timestamp NULL DEFAULT NULL,
313   PRIMARY KEY (`orgid`, `memid`)
314 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;