CLEANUP: cleaned up code for Karlchen
[e-DoKo.git] / create_database.sql
1 /* Copyright 2006, 2007, 2008, 2009, 2010 Arun Persaud <arun@nubati.net>
2  *
3  *   This file is part of e-DoKo.
4  *
5  *   e-DoKo is free software: you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation, either version 3 of the License, or
8  *   (at your option) any later version.
9  *
10  *   e-DoKo is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *   GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with e-DoKo.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19
20 -- MySQL dump 10.9
21 --
22 -- Host: localhost    Database: doko
23 -- ------------------------------------------------------
24 -- Server version       4.1.10
25
26 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
27 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
28 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
29 /*!40101 SET NAMES utf8 */;
30 /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
31 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
32 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
33
34
35 --
36 -- Table structure for table `Version`
37 --
38
39 DROP TABLE IF EXISTS `Version`;
40 CREATE TABLE `Version` (
41   `version` int NOT NULL default '0'
42 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
43
44 --
45 -- Dumping data for table `Card`
46 --
47
48
49 /*!40000 ALTER TABLE `Card` DISABLE KEYS */;
50 LOCK TABLES `Version` WRITE;
51 INSERT INTO `Version` VALUES (2);
52 UNLOCK TABLES;
53 /*!40000 ALTER TABLE `Version` ENABLE KEYS */;
54
55
56 --
57 -- Table structure for table `Card`
58 --
59
60 DROP TABLE IF EXISTS `Card`;
61 CREATE TABLE `Card` (
62   `id` int(11) NOT NULL auto_increment,
63   `suite` enum('diamonds','hearts','spades','clubs') NOT NULL default 'diamonds',
64   `strength` enum('nine','ten','jack','queen','king','ace') NOT NULL default 'nine',
65   `points` tinyint(4) NOT NULL default '0',
66   UNIQUE KEY `id` (`id`)
67 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
68
69 --
70 -- Dumping data for table `Card`
71 --
72
73
74 /*!40000 ALTER TABLE `Card` DISABLE KEYS */;
75 LOCK TABLES `Card` WRITE;
76 INSERT INTO `Card` VALUES (1,'hearts','ten',10),(2,'hearts','ten',10),(3,'clubs','queen',3),(4,'clubs','queen',3),(5,'spades','queen',3),(6,'spades','queen',3),(7,'hearts','queen',3),(8,'hearts','queen',3),(9,'diamonds','queen',3),(10,'diamonds','queen',3),(11,'clubs','jack',2),(12,'clubs','jack',2),(13,'spades','jack',2),(14,'spades','jack',2),(15,'hearts','jack',2),(16,'hearts','jack',2),(17,'diamonds','jack',2),(18,'diamonds','jack',2),(19,'diamonds','ace',11),(20,'diamonds','ace',11),(21,'diamonds','ten',10),(22,'diamonds','ten',10),(23,'diamonds','king',4),(24,'diamonds','king',4),(25,'diamonds','nine',0),(26,'diamonds','nine',0),(27,'clubs','ace',11),(28,'clubs','ace',11),(29,'clubs','ten',10),(30,'clubs','ten',10),(31,'clubs','king',4),(32,'clubs','king',4),(33,'clubs','nine',0),(34,'clubs','nine',0),(35,'spades','ace',11),(36,'spades','ace',11),(37,'spades','ten',10),(38,'spades','ten',10),(39,'spades','king',4),(40,'spades','king',4),(41,'spades','nine',0),(42,'spades','nine',0),(43,'hearts','ace',11),(44,'hearts','ace',11),(45,'hearts','king',4),(46,'hearts','king',4),(47,'hearts','nine',0),(48,'hearts','nine',0);
77 UNLOCK TABLES;
78 /*!40000 ALTER TABLE `Card` ENABLE KEYS */;
79
80 --
81 -- Table structure for table `Comment`
82 --
83
84 DROP TABLE IF EXISTS `Comment`;
85 CREATE TABLE `Comment` (
86   `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
87   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
88   `id` int(11) NOT NULL auto_increment,
89   `user_id` int(11) default NULL,
90   `play_id` int(11) default NULL,
91   `comment` text,
92   UNIQUE KEY `id` (`id`),
93   KEY `play_id` (`play_id`)
94 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
95
96 --
97 -- Dumping data for table `Comment`
98 --
99
100
101 /*!40000 ALTER TABLE `Comment` DISABLE KEYS */;
102 LOCK TABLES `Comment` WRITE;
103 UNLOCK TABLES;
104 /*!40000 ALTER TABLE `Comment` ENABLE KEYS */;
105
106 --
107 -- Table structure for table `Notes`
108 --
109
110 DROP TABLE IF EXISTS `Notes`;
111 CREATE TABLE `Notes` (
112   `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
113   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
114   `id` int(11) NOT NULL auto_increment,
115   `user_id` int(11) default NULL,
116   `game_id` int(11) default NULL,
117   `comment` text,
118   UNIQUE KEY `id` (`id`)
119 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
120
121 --
122 -- Dumping data for table `Notes`
123 --
124
125 /*!40000 ALTER TABLE `Notes` DISABLE KEYS */;
126 LOCK TABLES `Notes` WRITE;
127 UNLOCK TABLES;
128 /*!40000 ALTER TABLE `Notes` ENABLE KEYS */;
129
130 --
131 -- Table structure for table `Game`
132 --
133
134 DROP TABLE IF EXISTS `Game`;
135 CREATE TABLE `Game` (
136   `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
137   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
138   `randomnumbers` varchar(136) default NULL,
139   `type` enum('normal','solo','wedding','poverty','dpoverty') default NULL,
140   `solo` enum('trumpless','jack','queen','trump','club','spade','heart','silent') default NULL,
141   `sickness` int(11) default NULL,
142   `startplayer` tinyint(4) default '1',
143   `player` int(11) default NULL,
144   `status` enum('pre','play','gameover','cancel-timedout','cancel-nines','cancel-trump','cancel-noplay','cancel-lowtrump') default NULL,
145   `ruleset` int(11) default NULL,
146   `session` int(11) default NULL,
147   `id` int(11) NOT NULL auto_increment,
148   UNIQUE KEY `id` (`id`),
149   KEY `session` (`session`)
150 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
151
152 --
153 -- Dumping data for table `Game`
154 --
155
156
157 /*!40000 ALTER TABLE `Game` DISABLE KEYS */;
158 LOCK TABLES `Game` WRITE;
159 UNLOCK TABLES;
160 /*!40000 ALTER TABLE `Game` ENABLE KEYS */;
161
162
163 --
164 -- Table structure for table `Ruleset`
165 --
166
167 DROP TABLE IF EXISTS `Rulesets`;
168 CREATE TABLE `Rulesets` (
169   `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
170   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
171   `dullen` enum('none','firstwins','secondwins') default 'secondwins',
172   `schweinchen` enum ('none','both','second','secondaftercall') default 'second',
173   `call` enum ('1st-own-card','5th-card','9-cards') default '1st-own-card',
174   `lowtrump` enum('poverty','cancel','none') default 'poverty',
175   `id` int(11) NOT NULL auto_increment,
176   UNIQUE KEY `id` (`id`)
177 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
178
179 --
180 -- Dumping data for table `Rulesets`
181 --
182
183
184 /*!40000 ALTER TABLE `Rulesets` DISABLE KEYS */;
185 LOCK TABLES `Rulesets` WRITE;
186 UNLOCK TABLES;
187 /*!40000 ALTER TABLE `Rulesets` ENABLE KEYS */;
188
189
190
191 --
192 -- Table structure for table `Hand`
193 --
194
195 DROP TABLE IF EXISTS `Hand`;
196 CREATE TABLE `Hand` (
197   `id` int(11) NOT NULL auto_increment,
198   `game_id` int(11) NOT NULL default '0',
199   `user_id` int(11) NOT NULL default '0',
200   `hash` varchar(33) default NULL,
201   `status` enum('start','init','check','poverty','play','gameover') default 'start',
202   `position` tinyint(4) NOT NULL default '0',
203   `party` enum('re','contra') default NULL,
204   `sickness` enum('wedding','nines','poverty','solo','lowtrump') default NULL,
205   `solo` enum('trumpless','jack','queen','trump','club','spade','heart','silent') default NULL,
206   `point_call` enum('120','90','60','30','0') default NULL,
207   UNIQUE KEY `id` (`id`),
208   KEY `game_id` (`game_id`),
209   KEY `user_id` (`user_id`)
210 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
211
212 --
213 -- Dumping data for table `Hand`
214 --
215
216
217 /*!40000 ALTER TABLE `Hand` DISABLE KEYS */;
218 LOCK TABLES `Hand` WRITE;
219 UNLOCK TABLES;
220 /*!40000 ALTER TABLE `Hand` ENABLE KEYS */;
221
222 --
223 -- Table structure for table `Hand_Card`
224 --
225
226 DROP TABLE IF EXISTS `Hand_Card`;
227 CREATE TABLE `Hand_Card` (
228   `id` int(11) NOT NULL auto_increment,
229   `hand_id` int(11) NOT NULL default '0',
230   `card_id` int(11) NOT NULL default '0',
231   `played` enum('true','false') default 'false',
232   UNIQUE KEY `id` (`id`),
233   KEY `hand_id` (`hand_id`)
234 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
235
236 --
237 -- Dumping data for table `Hand_Card`
238 --
239
240
241 /*!40000 ALTER TABLE `Hand_Card` DISABLE KEYS */;
242 LOCK TABLES `Hand_Card` WRITE;
243 UNLOCK TABLES;
244 /*!40000 ALTER TABLE `Hand_Card` ENABLE KEYS */;
245
246 --
247 -- Table structure for table `Card_Exchange`
248 --
249
250 DROP TABLE IF EXISTS `Card_Exchange`;
251 CREATE TABLE `Card_Exchange` (
252   `id` int(11) NOT NULL auto_increment,
253   `orig_hand_id` int(11) NOT NULL default '0',
254   `new_hand_id` int(11) NOT NULL default '0',
255   `card_id` int(11) NOT NULL default '0',
256   UNIQUE KEY `id` (`id`),
257   KEY `orig_hand_id` (`orig_hand_id`),
258   KEY `new_hand_id` (`new_hand_id`)
259 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
260
261 --
262 -- Dumping data for table `Hand_Card`
263 --
264
265
266 /*!40000 ALTER TABLE `Hand_Card` DISABLE KEYS */;
267 LOCK TABLES `Card_Exchange` WRITE;
268 UNLOCK TABLES;
269 /*!40000 ALTER TABLE `Hand_Card` ENABLE KEYS */;
270
271
272 --
273 -- Table structure for table `Play`
274 --
275
276 DROP TABLE IF EXISTS `Play`;
277 CREATE TABLE `Play` (
278   `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
279   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
280   `id` int(11) NOT NULL auto_increment,
281   `trick_id` int(11) NOT NULL default '0',
282   `hand_card_id` int(11) NOT NULL default '0',
283   `sequence` tinyint(4) NOT NULL default '0',
284   UNIQUE KEY `id` (`id`),
285   KEY `trick_id` (`trick_id`)
286 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
287
288 --
289 -- Dumping data for table `Play`
290 --
291
292
293 /*!40000 ALTER TABLE `Play` DISABLE KEYS */;
294 LOCK TABLES `Play` WRITE;
295 UNLOCK TABLES;
296 /*!40000 ALTER TABLE `Play` ENABLE KEYS */;
297
298 --
299 -- Table structure for table `Score`
300 --
301
302 DROP TABLE IF EXISTS `Score`;
303 CREATE TABLE `Score` (
304   `id` int(11) NOT NULL auto_increment,
305   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
306   `game_id` int(11) NOT NULL default '0',
307   `party` enum('re','contra') default NULL ,
308   `winner_id` int(11) default NULL ,
309   `looser_id` int(11) default NULL ,
310   `score` enum('120', 'call120','against120','90','call90','against90','made90',
311           '60','call60','against60','made60','30','call30','against30','made30',
312           '0','call0','against0','made0',
313           'fox','karlchen','dulle','doko','againstqueens') default NULL,
314   UNIQUE KEY `id` (`id`),
315   KEY `game_id` (`game_id`)
316 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
317
318 --
319 -- Dumping data for table `Score`
320 --
321
322
323 /*!40000 ALTER TABLE `Score` DISABLE KEYS */;
324 LOCK TABLES `Score` WRITE;
325 UNLOCK TABLES;
326 /*!40000 ALTER TABLE `Score` ENABLE KEYS */;
327
328 --
329 -- Table structure for table `Trick`
330 --
331
332 DROP TABLE IF EXISTS `Trick`;
333 CREATE TABLE `Trick` (
334   `mod_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
335   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
336   `id` int(11) NOT NULL auto_increment,
337   `game_id` int(11) NOT NULL default '0',
338   `winner`  tinyint(4) default NULL,
339   UNIQUE KEY `id` (`id`),
340   KEY `game_id` (`game_id`)
341 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
342
343 --
344 -- Dumping data for table `Trick`
345 --
346
347
348 /*!40000 ALTER TABLE `Trick` DISABLE KEYS */;
349 LOCK TABLES `Trick` WRITE;
350 UNLOCK TABLES;
351 /*!40000 ALTER TABLE `Trick` ENABLE KEYS */;
352
353 --
354 -- Table structure for table `User`
355 --
356
357 DROP TABLE IF EXISTS `User`;
358 CREATE TABLE `User` (
359   `id` int(11) NOT NULL auto_increment,
360   `fullname` varchar(64) default NULL,
361   `email` varchar(64) default NULL,
362   `password` varchar(32) default NULL,
363   `timezone` varchar(64) default 'Europe/London',
364   `last_login` timestamp NOT NULL default '0000-00-00 00:00:00',
365   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
366   UNIQUE KEY `id` (`id`)
367 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
368
369 --
370 -- Dumping data for table `User`
371 --
372
373
374 /*!40000 ALTER TABLE `User` DISABLE KEYS */;
375 LOCK TABLES `User` WRITE;
376 UNLOCK TABLES;
377 /*!40000 ALTER TABLE `User` ENABLE KEYS */;
378
379 --
380 -- Table structure for table `User_Game_Prefs`
381 --
382
383 DROP TABLE IF EXISTS `User_Game_Prefs`;
384 CREATE TABLE `User_Game_Prefs` (
385   `id` int(11) NOT NULL auto_increment,
386   `user_id` int(11) NOT NULL default '0',
387   `game_id` int(11) NOT NULL default '0',
388   `pref_key` varchar(64) default NULL,
389   `value` varchar(64) default NULL,
390   UNIQUE KEY `id` (`id`),
391   KEY `user_id` (`user_id`)
392 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
393
394 --
395 -- Dumping data for table `User_Game_Prefs`
396 --
397
398
399 /*!40000 ALTER TABLE `User_Game_Prefs` DISABLE KEYS */;
400 LOCK TABLES `User_Game_Prefs` WRITE;
401 UNLOCK TABLES;
402 /*!40000 ALTER TABLE `User_Game_Prefs` ENABLE KEYS */;
403
404 --
405 -- Table structure for table `User_Prefs`
406 --
407
408 DROP TABLE IF EXISTS `User_Prefs`;
409 CREATE TABLE `User_Prefs` (
410   `id` int(11) NOT NULL auto_increment,
411   `user_id` int(11) NOT NULL default '0',
412   `pref_key` varchar(64) default NULL,
413   `value` varchar(64) default NULL,
414   UNIQUE KEY `id` (`id`),
415   KEY `user_id` (`user_id`)
416 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
417
418 --
419 -- Dumping data for table `User_Prefs`
420 --
421
422
423
424
425 /*!40000 ALTER TABLE `Recovery` DISABLE KEYS */;
426 LOCK TABLES `Recovery` WRITE;
427 UNLOCK TABLES;
428 /*!40000 ALTER TABLE `Recovery` ENABLE KEYS */;
429
430
431 DROP TABLE IF EXISTS `Recovery`;
432 CREATE TABLE `Recovery` (
433   `id` int(11) NOT NULL auto_increment,
434   `user_id` int(11) NOT NULL default '0',
435   `password` varchar(32) default NULL,
436   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
437   UNIQUE KEY `id` (`id`)
438 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
439
440 --
441 -- Dumping data for table `Recovery`
442 --
443
444 /*!40000 ALTER TABLE `Recovery` DISABLE KEYS */;
445 LOCK TABLES `Recovery` WRITE;
446 UNLOCK TABLES;
447 /*!40000 ALTER TABLE `Recovery` ENABLE KEYS */;
448
449 /*!40000 ALTER TABLE `Reminder` DISABLE KEYS */;
450 LOCK TABLES `Reminder` WRITE;
451 UNLOCK TABLES;
452 /*!40000 ALTER TABLE `Reminder` ENABLE KEYS */;
453
454 DROP TABLE IF EXISTS `Reminder`;
455 CREATE TABLE `Reminder` (
456   `id` int(11) NOT NULL auto_increment,
457   `user_id` int(11) NOT NULL default '0',
458   `game_id` int(11) NOT NULL default '0',
459   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
460   UNIQUE KEY `id` (`id`)
461 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
462
463 --
464 -- Dumping data for table `Reminder`
465 --
466
467 /*!40000 ALTER TABLE `Reminder` DISABLE KEYS */;
468 LOCK TABLES `Reminder` WRITE;
469 UNLOCK TABLES;
470 /*!40000 ALTER TABLE `Reminder` ENABLE KEYS */;
471
472
473 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
474 /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
475 /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
476 /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
477 /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
478 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
479
480 DROP TABLE IF EXISTS `user_openids`;
481 create table user_openids (
482   openid_url varchar(255) not null,
483   primary key (openid_url),
484
485   user_id int not null,
486   index (user_id)
487 );
488
489 DROP TABLE IF EXISTS `digest_email`;
490 create table digest_email (
491   `id` int(11) NOT NULL auto_increment,
492   `email` varchar(255) default null,
493   `create_date` timestamp NOT NULL default '0000-00-00 00:00:00',
494   `content` text,
495   UNIQUE KEY `id` (`id`),
496   index (email)
497 );
498
499