]> WPIA git - gigi.git/blob - doc/tableStructure.sql
3619308d7aa361bf6188d55194538bee8df11c08
[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   `reping` enum('y','n') NOT NULL DEFAULT 'n',
83   PRIMARY KEY (`id`)
84 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
85
86
87 DROP TABLE IF EXISTS `domainPinglog`;
88 CREATE TABLE `domainPinglog` (
89   `when` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
90   `configId` int(13) NOT NULL,
91   `state` enum('open', 'success', 'failed') NOT NULL,
92   `challenge` varchar(16),
93   `result` varchar(255)
94 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
95
96 DROP TABLE IF EXISTS `baddomains`;
97 CREATE TABLE `baddomains` (
98   `domain` varchar(255) NOT NULL DEFAULT ''
99 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
100
101
102 DROP TABLE IF EXISTS `alerts`;
103 CREATE TABLE `alerts` (
104   `memid` int(11) NOT NULL DEFAULT '0',
105   `general` tinyint(1) NOT NULL DEFAULT '0',
106   `country` tinyint(1) NOT NULL DEFAULT '0',
107   `regional` tinyint(1) NOT NULL DEFAULT '0',
108   `radius` tinyint(1) NOT NULL DEFAULT '0',
109   PRIMARY KEY (`memid`)
110 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
111
112 DROP TABLE IF EXISTS `user_agreements`;
113 CREATE TABLE `user_agreements` (
114   `id` int(11) NOT NULL AUTO_INCREMENT,
115   `memid` int(11) NOT NULL,
116   `secmemid` int(11) DEFAULT NULL,
117   `document` varchar(50) DEFAULT NULL,
118   `date` datetime DEFAULT NULL,
119   `active` int(1) NOT NULL,
120   `method` varchar(100) NOT NULL,
121   `comment` varchar(100) DEFAULT NULL,
122   PRIMARY KEY (`id`)
123 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
124
125 DROP TABLE IF EXISTS `certs`;
126 CREATE TABLE `certs` (
127   `id` int(11) NOT NULL AUTO_INCREMENT,
128   `memid` int(11) NOT NULL DEFAULT '0',
129   `serial` varchar(50) NOT NULL DEFAULT '',
130   `CN` varchar(255) NOT NULL DEFAULT '',
131   `subject` text NOT NULL,
132   `keytype` char(2) NOT NULL DEFAULT 'NS',
133   `codesign` tinyint(1) NOT NULL DEFAULT '0',
134   `md` enum('md5','sha1','sha256','sha512') NOT NULL DEFAULT 'sha512',
135   `profile` int(3) NOT NULL,
136
137   `csr_name` varchar(255) NOT NULL DEFAULT '',
138   `csr_type` enum('CSR', 'SPKAC') NOT NULL,
139   `crt_name` varchar(255) NOT NULL DEFAULT '',
140   `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
141   `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
142   `revoked` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
143   `expire` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
144   `renewed` tinyint(1) NOT NULL DEFAULT '0',
145   `disablelogin` int(1) NOT NULL DEFAULT '0',
146   `pkhash` char(40) DEFAULT NULL,
147   `certhash` char(40) DEFAULT NULL,
148   `description` varchar(100) NOT NULL DEFAULT '',
149   PRIMARY KEY (`id`),
150   KEY `emailcerts_pkhash` (`pkhash`),
151   KEY `revoked` (`revoked`),
152   KEY `created` (`created`),
153   KEY `memid` (`memid`),
154   KEY `serial` (`serial`),
155   KEY `stats_emailcerts_expire` (`expire`),
156   KEY `emailcrt` (`crt_name`)
157 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
158
159 DROP TABLE IF EXISTS `clientcerts`;
160 CREATE TABLE `clientcerts` (
161   `id` int(11) NOT NULL,
162   `disablelogin` int(1) NOT NULL DEFAULT '0',
163
164   PRIMARY KEY (`id`)
165 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
166
167 DROP TABLE IF EXISTS `profiles`;
168 CREATE TABLE `profiles` (
169   `id` int(3) NOT NULL AUTO_INCREMENT,
170   `keyname` varchar(60) NOT NULL,
171   `keyUsage` varchar(100) NOT NULL,
172   `extendedKeyUsage` varchar(100) NOT NULL,
173   `rootcert` int(2) NOT NULL DEFAULT '1',
174   `name` varchar(100) NOT NULL,
175   PRIMARY KEY (`id`),
176   UNIQUE (`keyname`)
177 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
178 INSERT INTO `profiles` SET rootcert=0, keyname='client', name='ssl-client (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
179 INSERT INTO `profiles` SET rootcert=0, keyname='mail',  name='mail (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
180 INSERT INTO `profiles` SET rootcert=0, keyname='client-mail', name='ssl-client + mail (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
181 INSERT INTO `profiles` SET rootcert=0, keyname='server', name='ssl-server (unassured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
182
183 INSERT INTO `profiles` SET rootcert=1, keyname='client-a', name='ssl-client (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth';
184 INSERT INTO `profiles` SET rootcert=1, keyname='mail-a',  name='mail (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='emailProtection';
185 INSERT INTO `profiles` SET rootcert=1, keyname='client-mail-a', name='ssl-client + mail(assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='clientAuth, emailProtection';
186 INSERT INTO `profiles` SET rootcert=1, keyname='server-a', name='ssl-server (assured)', keyUsage='digitalSignature, keyEncipherment, keyAgreement', extendedKeyUsage='serverAuth';
187
188 -- 0=unassured, 1=assured, 2=codesign, 3=orga, 4=orga-sign
189 DROP TABLE IF EXISTS `subjectAlternativeNames`;
190 CREATE TABLE `subjectAlternativeNames` (
191   `certId` int(11) NOT NULL,
192   `contents` varchar(50) NOT NULL,
193   `type` enum('email','DNS') NOT NULL
194 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
195
196
197
198
199 DROP TABLE IF EXISTS `jobs`;
200 CREATE TABLE `jobs` (
201   `id` int(11) NOT NULL AUTO_INCREMENT,
202   `targetId` int(11) NOT NULL,
203   `task` enum('sign','revoke') NOT NULL,
204   `state` enum('open', 'done', 'error') NOT NULL DEFAULT 'open',
205   `warning` int(2) NOT NULL DEFAULT '0',
206   `executeFrom` DATE,
207   `executeTo` VARCHAR(11),
208   PRIMARY KEY (`id`),
209   KEY `state` (`state`)
210 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
211
212
213 DROP TABLE IF EXISTS `notary`;
214 CREATE TABLE `notary` (
215   `id` int(11) NOT NULL AUTO_INCREMENT,
216   `from` int(11) NOT NULL DEFAULT '0',
217   `to` int(11) NOT NULL DEFAULT '0',
218 # total points that have been entered
219   `points` int(3) NOT NULL DEFAULT '0',
220 # awarded and the "experience points" are calculated virtually
221 # Face to Face is default, TOPUP is for the remaining 30Points after two TTP
222 # TTP is default ttp assurance
223   `method` enum('Face to Face Meeting', 'TOPUP', 'TTP-Assisted') NOT NULL DEFAULT 'Face to Face Meeting',
224   `location` varchar(255) NOT NULL DEFAULT '',
225   `date` varchar(255) NOT NULL DEFAULT '',
226 # date when assurance was entered
227   `when` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
228 #?
229   `expire` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
230 #?????????????????
231   `sponsor` int(11) NOT NULL DEFAULT '0',
232 # date when assurance was deleted (or 0)
233   `deleted` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
234   PRIMARY KEY (`id`),
235   KEY `from` (`from`),
236   KEY `to` (`to`),
237   KEY `stats_notary_when` (`when`),
238   KEY `stats_notary_method` (`method`)
239 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
240
241
242 DROP TABLE IF EXISTS `cats_passed`;
243 CREATE TABLE `cats_passed` (
244   `id` int(11) NOT NULL AUTO_INCREMENT,
245   `user_id` int(11) NOT NULL,
246   `variant_id` int(11) NOT NULL,
247   `pass_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
248   PRIMARY KEY (`id`),
249   UNIQUE KEY `test_passed` (`user_id`,`variant_id`,`pass_date`)
250 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
251
252 # --------------------------------------------------------
253
254 #
255 # Table structure for table `cats_type`
256 #
257
258 DROP TABLE IF EXISTS `cats_type`;
259 CREATE TABLE `cats_type` (
260   `id` int(11) NOT NULL AUTO_INCREMENT,
261   `type_text` varchar(255) NOT NULL,
262   PRIMARY KEY (`id`),
263   UNIQUE KEY `type_text` (`type_text`)
264 ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
265
266 DROP TABLE IF EXISTS `arbitrations`;
267 CREATE TABLE IF NOT EXISTS `arbitrations` (
268   `user` int(11) NOT NULL,
269   `arbitration` varchar(20) NOT NULL,
270   PRIMARY KEY (`user`,`arbitration`)
271 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;