-
Notifications
You must be signed in to change notification settings - Fork 35
/
schema_v1.sql
143 lines (106 loc) · 4.55 KB
/
schema_v1.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
-- Initial version of the database schema.
-- See src/dfeed/database.d for updates since this initial revision.
-- Table `Groups`
CREATE TABLE [Groups] (
[Group] VARCHAR(50) NULL,
[ArtNum] INTEGER NULL,
[ID] VARCHAR(50) NULL
, Time INTEGER);
-- Table `Posts`
CREATE TABLE [Posts] (
[ID] VARCHAR(50) NULL,
[Message] TEXT NULL,
[Author] VARCHAR(255) NULL,
[Subject] VARCHAR(255) NULL,
[Time] INTEGER NULL,
[ParentID] VARCHAR(50) NULL,
[ThreadID] VARCHAR(50) NULL
, [AuthorEmail] VARCHAR(50));
-- Table `Threads`
CREATE TABLE [Threads] (
[Group] VARCHAR(50) NULL,
[ID] VARCHAR(50) NULL,
[LastUpdated] INTEGER NULL
, LastPost VARCHAR(50), [Created] INTEGER NULL);
-- Index `PostThreadID` on table `Posts`
CREATE INDEX [PostThreadID] ON [Posts](
[ThreadID] ASC
);
-- Index `ThreadGroup` on table `Threads`
CREATE INDEX [ThreadGroup] ON [Threads] ( [Group] );
-- Index `GroupTime` on table `Groups`
CREATE INDEX GroupTime ON Groups (`Group`, Time DESC);
-- Index `ThreadOrder` on table `Threads`
CREATE INDEX ThreadOrder ON Threads ([Group], [LastUpdated] DESC);
-- Index `GroupID` on table `Groups`
CREATE UNIQUE INDEX [GroupID] ON [Groups](
[Group] ASC,
[ID] ASC
);
-- Index `PostID` on table `Posts`
CREATE UNIQUE INDEX [PostID] ON "Posts"(
[ID] ASC
);
-- Index `ThreadID` on table `Threads`
CREATE INDEX "ThreadID" ON "Threads" ( ID );
-- Index `PostParentID` on table `Posts`
CREATE INDEX PostParentID ON Posts ( ParentID );
-- Table `Users`
CREATE TABLE [Users] ( [Username] VARCHAR(50), [Password] VARCHAR(50), [Session] VARCHAR(50) , [Level] INTEGER NOT NULL DEFAULT 0, [Created] INTEGER);
-- Index `UserName` on table `Users`
CREATE UNIQUE INDEX [UserName] ON [Users] ( [Username] );
-- Table `UserSettings`
CREATE TABLE [UserSettings] ( [User] VARCHAR(50), [Name] VARCHAR(50), [Value] TEXT );
-- Index `UserSetting` on table `UserSettings`
CREATE UNIQUE INDEX [UserSetting] on [UserSettings] ( [User], [Name] );
-- Index `GroupArtNum` on table `Groups`
CREATE INDEX [GroupArtNum] ON [Groups] ( [Group], [ArtNum] );
-- Index `PostTime` on table `Posts`
CREATE INDEX [PostTime] ON [Posts] ( [Time] DESC );
-- Table `Drafts`
CREATE TABLE [Drafts] ([UserID] VARCHAR(20) NOT NULL, [ID] VARCHAR(20) NOT NULL, [PostID] VARCHAR(20) NULL, [Status] INTEGER NOT NULL, [ClientVars] TEXT NOT NULL, [ServerVars] TEXT NULL, [Time] INTEGER NOT NULL);
-- Index `DraftID` on table `Drafts`
CREATE UNIQUE INDEX [DraftID] ON [Drafts] ([ID]);
-- Index `DraftUserID` on table `Drafts`
CREATE INDEX [DraftUserID] ON [Drafts] ([UserID], [Status]);
-- Index `DraftPostID` on table `Drafts`
CREATE UNIQUE INDEX [DraftPostID] ON [Drafts] ([PostID]);
-- Table `Subscriptions`
CREATE TABLE [Subscriptions] (
[ID] VARCHAR(20) NOT NULL PRIMARY KEY,
[Username] VARCHAR(50) NOT NULL,
[Data] TEXT NULL
);
-- Table `ReplyTriggers`
CREATE TABLE [ReplyTriggers] ([Email] VARCHAR(50) NOT NULL, [SubscriptionID] VARCHAR(20) NOT NULL);
-- Index `ReplyTriggerSubscripion` on table `ReplyTriggers`
CREATE UNIQUE INDEX [ReplyTriggerSubscripion] ON [ReplyTriggers] ([SubscriptionID]);
-- Index `ReplyTriggerEmail` on table `ReplyTriggers`
CREATE INDEX [ReplyTriggerEmail] ON [ReplyTriggers] ([Email]);
-- Table `ThreadTriggers`
CREATE TABLE [ThreadTriggers] ([ThreadID] VARCHAR(50) NOT NULL, [SubscriptionID] VARCHAR(20) NOT NULL);
-- Index `ThreadTriggerSubscription` on table `ThreadTriggers`
CREATE UNIQUE INDEX [ThreadTriggerSubscription] ON [ThreadTriggers] ([SubscriptionID]);
-- Index `ThreadTriggerThreadID` on table `ThreadTriggers`
CREATE INDEX [ThreadTriggerThreadID] ON [ThreadTriggers] ([ThreadID]);
-- Table `ContentTriggers`
CREATE TABLE [ContentTriggers] ([SubscriptionID] VARCHAR(20) NOT NULL PRIMARY KEY);
-- Table `SubscriptionPosts`
CREATE TABLE [SubscriptionPosts] (
[SubscriptionID] VARCHAR(20) NOT NULL,
[MessageID] VARCHAR(50) NOT NULL,
[MessageRowID] INTEGER NOT NULL,
[Time] INTEGER NOT NULL
);
-- Index `SubscriptionPostID` on table `SubscriptionPosts`
CREATE INDEX [SubscriptionPostID] ON [SubscriptionPosts] ([SubscriptionID], [Time] DESC);
-- Table `PostSearch`
CREATE VIRTUAL TABLE [PostSearch] USING fts4([Time], [ThreadMD5], [Group], [Author], [AuthorEmail], [Subject], [Content], [NewThread], order=desc);
-- Index `ThreadCreated` on table `Threads`
CREATE INDEX [ThreadCreated] ON [Threads] ([Created] DESC);
-- Index `PostAuthorEmail` on table `Posts`
CREATE INDEX [PostAuthorEmail] ON [Posts] ([AuthorEmail]);
-- Table `Flags`
CREATE TABLE [Flags] ([PostID] VARCHAR(50), [Username] VARCHAR(50), [Date] INTEGER);
-- Index `UserFlags` on table `Flags`
CREATE INDEX [UserFlags] ON [Flags] ([Username], [PostID]);