aboutsummaryrefslogtreecommitdiff
path: root/schema.sql
blob: 5faeb741945b56887a8069cdfefbee887315addd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
CREATE TABLE accounts (
	id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
	username TEXT,
	password TEXT
);

CREATE TABLE mailboxes (
	id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
	account INTEGER NOT NULL,
	FOREIGN KEY(account) REFERENCES accounts(id),
	name TEXT,
	UNIQUE(account, name)
);

CREATE TABLE mail (
	id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
	mailbox INTEGER NOT NULL,
	FOREIGN KEY(mailbox) REFERENCES mailboxes(id),
	data bytea
);