forked from 2048khz-gachi-rmx/beizwors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tables.sql
244 lines (215 loc) · 7.67 KB
/
tables.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
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!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 */;
CREATE TABLE IF NOT EXISTS `bw_baseareas` (
`zone_id` int NOT NULL AUTO_INCREMENT,
`zone_name` varchar(121) DEFAULT NULL,
`base_id` int NOT NULL,
`zone_max_x` float NOT NULL,
`zone_max_y` float NOT NULL,
`zone_max_z` float NOT NULL,
`zone_min_x` float NOT NULL,
`zone_min_y` float NOT NULL,
`zone_min_z` float NOT NULL,
PRIMARY KEY (`zone_id`)
) ENGINE=InnoDB AUTO_INCREMENT=243 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `bw_bases` (
`base_id` int NOT NULL AUTO_INCREMENT,
`base_name` varchar(500) NOT NULL,
`base_data` json DEFAULT NULL,
`map_name` varchar(128) DEFAULT NULL,
PRIMARY KEY (`base_id`)
) ENGINE=InnoDB AUTO_INCREMENT=277 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `bw_plydata` (
`puid` bigint unsigned NOT NULL,
`money` bigint unsigned NOT NULL DEFAULT '300',
`lvl` int unsigned NOT NULL DEFAULT '1',
`xp` bigint unsigned NOT NULL DEFAULT '0',
`playtime` bigint NOT NULL DEFAULT '0',
`prestige` bigint unsigned NOT NULL DEFAULT '0',
`ptokens` bigint unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`puid`),
UNIQUE KEY `puid_UNIQUE` (`puid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `bw_rollback` (
`puid` bigint unsigned NOT NULL,
`money` bigint unsigned DEFAULT NULL,
`ents` json DEFAULT NULL,
PRIMARY KEY (`puid`),
UNIQUE KEY `puid_UNIQUE` (`puid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `cum_ranks` (
`permissions` text,
`rankid` int NOT NULL,
PRIMARY KEY (`rankid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
DELIMITER //
CREATE FUNCTION `GetBaseItemID`(
comp_name VARCHAR(254)
) RETURNS int
MODIFIES SQL DATA
DETERMINISTIC
BEGIN
-- <Body>
DECLARE ret INT DEFAULT NULL;
SELECT id INTO ret FROM itemids WHERE name = comp_name;
IF ( isnull(ret) ) THEN
INSERT INTO `itemids`(name) VALUES(comp_name);
RETURN LAST_INSERT_ID();
END IF;
RETURN ret;
-- </Body>
END//
DELIMITER ;
DELIMITER //
CREATE PROCEDURE `InsertByIDInInventory`(
id INT UNSIGNED,
inv TEXT,
puid BIGINT,
jsDat TEXT
)
BEGIN
-- <Body>
DECLARE uid INT UNSIGNED;
INSERT INTO items(iid, `data`) VALUES(id, jsDat);
SET uid = last_insert_id();
SET @t1 = CONCAT('INSERT INTO ', inv ,'(uid, puid) VALUES(', uid, ", ", puid, ')' ); # oh my fucking god actually kill me
PREPARE stmt3 FROM @t1;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;
SELECT uid;
-- </Body>
END//
DELIMITER ;
DELIMITER //
CREATE PROCEDURE `InsertByItemNameInInventory`(
itemname VARCHAR(254),
inv TEXT,
puid BIGINT,
jsDat TEXT
)
BEGIN
-- <Body>
DECLARE uid INT UNSIGNED;
DECLARE iid INT UNSIGNED;
SELECT id INTO iid FROM itemids WHERE name = itemname;
INSERT INTO items(iid, `data`) VALUES(iid, jsDat);
SET uid = last_insert_id();
SET @t1 = CONCAT('INSERT INTO ', inv ,'(uid, puid)
VALUES(', uid, ", ", puid,')' ); # oh my fucking god actually kill me
PREPARE stmt3 FROM @t1;
EXECUTE stmt3;
DEALLOCATE PREPARE stmt3;
SELECT uid;
-- </Body>
END//
DELIMITER ;
CREATE TABLE IF NOT EXISTS `inv_entity` (
`uid` int NOT NULL,
`puid` bigint unsigned DEFAULT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `uid` (`uid`),
CONSTRAINT `inv_entity_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `items_old` (`uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `inv_ply_char` (
`uid` int NOT NULL,
`puid` bigint unsigned DEFAULT NULL,
`slotid` mediumint unsigned DEFAULT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `uid` (`uid`),
UNIQUE KEY `uq_slot_puid` (`puid`,`slotid`),
CONSTRAINT `inv_ply_char_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `items_old` (`uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `inv_ply_perma` (
`uid` int NOT NULL,
`puid` bigint unsigned DEFAULT NULL,
`slotid` mediumint unsigned DEFAULT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `uid` (`uid`),
UNIQUE KEY `uq_slot_puid` (`puid`,`slotid`),
CONSTRAINT `inv_ply_perma_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `items_old` (`uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `inv_ply_temp` (
`uid` int NOT NULL,
`puid` bigint unsigned DEFAULT NULL,
`slotid` mediumint unsigned DEFAULT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `uid` (`uid`),
UNIQUE KEY `uq_slot_puid` (`puid`,`slotid`),
CONSTRAINT `inv_ply_temp_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `items_old` (`uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `inv_ply_vault` (
`uid` int NOT NULL,
`puid` bigint unsigned DEFAULT NULL,
`slotid` mediumint unsigned DEFAULT NULL,
PRIMARY KEY (`uid`),
UNIQUE KEY `uid` (`uid`),
UNIQUE KEY `uq_slot_puid` (`puid`,`slotid`),
CONSTRAINT `inv_ply_vault_ibfk_1` FOREIGN KEY (`uid`) REFERENCES `items_old` (`uid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `itemids` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(254) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id_UNIQUE` (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `items` (
`uid` int NOT NULL AUTO_INCREMENT,
`iid` int NOT NULL,
`owner` bigint DEFAULT NULL,
`inventory` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`slot` int DEFAULT NULL,
`data` json DEFAULT NULL,
PRIMARY KEY (`uid`) USING BTREE,
UNIQUE KEY `uid_UNIQUE` (`uid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=34727 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `nx_bans` (
`puid` bigint NOT NULL,
`banTime` bigint NOT NULL,
`unbanTime` bigint NOT NULL,
`admin` mediumtext,
`reason` mediumtext,
`lastname` tinytext,
PRIMARY KEY (`puid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `nx_detections` (
`dataid` int NOT NULL AUTO_INCREMENT,
`uid` bigint unsigned NOT NULL,
`detection` smallint NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`extra_data` mediumtext,
PRIMARY KEY (`dataid`)
) ENGINE=InnoDB AUTO_INCREMENT=1642 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `research` (
`puid` bigint NOT NULL,
`perks` json DEFAULT NULL,
PRIMARY KEY (`puid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `todo` (
`uid` int NOT NULL AUTO_INCREMENT,
`str` text,
`done` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
DELIMITER //
CREATE PROCEDURE `todoDeleteAndReturn`(id INT)
BEGIN
SELECT * FROM todo WHERE uid = id;
DELETE FROM todo WHERE uid = id;
END//
DELIMITER ;
DELIMITER //
CREATE PROCEDURE `todoSolveAndReturn`(id INT)
BEGIN
UPDATE todo SET done = TRUE WHERE uid = id;
SELECT * FROM todo WHERE uid = id;
END//
DELIMITER ;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;