-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
63 lines (55 loc) · 2.09 KB
/
schema.sql
File metadata and controls
63 lines (55 loc) · 2.09 KB
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
-- SPDX-License-Identifier: AGPL-3.0-only
-- ChatGPT Browser - https://github.com/actuallyrizzn/chatGPT-browser
-- Single source of truth for schema. Executed by app.init_db(). conversations.id is TEXT.
CREATE TABLE IF NOT EXISTS conversations (
id TEXT PRIMARY KEY,
create_time TEXT,
update_time TEXT,
title TEXT
);
CREATE TABLE IF NOT EXISTS messages (
id TEXT PRIMARY KEY,
conversation_id TEXT,
role TEXT,
content TEXT,
create_time TEXT,
update_time TEXT,
parent_id TEXT,
FOREIGN KEY (conversation_id) REFERENCES conversations(id)
);
CREATE TABLE IF NOT EXISTS message_metadata (
message_id TEXT PRIMARY KEY,
message_type TEXT,
model_slug TEXT,
citations TEXT,
content_references TEXT,
finish_details TEXT,
is_complete BOOLEAN,
request_id TEXT,
timestamp_ TEXT,
message_source TEXT,
serialization_metadata TEXT,
FOREIGN KEY (message_id) REFERENCES messages(id)
);
CREATE TABLE IF NOT EXISTS message_children (
parent_id TEXT,
child_id TEXT,
PRIMARY KEY (parent_id, child_id),
FOREIGN KEY (parent_id) REFERENCES messages(id),
FOREIGN KEY (child_id) REFERENCES messages(id)
);
CREATE INDEX IF NOT EXISTS idx_conversations_update_time ON conversations(update_time);
CREATE INDEX IF NOT EXISTS idx_messages_conversation_id ON messages(conversation_id);
CREATE INDEX IF NOT EXISTS idx_messages_parent_id ON messages(parent_id);
CREATE INDEX IF NOT EXISTS idx_message_children_parent_id ON message_children(parent_id);
CREATE INDEX IF NOT EXISTS idx_message_children_child_id ON message_children(child_id);
CREATE TABLE IF NOT EXISTS settings (
key TEXT PRIMARY KEY,
value TEXT
);
INSERT OR IGNORE INTO settings (key, value) VALUES ('user_name', 'User');
INSERT OR IGNORE INTO settings (key, value) VALUES ('assistant_name', 'Assistant');
INSERT OR IGNORE INTO settings (key, value) VALUES ('dev_mode', 'false');
INSERT OR IGNORE INTO settings (key, value) VALUES ('dark_mode', 'false');
INSERT OR IGNORE INTO settings (key, value) VALUES ('verbose_mode', 'false');
DELETE FROM settings WHERE key = 'nice_mode';