-
Notifications
You must be signed in to change notification settings - Fork 1
/
01_initTables.sql
128 lines (108 loc) · 2.69 KB
/
01_initTables.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
CREATE DATABASE IF NOT EXISTS unga;
CREATE TABLE IF NOT EXISTS `unga`.`users`(
username varchar(100) PRIMARY KEY,
password text,
registered text,
email text,
operating_system text
);
CREATE TABLE IF NOT EXISTS `unga`.`platforms`(
id int PRIMARY KEY,
name text
);
CREATE TABLE IF NOT EXISTS `unga`.`userPlatformMapping`(
username varchar(100),
usernameOfPlatform text,
platformId integer,
FOREIGN KEY(username) REFERENCES `unga`.`users`(username) ON DELETE CASCADE,
FOREIGN KEY(platformId) REFERENCES `unga`.`platforms`(id) ON DELETE CASCADE,
PRIMARY KEY(username, platformId)
);
CREATE TABLE IF NOT EXISTS `unga`.`games`(
id integer PRIMARY KEY auto_increment,
platform_id integer,
name text UNIQUE,
coverImage text,
FOREIGN KEY(platform_id) REFERENCES `unga`.`platforms`(id)
);
CREATE TABLE IF NOT EXISTS `unga`.`gameUserMapping`(
game_id integer,
username varchar(100),
FOREIGN KEY(game_id) REFERENCES `unga`.`games`(id) ON DELETE CASCADE,
FOREIGN KEY(username) REFERENCES `unga`.`users`(username) ON DELETE CASCADE,
PRIMARY KEY(game_id, username)
);
CREATE TABLE IF NOT EXISTS `unga`.`invalidToken`(
token varchar(200) PRIMARY KEY,
expiration INTEGER UNSIGNED DEFAULT UNIX_TIMESTAMP() NOT NULL
);
INSERT INTO users VALUES (
"demo",
"$2a$10$9n21zUJBEys29m8HeSaqWedZFcYQJ7JRo.SCxIDOcY/4NZUA7x.MG",
UNIX_TIMESTAMP(),
"d@d.d",
"Windows"
);
INSERT INTO `unga`.`platforms` VALUES(
1,
"Steam"
);
INSERT INTO `unga`.`platforms` VALUES(
2,
"Origin"
);
INSERT INTO `unga`.`platforms` VALUES(
3,
"EpicGames"
);
INSERT INTO `unga`.`platforms` VALUES(
4,
"UbisoftConnect"
);
INSERT INTO `unga`.`platforms` VALUES(
5,
"BattleNET"
);
INSERT INTO `unga`.`userPlatformMapping` VALUES(
"demo",
"demo_steam",
1
);
INSERT INTO `unga`.`userPlatformMapping` VALUES(
"demo",
"demo_origin",
2
);
INSERT INTO `unga`.`userPlatformMapping` VALUES(
"demo",
"demo_epic",
3
);
INSERT INTO `unga`.`userPlatformMapping` VALUES(
"demo",
"demo_ubisoft",
4
);
INSERT INTO `unga`.`userPlatformMapping` VALUES(
"demo",
"demo_battlenet",
5
);
INSERT INTO `unga`.`games`(platform_id, name, coverImage) VALUES(
2,
"Battlefield 2042",
"/images/upload/bf2042.jpg"
);
INSERT INTO `unga`.`gameUserMapping` VALUES(
(SELECT id FROM `unga`.`games` WHERE name = "Battlefield 2042"),
"demo"
);
INSERT INTO `unga`.`games`(platform_id, name, coverImage) VALUES(
2,
"Battlefield V",
"/images/upload/bf5.jpg"
);
INSERT INTO `unga`.`gameUserMapping` VALUES(
(SELECT id FROM `unga`.`games` WHERE name = "Battlefield V"),
"demo"
);