-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_database.sql
35 lines (31 loc) · 1.01 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
CREATE TABLE IF NOT EXISTS media (
id INTEGER PRIMARY KEY
, status INTEGER NOT NULL DEFAULT 0
, url TEXT UNIQUE NOT NULL
, filename TEXT
, title TEXT
, length INTEGER
, filesize INTEGER
, metadata TEXT
, metadataTime TIMESTAMP
, errorMessage TEXT
CHECK (status >= 0 AND status <= 3)
);
CREATE TABLE IF NOT EXISTS playlist (
id INTEGER PRIMARY KEY
, media INTEGER NOT NULL
, queueTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
, FOREIGN KEY (media) REFERENCES media
);
CREATE TABLE IF NOT EXISTS history (
id INTEGER PRIMARY KEY
, media INTEGER NOT NULL
, queueTime TIMESTAMP NOT NULL
, startTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
, skipCount INTEGER NOT NULL DEFAULT 0
, skipsNeeded INTEGER NOT NULL DEFAULT 0
, endTime TIMESTAMP
, finishReason INTEGER
, FOREIGN KEY (media) REFERENCES media
CHECK (finishReason >= 0 AND finishReason <= 1)
);