-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
77 lines (77 loc) · 1.89 KB
/
schema.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
66
67
68
69
70
71
72
73
74
75
76
77
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "attachments" (
"id" INTEGER,
"related_message_id" INTEGER,
"file_name" TEXT,
"timestamp" INTEGER,
"extension" TEXT
);
CREATE TABLE IF NOT EXISTS "likes" (
"attachment_id" INTEGER,
"discord_id" INTEGER,
"timestamp" INTEGER
);
CREATE TABLE IF NOT EXISTS "message_likes" (
"message_id" INTEGER,
"discord_id" INTEGER,
"timestamp" INTEGER
);
CREATE TABLE IF NOT EXISTS "messages" (
"message_id" INTEGER,
"type" TEXT,
"timestamp" INTEGER,
"content" TEXT,
"author_id" INTEGER,
"author_name" TEXT,
"author_nickname" TEXT,
"author_discriminator" TEXT,
"author_avatar_url" TEXT,
"attachments" BLOB,
"embeds" BLOB,
"stickers" BLOB,
"reactions" BLOB,
"total_reactions" INTEGER,
"mentions" BLOB,
"channel_id" INTEGER,
"channel_name" TEXT,
"content_length" INTEGER,
PRIMARY KEY("message_id")
);
CREATE TABLE IF NOT EXISTS "users" (
"user_id" INTEGER,
"user_name" TEXT,
"user_nickname" TEXT,
"user_avatar_url" TEXT,
"mentions_received" INTEGER,
"mentions_given" INTEGER,
"reactions_received" INTEGER,
"reactions_given" INTEGER,
"messages_sent" INTEGER,
"attachments_sent" INTEGER,
"attachments_size" INTEGER,
"most_frequent_time" INTEGER,
"most_mentioned_given_name" TEXT,
"most_mentioned_received_name" TEXT,
"most_mentioned_given_id" INTEGER,
"most_mentioned_received_id" INTEGER,
"most_mentioned_given_count" INTEGER,
"most_mentioned_received_count" INTEGER
);
CREATE UNIQUE INDEX IF NOT EXISTS "idx_attachment_id_discord_id" ON "likes" (
"attachment_id",
"discord_id"
);
CREATE UNIQUE INDEX IF NOT EXISTS "idx_attachments_id" ON "attachments" (
"id"
);
CREATE UNIQUE INDEX IF NOT EXISTS "idx_message_id_discord_id" ON "message_likes" (
"message_id",
"discord_id"
);
CREATE INDEX IF NOT EXISTS "idx_messages_content" ON "messages" (
"content"
);
CREATE INDEX IF NOT EXISTS "idx_messages_total_reactions" ON "messages" (
"total_reactions"
);
COMMIT;