-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsqlite_init.sql
More file actions
33 lines (33 loc) · 796 Bytes
/
sqlite_init.sql
File metadata and controls
33 lines (33 loc) · 796 Bytes
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
CREATE TABLE IF NOT EXISTS messages (
msgid INTEGER PRIMARY KEY,
board TEXT NOT NULL,
time BIGINT NOT NULL,
author TEXT NOT NULL,
msg TEXT NOT NULL,
image TEXT NOT NULL,
latest_submsg BIGINT NOT NULL
);
CREATE TABLE IF NOT EXISTS submessages (
parent_msg BIGINT NOT NULL,
submsg_id BIGINT NOT NULL,
board TEXT NOT NULL,
time BIGINT NOT NULL,
author TEXT NOT NULL,
submsg TEXT NOT NULL,
image TEXT NOT NULL,
CONSTRAINT bind_msg
FOREIGN KEY(parent_msg)
REFERENCES messages(msgid)
ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS flagged_messages (
entry_id INTEGER PRIMARY KEY,
msg_type TEXT NOT NULL,
msgid BIGINT NOT NULL,
submsg_index BIGINT,
UNIQUE(msgid,submsg_index),
CONSTRAINT bind_msg
FOREIGN KEY(msgid)
REFERENCES messages(msgid)
ON DELETE CASCADE
);