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