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