-
Notifications
You must be signed in to change notification settings - Fork 0
/
initialize.sql
58 lines (50 loc) · 1.75 KB
/
initialize.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
CREATE TABLE IF NOT EXISTS users(
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
email VARCHAR (256) NOT NULL,
name VARCHAR (256)
);
CREATE UNIQUE INDEX IF NOT EXISTS "email_unique_index" ON "users" (lower("email"));
CREATE TABLE IF NOT EXISTS lists (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
name VARCHAR ( 50 ) NOT NULL,
user_name VARCHAR ( 20 ) NOT NULL,
description TEXT,
created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
completed BOOLEAN DEFAULT FALSE,
repeats BOOLEAN DEFAULT FALSE
);
CREATE TABLE IF NOT EXISTS tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
list_id INTEGER REFERENCES lists(id) ON DELETE CASCADE,
name VARCHAR ( 50 ) NOT NULL,
created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
description TEXT,
category VARCHAR (50),
repeats BOOLEAN DEFAULT FALSE,
frequency VARCHAR (25)
);
CREATE TABLE IF NOT EXISTS task_history (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
task_id INTEGER REFERENCES tasks(id) ON DELETE CASCADE,
created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
completed BOOLEAN DEFAULT FALSE,
notes TEXT
);
CREATE TABLE IF NOT EXISTS symptoms (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
name VARCHAR ( 200 ) UNIQUE NOT NULL,
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
description TEXT,
category VARCHAR ( 200 )
);
CREATE TABLE IF NOT EXISTS symptoms_history (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
symptom_id INTEGER NOT NULL REFERENCES symptoms(id) ON DELETE CASCADE,
created_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
intensity INT NOT NULL,
description TEXT
);
-- to access postgres terminal "sudo -u evergreen psql -d self_scribe"