-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgen_example_data.py
144 lines (125 loc) · 3.74 KB
/
gen_example_data.py
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
from utilities import util
from utilities import test_utils
def reset(table: str):
connection = util.make_connection()
if table != "no-drop":
util.exec_query(connection, "DROP TABLE :table", table=table)
# SQLite optimizations
util.exec_query(connection, "PRAGMA synchronous = NORMAL")
util.exec_query(connection, "PRAGMA mmap_size = 1000000000")
# ! This operation may not be supported, disable if you run into issues
util.exec_query(connection, "PRAGMA journal_mode = WAL")
# Projects Data
util.exec_query(
connection,
"""CREATE TABLE \"projects\"(
type TEXT NOT NULL,
author INT NOT NULL,
title TEXT NOT NULL,
description TEXT NOT NULL,
body TEXT NOT NULL,
icon TEXT,
url TEXT NOT NULL UNIQUE,
status TEXT NOT NULL DEFAULT \"draft\",
category TEXT NOT NULL,
uploaded INT NOT NULL,
updated INT NOT NULL,
mod_message TEXT,
downloads INT NOT NULL DEFAULT 0,
featured_until INT,
licence TEXT,
dependencies TEXT)
""",
)
# Versions Data
util.exec_query(
connection,
"""CREATE TABLE IF NOT EXISTS versions(
name TEXT NOT NULL,
description TEXT NOT NULL,
primary_download TEXT NOT NULL,
resource_pack_download TEXT,
minecraft_versions TEXT NOT NULL,
version_code TEXT NOT NULL,
project INT NOT NULL
);
""",
)
# User data
util.exec_query(
connection,
"""CREATE TABLE IF NOT EXISTS users (
username TEXT NOT NULL UNIQUE,
token TEXT NOT NULL UNIQUE,
role TEXT NOT NULL,
bio TEXT,
github_id int UNIQUE,
discord_id int UNIQUE,
badges TEXT,
profile_icon TEXT NOT NULL,
join_date INTEGER NOT NULL
)""",
)
# Banned User Data
util.exec_query(
connection,
"""CREATE TABLE IF NOT EXISTS banned_users (
id int NOT NULL UNIQUE,
expires int,
reason TEXT
)""",
)
# Notification Data
util.exec_query(
connection,
"""CREATE TABLE IF NOT EXISTS notifs(
message TEXT NOT NULL,
description TEXT NOT NULL,
read BOOL NOT NULL,
type TEXT NOT NULL,
user INT NOT NULL
);
""",
)
# Report Data
util.exec_query(
connection,
"""CREATE TABLE IF NOT EXISTS reports(
message TEXT NOT NULL,
reporter INT NOT NULL,
project INT NOT NULL
);
""",
)
# Comment data
util.exec_query(
connection,
"""CREATE TABLE IF NOT EXISTS comments(
thread_id INT,
message TEXT NOT NULL,
author INT NOT NULL,
sent INT NOT NULL,
parent_id INT
);
""",
)
# Follow data
util.exec_query(
connection,
"""CREATE TABLE IF NOT EXISTS follows(
follower INT,
followed INT
);
""",
)
# save and exit
connection.commit()
if __name__ == "__main__":
reset("no-drop")
util.commit_query(
"""INSERT INTO users (username, token, role, bio, github_id, profile_icon, join_date) VALUES ("HoodieRocks", "LOREMIPSUM", "admin", "rock", 123897432978, "https://example.com/", 0)""",
)
util.commit_query(
"""INSERT INTO users (username, token, role, bio, github_id, profile_icon, join_date) VALUES ("sacrifice", "POTATOES", "default", "paper", 238746238746, "https://example.com/1", 0)""",
)
test_utils.commit_fake_project(10)