-
Notifications
You must be signed in to change notification settings - Fork 11
/
schema.sql
311 lines (290 loc) · 13.2 KB
/
schema.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `archetypes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `archetypes` (
`name` varchar(40) NOT NULL,
`description` text,
`priority` tinyint(3) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `archetypes` WRITE;
/*!40000 ALTER TABLE `archetypes` DISABLE KEYS */;
INSERT INTO `archetypes` (`name`, `description`, `priority`) VALUES ('Aggro',NULL,2);
INSERT INTO `archetypes` (`name`, `description`, `priority`) VALUES ('Aggro-Combo',NULL,1);
INSERT INTO `archetypes` (`name`, `description`, `priority`) VALUES ('Aggro-Control',NULL,1);
INSERT INTO `archetypes` (`name`, `description`, `priority`) VALUES ('Combo',NULL,2);
INSERT INTO `archetypes` (`name`, `description`, `priority`) VALUES ('Combo-Control',NULL,1);
INSERT INTO `archetypes` (`name`, `description`, `priority`) VALUES ('Control',NULL,2);
INSERT INTO `archetypes` (`name`, `description`, `priority`) VALUES ('Unclassified',NULL,0);
/*!40000 ALTER TABLE `archetypes` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `bans`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bans` (
`card` bigint(20) unsigned NOT NULL,
`format` varchar(40) NOT NULL,
`allowed` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`card`,`format`),
KEY `format` (`format`),
CONSTRAINT `bans_ibfk_1` FOREIGN KEY (`card`) REFERENCES `cards` (`id`) ON UPDATE CASCADE,
CONSTRAINT `bans_ibfk_2` FOREIGN KEY (`format`) REFERENCES `formats` (`name`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cards`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `cards` (
`cost` varchar(40) DEFAULT NULL,
`convertedcost` tinyint(3) unsigned NOT NULL DEFAULT '0',
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`isw` tinyint(1) DEFAULT '0',
`isr` tinyint(1) DEFAULT '0',
`isg` tinyint(1) DEFAULT '0',
`isu` tinyint(1) DEFAULT '0',
`isb` tinyint(1) DEFAULT '0',
`name` varchar(40) NOT NULL,
`cardset` varchar(40) NOT NULL,
`type` varchar(40) NOT NULL,
PRIMARY KEY (`id`),
KEY `cardset` (`cardset`),
CONSTRAINT `cards_ibfk_1` FOREIGN KEY (`cardset`) REFERENCES `cardsets` (`name`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4603 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `cardsets`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `cardsets` (
`released` date NOT NULL,
`name` varchar(40) NOT NULL,
`type` enum('Core','Block','Extra') DEFAULT 'Block',
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `db_version`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `db_version` (
`version` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
LOCK TABLES `db_version` WRITE;
/*!40000 ALTER TABLE `db_version` DISABLE KEYS */;
INSERT INTO `db_version` (`version`) VALUES (2);
/*!40000 ALTER TABLE `db_version` ENABLE KEYS */;
UNLOCK TABLES;
DROP TABLE IF EXISTS `deckcontents`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `deckcontents` (
`card` bigint(20) unsigned NOT NULL,
`deck` bigint(20) unsigned NOT NULL,
`qty` tinyint(3) unsigned NOT NULL DEFAULT '1',
`issideboard` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`card`,`deck`,`issideboard`),
KEY `deck` (`deck`),
CONSTRAINT `deckcontents_ibfk_1` FOREIGN KEY (`card`) REFERENCES `cards` (`id`),
CONSTRAINT `deckcontents_ibfk_2` FOREIGN KEY (`deck`) REFERENCES `decks` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `decks`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `decks` (
`archetype` varchar(40) DEFAULT NULL,
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(40) NOT NULL,
`notes` text,
`deck_hash` varchar(40) DEFAULT NULL,
`sideboard_hash` varchar(40) DEFAULT NULL,
`whole_hash` varchar(40) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `archetype` (`archetype`)
) ENGINE=InnoDB AUTO_INCREMENT=10559 DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `decktypes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `decktypes` (
`name` varchar(40) COLLATE latin1_general_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `entries`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `entries` (
`event` varchar(40) NOT NULL,
`player` varchar(40) NOT NULL,
`medal` enum('1st','2nd','t4','t8','dot') NOT NULL DEFAULT 'dot',
`deck` bigint(20) unsigned DEFAULT NULL,
`ignored` tinyint(1) DEFAULT NULL,
`notes` text,
PRIMARY KEY (`event`,`player`),
KEY `player` (`player`),
KEY `deck` (`deck`),
CONSTRAINT `entries_ibfk_2` FOREIGN KEY (`player`) REFERENCES `players` (`name`) ON UPDATE CASCADE,
CONSTRAINT `entries_ibfk_3` FOREIGN KEY (`deck`) REFERENCES `decks` (`id`),
CONSTRAINT `entries_ibfk_4` FOREIGN KEY (`event`) REFERENCES `events` (`name`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `events`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `events` (
`start` datetime NOT NULL,
`format` varchar(40) NOT NULL,
`host` varchar(40) DEFAULT NULL,
`kvalue` tinyint(3) unsigned NOT NULL DEFAULT '16',
`metaurl` varchar(240) DEFAULT NULL,
`name` varchar(40) NOT NULL,
`number` tinyint(3) unsigned DEFAULT NULL,
`season` tinyint(3) unsigned DEFAULT NULL,
`series` varchar(40) DEFAULT NULL,
`threadurl` varchar(240) DEFAULT NULL,
`reporturl` varchar(240) DEFAULT NULL,
`finalized` tinyint(3) unsigned NOT NULL DEFAULT '0',
`cohost` varchar(40) DEFAULT NULL,
PRIMARY KEY (`name`),
KEY `format` (`format`),
KEY `host` (`host`),
KEY `series` (`series`),
KEY `cohost` (`cohost`),
CONSTRAINT `events_ibfk_1` FOREIGN KEY (`format`) REFERENCES `formats` (`name`) ON UPDATE CASCADE,
CONSTRAINT `events_ibfk_2` FOREIGN KEY (`host`) REFERENCES `players` (`name`) ON UPDATE CASCADE,
CONSTRAINT `events_ibfk_3` FOREIGN KEY (`series`) REFERENCES `series` (`name`) ON UPDATE CASCADE,
CONSTRAINT `events_ibfk_4` FOREIGN KEY (`cohost`) REFERENCES `players` (`name`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `formats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `formats` (
`name` varchar(40) NOT NULL,
`description` text,
`priority` tinyint(3) unsigned DEFAULT '1',
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `matches`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `matches` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`playera` varchar(40) NOT NULL,
`playerb` varchar(40) NOT NULL,
`round` tinyint(3) unsigned NOT NULL,
`subevent` bigint(20) unsigned NOT NULL,
`result` enum('A','B','D') NOT NULL DEFAULT 'D',
PRIMARY KEY (`id`),
KEY `playera` (`playera`),
KEY `playerb` (`playerb`),
KEY `subevent` (`subevent`),
CONSTRAINT `matches_ibfk_1` FOREIGN KEY (`playera`) REFERENCES `players` (`name`) ON UPDATE CASCADE,
CONSTRAINT `matches_ibfk_2` FOREIGN KEY (`playerb`) REFERENCES `players` (`name`) ON UPDATE CASCADE,
CONSTRAINT `matches_ibfk_3` FOREIGN KEY (`subevent`) REFERENCES `subevents` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=37427 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `players`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `players` (
`name` varchar(40) CHARACTER SET latin1 NOT NULL,
`host` tinyint(3) unsigned NOT NULL DEFAULT '0',
`password` varchar(80) CHARACTER SET latin1 DEFAULT NULL,
`super` tinyint(3) unsigned NOT NULL DEFAULT '0',
`mtgo_confirmed` tinyint(1) DEFAULT NULL,
`mtgo_challenge` varchar(5) COLLATE latin1_general_ci DEFAULT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ratings`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `ratings` (
`player` varchar(40) NOT NULL,
`rating` smallint(5) unsigned NOT NULL,
`format` varchar(40) NOT NULL,
`updated` datetime NOT NULL,
`wins` bigint(20) unsigned NOT NULL,
`losses` bigint(20) unsigned NOT NULL,
KEY `player` (`player`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `series`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `series` (
`name` varchar(40) NOT NULL,
`isactive` tinyint(1) DEFAULT '0',
`logo` blob,
`imgtype` varchar(40) DEFAULT NULL,
`imgsize` bigint(20) unsigned DEFAULT NULL,
PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `setlegality`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `setlegality` (
`format` varchar(40) NOT NULL,
`cardset` varchar(40) NOT NULL,
PRIMARY KEY (`format`,`cardset`),
KEY `cardset` (`cardset`),
CONSTRAINT `setlegality_ibfk_1` FOREIGN KEY (`format`) REFERENCES `formats` (`name`) ON UPDATE CASCADE,
CONSTRAINT `setlegality_ibfk_2` FOREIGN KEY (`cardset`) REFERENCES `cardsets` (`name`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `stewards`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `stewards` (
`event` varchar(40) NOT NULL,
`player` varchar(40) NOT NULL,
KEY `event` (`event`),
KEY `player` (`player`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `subevents`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `subevents` (
`parent` varchar(40) NOT NULL,
`rounds` tinyint(3) unsigned NOT NULL DEFAULT '3',
`timing` tinyint(3) unsigned NOT NULL DEFAULT '1',
`type` enum('Swiss','Single Elimination','League','Round Robin') DEFAULT NULL,
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
KEY `parent` (`parent`),
CONSTRAINT `subevents_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `events` (`name`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1946 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `trophies`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `trophies` (
`event` varchar(40) NOT NULL,
`image` blob,
`type` varchar(40) DEFAULT NULL,
`size` bigint(20) unsigned DEFAULT NULL,
PRIMARY KEY (`event`),
CONSTRAINT `trophies_ibfk_1` FOREIGN KEY (`event`) REFERENCES `events` (`name`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;