This repository has been archived by the owner on Jan 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_database.sql
65 lines (55 loc) · 1.79 KB
/
create_database.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
CREATE TABLE IF NOT EXISTS user (
u_id INTEGER NOT NULL PRIMARY KEY,
u_name TEXT,
u_access_token TEXT,
u_access_level INTEGER
);
CREATE TABLE IF NOT EXISTS label (
l_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
l_name TEXT,
l_color TEXT
);
CREATE TABLE IF NOT EXISTS project (
p_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
p_title TEXT,
p_description TEXT,
p_status INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS milestone (
m_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
m_title TEXT,
m_description TEXT,
m_duedate DATETIME,
m_p_project INTEGER,
m_status INTEGER NOT NULL,
FOREIGN KEY (m_p_project) REFERENCES project (p_id)
);
CREATE TABLE IF NOT EXISTS todo (
t_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
t_title TEXT NOT NULL,
t_description TEXT NOT NULL,
t_u_assignee INTEGER,
t_m_milestone INTEGER,
t_status INTEGER NOT NULL,
t_p_project INTEGER,
FOREIGN KEY (t_p_project) REFERENCES project (p_id),
FOREIGN KEY (t_u_assignee) REFERENCES user (u_id),
FOREIGN KEY (t_m_milestone) REFERENCES milestone (m_id)
);
CREATE TABLE IF NOT EXISTS todo_and_label (
tl_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
tl_t_todo INTEGER NOT NULL,
tl_l_label INTEGER NOT NULL,
FOREIGN KEY (tl_t_todo) REFERENCES todo (t_id),
FOREIGN KEY (tl_l_label) REFERENCES label (l_id)
);
CREATE TABLE IF NOT EXISTS event (
e_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
e_type INTEGER NOT NULL,
e_content TEXT,
e_timestamp DATETIME DEFAULT current_timestamp,
e_u_id INTEGER NOT NULL,
e_t_id INTEGER NOT NULL,
FOREIGN KEY (e_u_id) REFERENCES user (u_id),
FOREIGN KEY (e_t_id) REFERENCES todo (t_id)
);