-
Notifications
You must be signed in to change notification settings - Fork 19
/
1_rdmdb_tables.up.sql
319 lines (291 loc) · 12.2 KB
/
1_rdmdb_tables.up.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
311
312
313
314
315
316
317
318
--
-- Table structure for table `gym`
--
CREATE TABLE `gym` (
`id` varchar(35) NOT NULL,
`lat` double(18,14) NOT NULL,
`lon` double(18,14) NOT NULL,
`name` varchar(128) DEFAULT NULL,
`url` varchar(200) DEFAULT NULL,
`last_modified_timestamp` int unsigned DEFAULT NULL,
`raid_end_timestamp` int unsigned DEFAULT NULL,
`raid_spawn_timestamp` int unsigned DEFAULT NULL,
`raid_battle_timestamp` int unsigned DEFAULT NULL,
`updated` int unsigned NOT NULL,
`raid_pokemon_id` smallint unsigned DEFAULT NULL,
`guarding_pokemon_id` smallint unsigned DEFAULT NULL,
`available_slots` smallint unsigned DEFAULT NULL,
`availble_slots` smallint unsigned GENERATED ALWAYS AS (`available_slots`) VIRTUAL,
`team_id` tinyint unsigned DEFAULT NULL,
`raid_level` tinyint unsigned DEFAULT NULL,
`enabled` tinyint unsigned DEFAULT NULL,
`ex_raid_eligible` tinyint unsigned DEFAULT NULL,
`in_battle` tinyint unsigned DEFAULT NULL,
`raid_pokemon_move_1` smallint unsigned DEFAULT NULL,
`raid_pokemon_move_2` smallint unsigned DEFAULT NULL,
`raid_pokemon_form` smallint unsigned DEFAULT NULL,
`raid_pokemon_cp` int unsigned DEFAULT NULL,
`raid_is_exclusive` tinyint unsigned DEFAULT NULL,
`cell_id` bigint unsigned DEFAULT NULL,
`deleted` tinyint unsigned NOT NULL DEFAULT '0',
`total_cp` int unsigned DEFAULT NULL,
`first_seen_timestamp` int unsigned NOT NULL,
`raid_pokemon_gender` tinyint unsigned DEFAULT NULL,
`sponsor_id` smallint unsigned DEFAULT NULL,
`partner_id` varchar(35) DEFAULT NULL,
`raid_pokemon_costume` smallint unsigned DEFAULT NULL,
`raid_pokemon_evolution` tinyint unsigned DEFAULT NULL,
`ar_scan_eligible` tinyint unsigned DEFAULT NULL,
`power_up_level` smallint unsigned DEFAULT NULL,
`power_up_points` int unsigned DEFAULT NULL,
`power_up_end_timestamp` int unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `ix_coords` (`lat`,`lon`),
KEY `ix_raid_end_timestamp` (`raid_end_timestamp`),
KEY `ix_updated` (`updated`),
KEY `ix_raid_pokemon_id` (`raid_pokemon_id`),
KEY `fk_gym_cell_id` (`cell_id`),
KEY `ix_gym_deleted` (`deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `incident`
--
CREATE TABLE `incident` (
`id` varchar(35) NOT NULL,
`pokestop_id` varchar(35) NOT NULL,
`start` int unsigned NOT NULL,
`expiration` int unsigned NOT NULL,
`display_type` smallint unsigned NOT NULL,
`style` smallint unsigned NOT NULL,
`character` smallint unsigned NOT NULL,
`updated` int unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `ix_pokestop` (`pokestop_id`,`expiration`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `invasion_stats`
--
DROP TABLE IF EXISTS `invasion_stats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `invasion_stats` (
`date` date NOT NULL,
`grunt_type` smallint unsigned NOT NULL DEFAULT '0',
`count` int NOT NULL,
PRIMARY KEY (`date`,`grunt_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `pokemon`
--
CREATE TABLE `pokemon` (
`id` varchar(25) NOT NULL,
`pokestop_id` varchar(35) DEFAULT NULL,
`spawn_id` bigint unsigned DEFAULT NULL,
`lat` double(18,14) NOT NULL,
`lon` double(18,14) NOT NULL,
`weight` double(18,14) DEFAULT NULL,
`size` double(18,14) DEFAULT NULL,
`expire_timestamp` int unsigned DEFAULT NULL,
`updated` int unsigned DEFAULT NULL,
`pokemon_id` smallint unsigned NOT NULL,
`move_1` smallint unsigned DEFAULT NULL,
`move_2` smallint unsigned DEFAULT NULL,
`gender` tinyint unsigned DEFAULT NULL,
`cp` smallint unsigned DEFAULT NULL,
`atk_iv` tinyint unsigned DEFAULT NULL,
`def_iv` tinyint unsigned DEFAULT NULL,
`sta_iv` tinyint unsigned DEFAULT NULL,
`form` smallint unsigned DEFAULT NULL,
`level` tinyint unsigned DEFAULT NULL,
`weather` tinyint unsigned DEFAULT NULL,
`costume` tinyint unsigned DEFAULT NULL,
`first_seen_timestamp` int unsigned NOT NULL,
`changed` int unsigned NOT NULL DEFAULT '0',
`iv` float(5,2) unsigned GENERATED ALWAYS AS (((((`atk_iv` + `def_iv`) + `sta_iv`) * 100) / 45)) VIRTUAL,
`cell_id` bigint unsigned DEFAULT NULL,
`expire_timestamp_verified` tinyint unsigned NOT NULL,
`display_pokemon_id` smallint unsigned DEFAULT NULL,
`seen_type` enum('wild','encounter','nearby_stop','nearby_cell') DEFAULT NULL,
`shiny` tinyint(1) DEFAULT '0',
`username` varchar(32) DEFAULT NULL,
`capture_1` double(18,14) DEFAULT NULL,
`capture_2` double(18,14) DEFAULT NULL,
`capture_3` double(18,14) DEFAULT NULL,
`pvp` text,
`is_event` tinyint unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`,`is_event`),
KEY `ix_coords` (`lat`,`lon`),
KEY `ix_pokemon_id` (`pokemon_id`),
KEY `ix_updated` (`updated`),
KEY `fk_spawn_id` (`spawn_id`),
KEY `fk_pokestop_id` (`pokestop_id`),
KEY `ix_atk_iv` (`atk_iv`),
KEY `ix_def_iv` (`def_iv`),
KEY `ix_sta_iv` (`sta_iv`),
KEY `ix_changed` (`changed`),
KEY `ix_level` (`level`),
KEY `fk_pokemon_cell_id` (`cell_id`),
KEY `ix_expire_timestamp` (`expire_timestamp`),
KEY `ix_iv` (`iv`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE TABLE `pokemon_hundo_stats` (
`date` date NOT NULL,
`pokemon_id` smallint unsigned NOT NULL,
`count` int NOT NULL,
PRIMARY KEY (`date`,`pokemon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `pokemon_iv_stats`
--
CREATE TABLE `pokemon_iv_stats` (
`date` date NOT NULL,
`pokemon_id` smallint unsigned NOT NULL,
`count` int NOT NULL,
PRIMARY KEY (`date`,`pokemon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `pokemon_shiny_stats`
--
CREATE TABLE `pokemon_shiny_stats` (
`date` date NOT NULL,
`pokemon_id` smallint unsigned NOT NULL,
`count` int NOT NULL,
PRIMARY KEY (`date`,`pokemon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `pokemon_stats`
--
CREATE TABLE `pokemon_stats` (
`date` date NOT NULL,
`pokemon_id` smallint unsigned NOT NULL,
`count` int NOT NULL,
PRIMARY KEY (`date`,`pokemon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `pokestop`
--
CREATE TABLE `pokestop` (
`id` varchar(35) NOT NULL,
`lat` double(18,14) NOT NULL,
`lon` double(18,14) NOT NULL,
`name` varchar(128) DEFAULT NULL,
`url` varchar(200) DEFAULT NULL,
`lure_expire_timestamp` int unsigned DEFAULT NULL,
`last_modified_timestamp` int unsigned DEFAULT NULL,
`updated` int unsigned NOT NULL,
`enabled` tinyint unsigned DEFAULT NULL,
`quest_type` int unsigned DEFAULT NULL,
`quest_timestamp` int unsigned DEFAULT NULL,
`quest_target` smallint unsigned DEFAULT NULL,
`quest_conditions` text,
`quest_rewards` text,
`quest_template` varchar(100) DEFAULT NULL,
`quest_title` varchar(100) DEFAULT NULL,
`quest_reward_type` smallint unsigned GENERATED ALWAYS AS (json_extract(json_extract(`quest_rewards`,_utf8mb4'$[*].type'),_utf8mb4'$[0]')) VIRTUAL,
`quest_item_id` smallint unsigned GENERATED ALWAYS AS (json_extract(json_extract(`quest_rewards`,_utf8mb4'$[*].info.item_id'),_utf8mb4'$[0]')) VIRTUAL,
`quest_reward_amount` smallint unsigned GENERATED ALWAYS AS (json_extract(json_extract(`quest_rewards`,_utf8mb4'$[*].info.amount'),_utf8mb4'$[0]')) VIRTUAL,
`cell_id` bigint unsigned DEFAULT NULL,
`deleted` tinyint unsigned NOT NULL DEFAULT '0',
`lure_id` smallint DEFAULT '0',
`first_seen_timestamp` int unsigned NOT NULL,
`sponsor_id` smallint unsigned DEFAULT NULL,
`partner_id` varchar(35) DEFAULT NULL,
`quest_pokemon_id` smallint unsigned GENERATED ALWAYS AS (json_extract(json_extract(`quest_rewards`,_utf8mb4'$[*].info.pokemon_id'),_utf8mb4'$[0]')) VIRTUAL,
`ar_scan_eligible` tinyint unsigned DEFAULT NULL,
`power_up_level` smallint unsigned DEFAULT NULL,
`power_up_points` int unsigned DEFAULT NULL,
`power_up_end_timestamp` int unsigned DEFAULT NULL,
`alternative_quest_type` int unsigned DEFAULT NULL,
`alternative_quest_timestamp` int unsigned DEFAULT NULL,
`alternative_quest_target` smallint unsigned DEFAULT NULL,
`alternative_quest_conditions` text,
`alternative_quest_rewards` text,
`alternative_quest_template` varchar(100) DEFAULT NULL,
`alternative_quest_title` varchar(100) DEFAULT NULL,
`alternative_quest_pokemon_id` smallint unsigned GENERATED ALWAYS AS (json_extract(json_extract(`alternative_quest_rewards`,_utf8mb4'$[*].info.pokemon_id'),_utf8mb4'$[0]')) VIRTUAL,
`alternative_quest_reward_type` smallint unsigned GENERATED ALWAYS AS (json_extract(json_extract(`alternative_quest_rewards`,_utf8mb4'$[*].type'),_utf8mb4'$[0]')) VIRTUAL,
`alternative_quest_item_id` smallint unsigned GENERATED ALWAYS AS (json_extract(json_extract(`alternative_quest_rewards`,_utf8mb4'$[*].info.item_id'),_utf8mb4'$[0]')) VIRTUAL,
`alternative_quest_reward_amount` smallint unsigned GENERATED ALWAYS AS (json_extract(json_extract(`alternative_quest_rewards`,_utf8mb4'$[*].info.amount'),_utf8mb4'$[0]')) VIRTUAL,
PRIMARY KEY (`id`),
KEY `ix_coords` (`lat`,`lon`),
KEY `ix_lure_expire_timestamp` (`lure_expire_timestamp`),
KEY `ix_updated` (`updated`),
KEY `fk_pokestop_cell_id` (`cell_id`),
KEY `ix_pokestop_deleted` (`deleted`),
KEY `ix_quest_reward_type` (`quest_reward_type`),
KEY `ix_quest_item_id` (`quest_item_id`),
KEY `ix_quest_pokemon_id` (`quest_pokemon_id`),
KEY `ix_alternative_quest_alternative_quest_pokemon_id` (`alternative_quest_pokemon_id`),
KEY `ix_alternative_quest_reward_type` (`alternative_quest_reward_type`),
KEY `ix_alternative_quest_item_id` (`alternative_quest_item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `quest_stats`
--
CREATE TABLE `quest_stats` (
`date` date NOT NULL,
`reward_type` smallint unsigned NOT NULL DEFAULT '0',
`pokemon_id` smallint unsigned NOT NULL DEFAULT '0',
`item_id` smallint unsigned NOT NULL DEFAULT '0',
`count` int NOT NULL,
PRIMARY KEY (`date`,`reward_type`,`pokemon_id`,`item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `raid_stats`
--
CREATE TABLE `raid_stats` (
`date` date NOT NULL,
`pokemon_id` smallint unsigned NOT NULL,
`count` int NOT NULL,
`level` smallint unsigned DEFAULT NULL,
PRIMARY KEY (`date`,`pokemon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `s2cell`
--
CREATE TABLE `s2cell` (
`id` bigint unsigned NOT NULL,
`level` tinyint unsigned DEFAULT NULL,
`center_lat` double(18,14) NOT NULL DEFAULT '0.00000000000000',
`center_lon` double(18,14) NOT NULL DEFAULT '0.00000000000000',
`updated` int unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `ix_coords` (`center_lat`,`center_lon`),
KEY `ix_updated` (`updated`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `spawnpoint`
--
CREATE TABLE `spawnpoint` (
`id` bigint unsigned NOT NULL,
`lat` double(18,14) NOT NULL,
`lon` double(18,14) NOT NULL,
`updated` int unsigned NOT NULL DEFAULT '0',
`last_seen` int unsigned NOT NULL DEFAULT '0',
`despawn_sec` smallint unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `ix_coords` (`lat`,`lon`),
KEY `ix_updated` (`updated`),
KEY `ix_last_seen` (`last_seen`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Table structure for table `weather`
--
CREATE TABLE `weather` (
`id` bigint NOT NULL,
`level` tinyint unsigned DEFAULT NULL,
`latitude` double(18,14) NOT NULL DEFAULT '0.00000000000000',
`longitude` double(18,14) NOT NULL DEFAULT '0.00000000000000',
`gameplay_condition` tinyint unsigned DEFAULT NULL,
`wind_direction` mediumint DEFAULT NULL,
`cloud_level` tinyint unsigned DEFAULT NULL,
`rain_level` tinyint unsigned DEFAULT NULL,
`wind_level` tinyint unsigned DEFAULT NULL,
`snow_level` tinyint unsigned DEFAULT NULL,
`fog_level` tinyint unsigned DEFAULT NULL,
`special_effect_level` tinyint unsigned DEFAULT NULL,
`severity` tinyint unsigned DEFAULT NULL,
`warn_weather` tinyint unsigned DEFAULT NULL,
`updated` int unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;