· 8 years ago · Mar 15, 2018, 02:56 AM
1CREATE TABLE IF NOT EXISTS account (
2 id integer PRIMARY KEY AUTOINCREMENT,
3 username text COLLATE NOCASE NOT NULL,
4 service text NOT NULL,
5 name text COLLATE NOCASE,
6 name_update_date integer
7);
8
9CREATE INDEX IF NOT EXISTS username_index ON account (username);
10
11CREATE TABLE IF NOT EXISTS chat (
12 id integer PRIMARY KEY AUTOINCREMENT,
13 path text UNIQUE NOT NULL,
14 creation_date integer,
15 modification_date integer,
16 fts_docid integer UNIQUE,
17 account_id integer,
18 chat_type integer,
19 group_chat_name text COLLATE NOCASE
20);
21
22CREATE INDEX IF NOT EXISTS account_id_modification_date_index ON chat (account_id, modification_date);
23
24CREATE INDEX IF NOT EXISTS group_chat_name_index ON chat (group_chat_name);
25
26CREATE INDEX IF NOT EXISTS chat_type_index ON chat (chat_type);
27
28CREATE INDEX IF NOT EXISTS account_id_index ON chat (account_id);
29
30CREATE INDEX IF NOT EXISTS modification_date_index ON chat (modification_date);
31
32CREATE INDEX IF NOT EXISTS creation_date_index ON chat (creation_date);
33
34CREATE VIRTUAL TABLE IF NOT EXISTS chat_content (
35 content
36) USING fts4();
37
38CREATE TABLE IF NOT EXISTS chat_content_content (
39 docid integer PRIMARY KEY,
40 c0content
41);
42
43CREATE TABLE IF NOT EXISTS chat_content_docsize (
44 docid integer PRIMARY KEY,
45 size blob
46);
47
48CREATE TABLE IF NOT EXISTS chat_content_segdir (
49 level integer,
50 idx integer,
51 start_block integer,
52 leaves_end_block integer,
53 end_block integer,
54 root blob,
55 PRIMARY KEY(level, idx)
56);
57
58CREATE TABLE IF NOT EXISTS chat_content_segments (
59 blockid integer PRIMARY KEY,
60 block blob
61);
62
63CREATE TABLE IF NOT EXISTS chat_content_stat (
64 id integer PRIMARY KEY,
65 value blob
66);
67
68CREATE TABLE IF NOT EXISTS groupchat_account (
69 chat_id integer,
70 account_id integer
71);
72
73CREATE INDEX IF NOT EXISTS groupchat_account_id_index ON groupchat_account (account_id);
74
75CREATE INDEX IF NOT EXISTS groupchat_chat_id_index ON groupchat_account (chat_id);
76
77CREATE TABLE IF NOT EXISTS metadata (
78 "key" text UNIQUE NOT NULL,
79 value integer
80);