]> WPIA git - gigi.git/blob - doc/tableStructure.sql
2d5fa6c38421d2f304f8d9dc8ef524ae0ed4b88c
[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   `admin` tinyint(1) NOT NULL DEFAULT '0',
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   `locked` tinyint(1) NOT NULL DEFAULT '0',
22   `assurer_blocked` tinyint(1) NOT NULL DEFAULT '0',
23   PRIMARY KEY (`id`),
24   KEY `ccid` (`ccid`),
25   KEY `regid` (`regid`),
26   KEY `locid` (`locid`),
27   KEY `email` (`email`),
28   KEY `stats_users_created` (`created`),
29   KEY `stats_users_verified` (`verified`),
30   KEY `userverified` (`verified`)
31 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
32
33
34 DROP TABLE IF EXISTS `domains`;
35 CREATE TABLE `domains` (
36   `id` int(11) NOT NULL AUTO_INCREMENT,
37   `memid` int(11) NOT NULL,
38   `domain` varchar(255) NOT NULL,
39   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
40   `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
41   `deleted` datetime DEFAULT NULL,
42   PRIMARY KEY (`id`),
43   KEY `memid` (`memid`),
44   KEY `domain` (`domain`),
45   KEY `stats_domains_deleted` (`deleted`)
46 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
47
48 DROP TABLE IF EXISTS `emails`;
49 CREATE TABLE `emails` (
50   `id` int(11) NOT NULL AUTO_INCREMENT,
51   `memid` int(11) NOT NULL DEFAULT '0',
52   `email` varchar(255) NOT NULL DEFAULT '',
53   `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
54   `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
55   `deleted` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
56   `hash` varchar(50) NOT NULL DEFAULT '',
57   `attempts` int(1) NOT NULL DEFAULT '0',
58   PRIMARY KEY (`id`),
59   KEY `memid` (`memid`),
60   KEY `stats_email_hash` (`hash`),
61   KEY `stats_email_deleted` (`deleted`),
62   KEY `email` (`email`)
63 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
64
65 DROP TABLE IF EXISTS `emailPinglog`;
66 CREATE TABLE `emailPinglog` (
67   `when` datetime NOT NULL,
68   `uid` int(11) NOT NULL,
69   `emailid` int(11) NOT NULL,
70   `type` enum('fast', 'active') NOT NULL,
71   `status` enum('open', 'success', 'failed') NOT NULL,
72   `result` varchar(255) NOT NULL
73 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
74
75 DROP TABLE IF EXISTS `pingconfig`;
76 CREATE TABLE `pingconfig` (
77   `id` int(13) NOT NULL AUTO_INCREMENT,
78   `domainid` int(11) NOT NULL,
79   `type` enum('email', 'ssl', 'http', 'dns') NOT NULL,
80   `info` varchar(255) NOT NULL,
81   PRIMARY KEY (`id`)
82 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
83
84
85 DROP TABLE IF EXISTS `domainPinglog`;
86 CREATE TABLE `domainPinglog` (
87   `when` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
88   `configId` int(13) NOT NULL,
89   `state` enum('open', 'success', 'failed') NOT NULL,
90   `challenge` varchar(16) NOT NULL,
91   `result` varchar(255)
92 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
93
94 DROP TABLE IF EXISTS `baddomains`;
95 CREATE TABLE `baddomains` (
96   `domain` varchar(255) NOT NULL DEFAULT ''
97 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
98
99
100 DROP TABLE IF EXISTS `alerts`;
101 CREATE TABLE `alerts` (
102   `memid` int(11) NOT NULL DEFAULT '0',
103   `general` tinyint(1) NOT NULL DEFAULT '0',
104   `country` tinyint(1) NOT NULL DEFAULT '0',
105   `regional` tinyint(1) NOT NULL DEFAULT '0',
106   `radius` tinyint(1) NOT NULL DEFAULT '0',
107   PRIMARY KEY (`memid`)
108 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
109
110 DROP TABLE IF EXISTS `user_agreements`;
111 CREATE TABLE `user_agreements` (
112   `id` int(11) NOT NULL AUTO_INCREMENT,
113   `memid` int(11) NOT NULL,
114   `secmemid` int(11) DEFAULT NULL,
115   `document` varchar(50) DEFAULT NULL,
116   `date` datetime DEFAULT NULL,
117   `active` int(1) NOT NULL,
118   `method` varchar(100) NOT NULL,
119   `comment` varchar(100) DEFAULT NULL,
120   PRIMARY KEY (`id`)
121 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
122
123 DROP TABLE IF EXISTS `certs`;
124 CREATE TABLE `certs` (
125   `id` int(11) NOT NULL AUTO_INCREMENT,
126   `memid` int(11) NOT NULL DEFAULT '0',
127   `serial` varchar(50) NOT NULL DEFAULT '',
128   `CN` varchar(255) NOT NULL DEFAULT '',
129   `subject` text NOT NULL,
130   `keytype` char(2) NOT NULL DEFAULT 'NS',
131   `codesign` tinyint(1) NOT NULL DEFAULT '0',
132   `md` enum('md5','sha1','sha256','sha512') NOT NULL DEFAULT 'sha512',
133   `profile` int(3) NOT NULL,
134
135   `csr_name` varchar(255) NOT NULL DEFAULT '',
136   `csr_type` enum('CSR', 'SPKAC') NOT NULL,
137   `crt_name` varchar(255) NOT NULL DEFAULT '',
138   `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
139   `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
140   `revoked` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
141   `expire` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
142   `renewed` tinyint(1) NOT NULL DEFAULT '0',
143   `disablelogin` int(1) NOT NULL DEFAULT '0',
144   `pkhash` char(40) DEFAULT NULL,
145   `certhash` char(40) DEFAULT NULL,
146   `description` varchar(100) NOT NULL DEFAULT '',
147   PRIMARY KEY (`id`),
148   KEY `emailcerts_pkhash` (`pkhash`),
149   KEY `revoked` (`revoked`),
150   KEY `created` (`created`),
151   KEY `memid` (`memid`),
152   KEY `serial` (`serial`),
153   KEY `stats_emailcerts_expire` (`expire`),
154   KEY `emailcrt` (`crt_name`)
155 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
156
157 DROP TABLE IF EXISTS `clientcerts`;
158 CREATE TABLE `clientcerts` (
159   `id` int(11) NOT NULL,
160   `disablelogin` int(1) NOT NULL DEFAULT '0',
161
162   PRIMARY KEY (`id`)
163 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
164
165 DROP TABLE IF EXISTS `profiles`;
166 CREATE TABLE `profiles` (
167   `id` int(3) NOT NULL AUTO_INCREMENT,
168   `keyname` varchar(60) NOT NULL,
169   `keyUsage` varchar(100) NOT NULL,
170   `extendedKeyUsage` varchar(100) NOT NULL,
171   `rootcert` int(2) NOT NULL DEFAULT '1',
172   `name` varchar(100) NOT NULL,
173   PRIMARY KEY (`id`),
174   UNIQUE (`keyname`)
175 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
176 INSERT INTO `profiles` SET rootcert=0, keyname='client', name='ssl-client (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
177 INSERT INTO `profiles` SET rootcert=0, keyname='mail',  name='mail (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
178 INSERT INTO `profiles` SET rootcert=0, keyname='client-mail', name='ssl-client + mail (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
179 INSERT INTO `profiles` SET rootcert=0, keyname='server', name='ssl-server (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
180
181 INSERT INTO `profiles` SET rootcert=1, keyname='client-a', name='ssl-client (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
182 INSERT INTO `profiles` SET rootcert=1, keyname='mail-a',  name='mail (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
183 INSERT INTO `profiles` SET rootcert=1, keyname='client-mail-a', name='ssl-client + mail(assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
184 INSERT INTO `profiles` SET rootcert=1, keyname='server-a', name='ssl-server (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
185
186 -- 0=unassured, 1=assured, 2=codesign, 3=orga, 4=orga-sign
187 DROP TABLE IF EXISTS `subjectAlternativeNames`;
188 CREATE TABLE `subjectAlternativeNames` (
189   `certId` int(11) NOT NULL,
190   `contents` varchar(50) NOT NULL,
191   `type` enum('email','DNS') NOT NULL
192 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
193
194
195
196
197 DROP TABLE IF EXISTS `jobs`;
198 CREATE TABLE `jobs` (
199   `id` int(11) NOT NULL AUTO_INCREMENT,
200   `targetId` int(11) NOT NULL,
201   `task` enum('sign','revoke') NOT NULL,
202   `state` enum('open', 'done', 'error') NOT NULL DEFAULT 'open',
203   `warning` int(2) NOT NULL DEFAULT '0',
204   `executeFrom` DATE,
205   `executeTo` VARCHAR(11),
206   PRIMARY KEY (`id`),
207   KEY `state` (`state`)
208 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
209
210
211 DROP TABLE IF EXISTS `notary`;
212 CREATE TABLE `notary` (
213   `id` int(11) NOT NULL AUTO_INCREMENT,
214   `from` int(11) NOT NULL DEFAULT '0',
215   `to` int(11) NOT NULL DEFAULT '0',
216   `awarded` int(3) NOT NULL DEFAULT '0',
217   `points` int(3) NOT NULL DEFAULT '0',
218   `method` enum('Face to Face Meeting','Trusted Third Parties','Thawte Points Transfer','Administrative Increase','CT Magazine - Germany','Temporary Increase','Unknown','TOPUP','TTP-Assisted') NOT NULL DEFAULT 'Face to Face Meeting',
219   `location` varchar(255) NOT NULL DEFAULT '',
220   `date` varchar(255) NOT NULL DEFAULT '',
221   `when` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
222   `expire` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
223   `sponsor` int(11) NOT NULL DEFAULT '0',
224   `deleted` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
225   PRIMARY KEY (`id`),
226   KEY `from` (`from`),
227   KEY `to` (`to`),
228   KEY `from_2` (`from`),
229   KEY `to_2` (`to`),
230   KEY `stats_notary_when` (`when`),
231   KEY `stats_notary_method` (`method`)
232 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
233
234
235 DROP TABLE IF EXISTS `cats_passed`;
236 CREATE TABLE `cats_passed` (
237   `id` int(11) NOT NULL AUTO_INCREMENT,
238   `user_id` int(11) NOT NULL,
239   `variant_id` int(11) NOT NULL,
240   `pass_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
241   PRIMARY KEY (`id`),
242   UNIQUE KEY `test_passed` (`user_id`,`variant_id`,`pass_date`)
243 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
244
245 # --------------------------------------------------------
246
247 #
248 # Table structure for table `cats_type`
249 #
250
251 DROP TABLE IF EXISTS `cats_type`;
252 CREATE TABLE `cats_type` (
253   `id` int(11) NOT NULL AUTO_INCREMENT,
254   `type_text` varchar(255) NOT NULL,
255   PRIMARY KEY (`id`),
256   UNIQUE KEY `type_text` (`type_text`)
257 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;