-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sql
More file actions
80 lines (72 loc) · 2.42 KB
/
setup.sql
File metadata and controls
80 lines (72 loc) · 2.42 KB
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
CREATE DATABASE haraka
WITH OWNER = haraka
ENCODING = 'UTF8';
CREATE TABLE hosts (
id serial NOT NULL,
host text,
CONSTRAINT hosts_pk_id PRIMARY KEY (id) ) WITH (
OIDS=FALSE ); ALTER TABLE hosts
OWNER TO haraka;
CREATE SCHEMA testdomain
AUTHORIZATION haraka;
CREATE TABLE testdomain.alias (
id serial NOT NULL,
name text,
catchall boolean DEFAULT false,
CONSTRAINT alias_pk_id PRIMARY KEY (id) ) WITH (
OIDS=FALSE ); ALTER TABLE testdomain.alias
OWNER TO haraka;
CREATE TABLE testdomain.mailbox (
id serial NOT NULL,
name text,
given_name text,
surname text,
CONSTRAINT mailbox_pk_id PRIMARY KEY (id) ) WITH (
OIDS=FALSE ); ALTER TABLE testdomain.mailbox
OWNER TO haraka;
CREATE TABLE testdomain.message (
id integer NOT NULL DEFAULT nextval('testdomain.messages_id_seq'::regclass),
headers text,
content_type text,
body text,
parts text,
subject text,
"to" text,
"from" text,
CONSTRAINT messages_pk_id PRIMARY KEY (id) ) WITH (
OIDS=FALSE ); ALTER TABLE testdomain.message
OWNER TO haraka;
CREATE TABLE testdomain.attachment (
id serial NOT NULL,
message_id bigint,
filename text,
content_type text,
data text,
CONSTRAINT attachment_pk_id PRIMARY KEY (id),
CONSTRAINT attachment_message_id_fk FOREIGN KEY (message_id)
REFERENCES testdomain.message (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION ) WITH (
OIDS=FALSE ); ALTER TABLE testdomain.attachment
OWNER TO haraka;
CREATE TABLE testdomain.alias_mailbox (
alias_id bigint,
mailbox_id integer,
CONSTRAINT alias_mailbox_alias_fk_id FOREIGN KEY (alias_id)
REFERENCES testdomain.alias (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT alias_mailbox_mailbox_fk_id FOREIGN KEY (mailbox_id)
REFERENCES testdomain.mailbox (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION ) WITH (
OIDS=FALSE ); ALTER TABLE testdomain.alias_mailbox
OWNER TO haraka;
CREATE TABLE testdomain.mailbox_message (
mailbox_id bigint,
message_id bigint,
CONSTRAINT mailbox_message_mailbox_id_fk FOREIGN KEY (mailbox_id)
REFERENCES testdomain.mailbox (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT mailbox_message_message_fk_id FOREIGN KEY (message_id)
REFERENCES testdomain.message (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION ) WITH (
OIDS=FALSE ); ALTER TABLE testdomain.mailbox_message
OWNER TO haraka;