-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
41 lines (37 loc) · 893 Bytes
/
schema.sql
File metadata and controls
41 lines (37 loc) · 893 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
34
35
36
37
38
39
40
41
DROP TABLE IF EXISTS attachments;
DROP TABLE IF EXISTS emails;
DROP TABLE IF EXISTS sessions;
CREATE TABLE sessions (
id TEXT PRIMARY KEY,
email TEXT UNIQUE,
token TEXT,
domain TEXT,
created_at INTEGER,
expires_at INTEGER
);
CREATE TABLE emails (
id TEXT PRIMARY KEY,
inbox_email TEXT,
from_address TEXT,
from_name TEXT,
reply_to TEXT,
subject TEXT,
body_text TEXT,
body_html TEXT,
raw_headers TEXT,
received_at INTEGER,
is_read INTEGER DEFAULT 0,
size INTEGER,
FOREIGN KEY(inbox_email) REFERENCES sessions(email) ON DELETE CASCADE
);
CREATE TABLE attachments (
id TEXT PRIMARY KEY,
email_id TEXT,
filename TEXT,
content_type TEXT,
size INTEGER,
kv_key TEXT,
FOREIGN KEY(email_id) REFERENCES emails(id) ON DELETE CASCADE
);
CREATE INDEX idx_sessions_expires ON sessions(expires_at);
CREATE INDEX idx_emails_inbox ON emails(inbox_email);