-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
34 lines (34 loc) · 1.11 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
CREATE TABLE IF NOT EXISTS users(
username TEXT PRIMARY KEY,
displayname TEXT NOT NULL,
password TEXT NOT NULL,
permission INTEGER
);
CREATE TABLE IF NOT EXISTS flags(
flag TEXT PRIMARY KEY,
hash TEXT NOT NULL,
value INTEGER NOT NULL,
event_id INTEGER REFERENCES events(id),
notes TEXT,
user TEXT REFERENCES users(username)
);
CREATE TABLE IF NOT EXISTS flagsfound(
flag_id TEXT NOT NULL REFERENCES flags(flag),
user_id TEXT NOT NULL REFERENCES users(username),
timestamp TEXT,
PRIMARY KEY (flag_id, user_id)
);
CREATE TABLE IF NOT EXISTS events(id INTEGER PRIMARY KEY, name TEXT NOT NULL, active BOOLEAN, has_teams BOOLEAN);
CREATE TABLE IF NOT EXISTS teams(
slug TEXT NOT NULL,
name TEXT NOT NULL,
event_id INTEGER REFERENCES events(id),
PRIMARY KEY (slug, event_id)
);
CREATE TABLE IF NOT EXISTS teamusers(
team_slug TEXT NOT NULL REFERENCES teams(slug),
event_id INTEGER NOT NULL REFERENCES teams(event_id),
user_id TEXT NOT NULL REFERENCES users(username),
PRIMARY KEY (team_slug, event_id, user_id)
);
CREATE TABLE IF NOT EXISTS ranks(rank TEXT PRIMARY KEY, score INTEGER NOT NULL);