commit | author | age
|
f5dc2a
|
1 |
-- |
1cded8
|
2 |
-- Table "users" |
f5dc2a
|
3 |
-- Name: users; Type: TABLE; Schema: public; Owner: postgres |
S |
4 |
-- |
|
5 |
|
|
6 |
CREATE TABLE users ( |
|
7 |
user_id integer DEFAULT nextval('user_ids'::text) NOT NULL, |
|
8 |
username character varying(128) DEFAULT ''::character varying NOT NULL, |
|
9 |
mail_host character varying(128) DEFAULT ''::character varying NOT NULL, |
42b113
|
10 |
alias character varying(128) DEFAULT ''::character varying NOT NULL, |
f5dc2a
|
11 |
created timestamp with time zone DEFAULT now() NOT NULL, |
S |
12 |
last_login timestamp with time zone DEFAULT now() NOT NULL, |
|
13 |
"language" character varying(5) DEFAULT 'en'::character varying NOT NULL, |
|
14 |
preferences text DEFAULT ''::text NOT NULL |
|
15 |
); |
|
16 |
|
|
17 |
|
1cded8
|
18 |
|
f5dc2a
|
19 |
-- |
1cded8
|
20 |
-- Table "session" |
T |
21 |
-- Name: session; Type: TABLE; Schema: public; Owner: postgres |
|
22 |
-- |
|
23 |
|
|
24 |
CREATE TABLE "session" ( |
|
25 |
sess_id character varying(40) DEFAULT ''::character varying NOT NULL, |
|
26 |
created timestamp with time zone DEFAULT now() NOT NULL, |
|
27 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
|
28 |
ip character varying(16) NOT NULL, |
|
29 |
vars text NOT NULL |
|
30 |
); |
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
-- |
|
35 |
-- Table "identities" |
|
36 |
-- Name: identities; Type: TABLE; Schema: public; Owner: postgres |
|
37 |
-- |
|
38 |
|
|
39 |
CREATE TABLE identities ( |
|
40 |
identity_id integer DEFAULT nextval('identity_ids'::text) NOT NULL, |
|
41 |
user_id integer DEFAULT 0 NOT NULL, |
|
42 |
del integer DEFAULT 0 NOT NULL, |
|
43 |
standard integer DEFAULT 0 NOT NULL, |
|
44 |
name character varying(128) NOT NULL, |
|
45 |
organization character varying(128), |
|
46 |
email character varying(128) NOT NULL, |
|
47 |
"reply-to" character varying(128), |
|
48 |
bcc character varying(128), |
|
49 |
signature text |
|
50 |
); |
|
51 |
|
|
52 |
|
|
53 |
-- |
|
54 |
-- Table "contacts" |
|
55 |
-- Name: contacts; Type: TABLE; Schema: public; Owner: postgres |
|
56 |
-- |
|
57 |
|
|
58 |
CREATE TABLE contacts ( |
|
59 |
contact_id integer DEFAULT nextval('contact_ids'::text) NOT NULL, |
|
60 |
user_id integer DEFAULT 0 NOT NULL, |
|
61 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
|
62 |
del integer DEFAULT 0 NOT NULL, |
|
63 |
name character varying(128) DEFAULT ''::character varying NOT NULL, |
|
64 |
email character varying(128) DEFAULT ''::character varying NOT NULL, |
|
65 |
firstname character varying(128) DEFAULT ''::character varying NOT NULL, |
|
66 |
surname character varying(128) DEFAULT ''::character varying NOT NULL, |
|
67 |
vcard text |
|
68 |
); |
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
-- |
|
73 |
-- Table "cache" |
|
74 |
-- Name: cache; Type: TABLE; Schema: public; Owner: postgres |
|
75 |
-- |
|
76 |
|
|
77 |
CREATE TABLE "cache" ( |
|
78 |
cache_id integer DEFAULT nextval('cache_ids'::text) NOT NULL, |
|
79 |
user_id integer DEFAULT 0 NOT NULL, |
|
80 |
session_id character varying(40), |
|
81 |
cache_key character varying(128) DEFAULT ''::character varying NOT NULL, |
|
82 |
created timestamp with time zone DEFAULT now() NOT NULL, |
|
83 |
data text NOT NULL |
|
84 |
); |
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
-- |
|
89 |
-- Table "messages" |
|
90 |
-- Name: messages; Type: TABLE; Schema: public; Owner: postgres |
|
91 |
-- |
|
92 |
|
|
93 |
CREATE TABLE "messages" ( |
|
94 |
message_id integer DEFAULT nextval('message_ids'::text) NOT NULL, |
|
95 |
user_id integer DEFAULT 0 NOT NULL, |
|
96 |
del integer DEFAULT 0 NOT NULL, |
|
97 |
cache_key character varying(128) DEFAULT ''::character varying NOT NULL, |
|
98 |
idx integer DEFAULT 0 NOT NULL, |
|
99 |
uid integer DEFAULT 0 NOT NULL, |
|
100 |
subject character varying(128) DEFAULT ''::character varying NOT NULL, |
|
101 |
"from" character varying(128) DEFAULT ''::character varying NOT NULL, |
|
102 |
"to" character varying(128) DEFAULT ''::character varying NOT NULL, |
|
103 |
cc character varying(128) DEFAULT ''::character varying NOT NULL, |
|
104 |
date timestamp with time zone NOT NULL, |
|
105 |
size integer DEFAULT 0 NOT NULL, |
|
106 |
headers text NOT NULL, |
|
107 |
body text |
|
108 |
); |
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
-- |
|
113 |
-- Add primary keys |
f5dc2a
|
114 |
-- |
S |
115 |
|
|
116 |
ALTER TABLE ONLY "cache" |
|
117 |
ADD CONSTRAINT cache_pkey PRIMARY KEY (cache_id); |
|
118 |
|
|
119 |
|
1cded8
|
120 |
ALTER TABLE ONLY "contacts" |
f5dc2a
|
121 |
ADD CONSTRAINT contacts_pkey PRIMARY KEY (contact_id); |
S |
122 |
|
|
123 |
|
|
124 |
ALTER TABLE ONLY identities |
|
125 |
ADD CONSTRAINT identities_pkey PRIMARY KEY (identity_id); |
|
126 |
|
|
127 |
|
|
128 |
ALTER TABLE ONLY "session" |
|
129 |
ADD CONSTRAINT session_pkey PRIMARY KEY (sess_id); |
|
130 |
|
|
131 |
|
1cded8
|
132 |
ALTER TABLE ONLY "users" |
f5dc2a
|
133 |
ADD CONSTRAINT users_pkey PRIMARY KEY (user_id); |
S |
134 |
|
|
135 |
|
1cded8
|
136 |
ALTER TABLE ONLY "messages" |
T |
137 |
ADD CONSTRAINT messages_pkey PRIMARY KEY (message_id); |
|
138 |
|
|
139 |
|
f5dc2a
|
140 |
-- |
1cded8
|
141 |
-- Reference keys |
f5dc2a
|
142 |
-- |
S |
143 |
|
|
144 |
ALTER TABLE ONLY "cache" |
|
145 |
ADD CONSTRAINT "$1" FOREIGN KEY (user_id) REFERENCES users(user_id); |
|
146 |
|
|
147 |
ALTER TABLE ONLY "cache" |
|
148 |
ADD CONSTRAINT "$2" FOREIGN KEY (session_id) REFERENCES "session"(sess_id); |
|
149 |
|
|
150 |
|
1cded8
|
151 |
ALTER TABLE ONLY "contacts" |
T |
152 |
ADD CONSTRAINT "$1" FOREIGN KEY (user_id) REFERENCES users(user_id); |
f5dc2a
|
153 |
|
1cded8
|
154 |
|
T |
155 |
ALTER TABLE ONLY "identities" |
|
156 |
ADD CONSTRAINT "$1" FOREIGN KEY (user_id) REFERENCES users(user_id); |
|
157 |
|
|
158 |
|
|
159 |
ALTER TABLE ONLY "messages" |
f5dc2a
|
160 |
ADD CONSTRAINT "$1" FOREIGN KEY (user_id) REFERENCES users(user_id); |
S |
161 |
|
|
162 |
|
|
163 |
-- |
1cded8
|
164 |
-- Sequence "cache_ids" |
T |
165 |
-- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
f5dc2a
|
166 |
-- |
S |
167 |
|
1cded8
|
168 |
CREATE SEQUENCE cache_ids |
T |
169 |
INCREMENT BY 1 |
|
170 |
NO MAXVALUE |
|
171 |
NO MINVALUE |
|
172 |
CACHE 1; |
f5dc2a
|
173 |
|
S |
174 |
|
|
175 |
-- |
1cded8
|
176 |
-- Sequence "contact_ids" |
T |
177 |
-- Name: contact_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
f5dc2a
|
178 |
-- |
S |
179 |
|
1cded8
|
180 |
CREATE SEQUENCE contact_ids |
T |
181 |
START WITH 1 |
|
182 |
INCREMENT BY 1 |
|
183 |
NO MAXVALUE |
|
184 |
NO MINVALUE |
|
185 |
CACHE 1; |
f5dc2a
|
186 |
|
S |
187 |
|
|
188 |
-- |
1cded8
|
189 |
-- Sequence "identity_ids" |
T |
190 |
-- Name: identity_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
|
191 |
-- |
|
192 |
|
|
193 |
CREATE SEQUENCE identity_ids |
|
194 |
START WITH 1 |
|
195 |
INCREMENT BY 1 |
|
196 |
NO MAXVALUE |
|
197 |
NO MINVALUE |
|
198 |
CACHE 1; |
|
199 |
|
|
200 |
|
|
201 |
-- |
|
202 |
-- Sequence "user_ids" |
|
203 |
-- Name: user_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
|
204 |
-- |
|
205 |
|
|
206 |
CREATE SEQUENCE user_ids |
|
207 |
INCREMENT BY 1 |
|
208 |
NO MAXVALUE |
|
209 |
NO MINVALUE |
|
210 |
CACHE 1; |
|
211 |
|
|
212 |
|
|
213 |
-- |
|
214 |
-- Sequence "message_ids" |
|
215 |
-- Name: message_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
|
216 |
-- |
|
217 |
|
|
218 |
CREATE SEQUENCE message_ids |
|
219 |
INCREMENT BY 1 |
|
220 |
NO MAXVALUE |
|
221 |
NO MINVALUE |
|
222 |
CACHE 1; |
|
223 |
|