commit | author | age
|
e019f2
|
1 |
-- Roundcube Webmail initial database structure |
798ad5
|
2 |
|
977a29
|
3 |
-- |
T |
4 |
-- Sequence "user_ids" |
|
5 |
-- Name: user_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
|
6 |
-- |
|
7 |
|
|
8 |
CREATE SEQUENCE user_ids |
|
9 |
INCREMENT BY 1 |
|
10 |
NO MAXVALUE |
|
11 |
NO MINVALUE |
|
12 |
CACHE 1; |
|
13 |
|
f5dc2a
|
14 |
-- |
1cded8
|
15 |
-- Table "users" |
f5dc2a
|
16 |
-- Name: users; Type: TABLE; Schema: public; Owner: postgres |
S |
17 |
-- |
|
18 |
|
|
19 |
CREATE TABLE users ( |
15a9d1
|
20 |
user_id integer DEFAULT nextval('user_ids'::text) PRIMARY KEY, |
22d6b5
|
21 |
username varchar(128) DEFAULT '' NOT NULL, |
A |
22 |
mail_host varchar(128) DEFAULT '' NOT NULL, |
f5dc2a
|
23 |
created timestamp with time zone DEFAULT now() NOT NULL, |
e2402e
|
24 |
last_login timestamp with time zone DEFAULT NULL, |
22d6b5
|
25 |
"language" varchar(5), |
ace511
|
26 |
preferences text DEFAULT ''::text NOT NULL, |
8381ec
|
27 |
CONSTRAINT users_username_key UNIQUE (username, mail_host) |
f5dc2a
|
28 |
); |
S |
29 |
|
|
30 |
|
|
31 |
-- |
1cded8
|
32 |
-- Table "session" |
T |
33 |
-- Name: session; Type: TABLE; Schema: public; Owner: postgres |
|
34 |
-- |
|
35 |
|
|
36 |
CREATE TABLE "session" ( |
b8ae0e
|
37 |
sess_id varchar(128) DEFAULT '' PRIMARY KEY, |
1cded8
|
38 |
created timestamp with time zone DEFAULT now() NOT NULL, |
T |
39 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
22d6b5
|
40 |
ip varchar(41) NOT NULL, |
1cded8
|
41 |
vars text NOT NULL |
T |
42 |
); |
|
43 |
|
3e48d2
|
44 |
CREATE INDEX session_changed_idx ON session (changed); |
1cded8
|
45 |
|
b59474
|
46 |
|
T |
47 |
-- |
|
48 |
-- Sequence "identity_ids" |
|
49 |
-- Name: identity_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
|
50 |
-- |
|
51 |
|
|
52 |
CREATE SEQUENCE identity_ids |
|
53 |
START WITH 1 |
|
54 |
INCREMENT BY 1 |
|
55 |
NO MAXVALUE |
|
56 |
NO MINVALUE |
|
57 |
CACHE 1; |
1cded8
|
58 |
|
T |
59 |
-- |
|
60 |
-- Table "identities" |
|
61 |
-- Name: identities; Type: TABLE; Schema: public; Owner: postgres |
|
62 |
-- |
|
63 |
|
|
64 |
CREATE TABLE identities ( |
15a9d1
|
65 |
identity_id integer DEFAULT nextval('identity_ids'::text) PRIMARY KEY, |
22d6b5
|
66 |
user_id integer NOT NULL |
80152b
|
67 |
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
a35062
|
68 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
a493ea
|
69 |
del smallint DEFAULT 0 NOT NULL, |
A |
70 |
standard smallint DEFAULT 0 NOT NULL, |
22d6b5
|
71 |
name varchar(128) NOT NULL, |
A |
72 |
organization varchar(128), |
|
73 |
email varchar(128) NOT NULL, |
|
74 |
"reply-to" varchar(128), |
|
75 |
bcc varchar(128), |
a0109c
|
76 |
signature text, |
S |
77 |
html_signature integer DEFAULT 0 NOT NULL |
1cded8
|
78 |
); |
T |
79 |
|
94fe9c
|
80 |
CREATE INDEX identities_user_id_idx ON identities (user_id, del); |
565c47
|
81 |
CREATE INDEX identities_email_idx ON identities (email, del); |
b59474
|
82 |
|
T |
83 |
|
|
84 |
-- |
|
85 |
-- Sequence "contact_ids" |
|
86 |
-- Name: contact_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
|
87 |
-- |
|
88 |
|
|
89 |
CREATE SEQUENCE contact_ids |
|
90 |
START WITH 1 |
|
91 |
INCREMENT BY 1 |
|
92 |
NO MAXVALUE |
|
93 |
NO MINVALUE |
|
94 |
CACHE 1; |
1cded8
|
95 |
|
T |
96 |
-- |
|
97 |
-- Table "contacts" |
|
98 |
-- Name: contacts; Type: TABLE; Schema: public; Owner: postgres |
|
99 |
-- |
|
100 |
|
|
101 |
CREATE TABLE contacts ( |
15a9d1
|
102 |
contact_id integer DEFAULT nextval('contact_ids'::text) PRIMARY KEY, |
22d6b5
|
103 |
user_id integer NOT NULL |
3e2637
|
104 |
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
1cded8
|
105 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
a493ea
|
106 |
del smallint DEFAULT 0 NOT NULL, |
22d6b5
|
107 |
name varchar(128) DEFAULT '' NOT NULL, |
48be8f
|
108 |
email text DEFAULT '' NOT NULL, |
22d6b5
|
109 |
firstname varchar(128) DEFAULT '' NOT NULL, |
A |
110 |
surname varchar(128) DEFAULT '' NOT NULL, |
3e2637
|
111 |
vcard text, |
T |
112 |
words text |
1cded8
|
113 |
); |
T |
114 |
|
48be8f
|
115 |
CREATE INDEX contacts_user_id_idx ON contacts (user_id, del); |
22d6b5
|
116 |
|
A |
117 |
-- |
|
118 |
-- Sequence "contactgroups_ids" |
|
119 |
-- Name: contactgroups_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
|
120 |
-- |
|
121 |
|
|
122 |
CREATE SEQUENCE contactgroups_ids |
|
123 |
INCREMENT BY 1 |
|
124 |
NO MAXVALUE |
|
125 |
NO MINVALUE |
|
126 |
CACHE 1; |
|
127 |
|
|
128 |
-- |
|
129 |
-- Table "contactgroups" |
|
130 |
-- Name: contactgroups; Type: TABLE; Schema: public; Owner: postgres |
|
131 |
-- |
|
132 |
|
|
133 |
CREATE TABLE contactgroups ( |
|
134 |
contactgroup_id integer DEFAULT nextval('contactgroups_ids'::text) PRIMARY KEY, |
|
135 |
user_id integer NOT NULL |
|
136 |
REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
|
137 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
|
138 |
del smallint NOT NULL DEFAULT 0, |
|
139 |
name varchar(128) NOT NULL DEFAULT '' |
|
140 |
); |
|
141 |
|
|
142 |
CREATE INDEX contactgroups_user_id_idx ON contactgroups (user_id, del); |
|
143 |
|
|
144 |
-- |
|
145 |
-- Table "contactgroupmembers" |
|
146 |
-- Name: contactgroupmembers; Type: TABLE; Schema: public; Owner: postgres |
|
147 |
-- |
ace511
|
148 |
|
22d6b5
|
149 |
CREATE TABLE contactgroupmembers ( |
A |
150 |
contactgroup_id integer NOT NULL |
|
151 |
REFERENCES contactgroups(contactgroup_id) ON DELETE CASCADE ON UPDATE CASCADE, |
|
152 |
contact_id integer NOT NULL |
|
153 |
REFERENCES contacts(contact_id) ON DELETE CASCADE ON UPDATE CASCADE, |
|
154 |
created timestamp with time zone DEFAULT now() NOT NULL, |
|
155 |
PRIMARY KEY (contactgroup_id, contact_id) |
|
156 |
); |
1cded8
|
157 |
|
3a5476
|
158 |
CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id); |
A |
159 |
|
1cded8
|
160 |
-- |
T |
161 |
-- Table "cache" |
|
162 |
-- Name: cache; Type: TABLE; Schema: public; Owner: postgres |
|
163 |
-- |
|
164 |
|
|
165 |
CREATE TABLE "cache" ( |
22d6b5
|
166 |
user_id integer NOT NULL |
80152b
|
167 |
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
22d6b5
|
168 |
cache_key varchar(128) DEFAULT '' NOT NULL, |
1cded8
|
169 |
created timestamp with time zone DEFAULT now() NOT NULL, |
T |
170 |
data text NOT NULL |
|
171 |
); |
|
172 |
|
edc63c
|
173 |
CREATE INDEX cache_user_id_idx ON "cache" (user_id, cache_key); |
e4d9f0
|
174 |
CREATE INDEX cache_created_idx ON "cache" (created); |
1cded8
|
175 |
|
T |
176 |
-- |
80152b
|
177 |
-- Table "cache_index" |
A |
178 |
-- Name: cache_index; Type: TABLE; Schema: public; Owner: postgres |
b59474
|
179 |
-- |
T |
180 |
|
80152b
|
181 |
CREATE TABLE cache_index ( |
22d6b5
|
182 |
user_id integer NOT NULL |
80152b
|
183 |
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
A |
184 |
mailbox varchar(255) NOT NULL, |
|
185 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
609d39
|
186 |
valid smallint NOT NULL DEFAULT 0, |
80152b
|
187 |
data text NOT NULL, |
A |
188 |
PRIMARY KEY (user_id, mailbox) |
1cded8
|
189 |
); |
T |
190 |
|
80152b
|
191 |
CREATE INDEX cache_index_changed_idx ON cache_index (changed); |
A |
192 |
|
|
193 |
-- |
|
194 |
-- Table "cache_thread" |
|
195 |
-- Name: cache_thread; Type: TABLE; Schema: public; Owner: postgres |
|
196 |
-- |
|
197 |
|
|
198 |
CREATE TABLE cache_thread ( |
|
199 |
user_id integer NOT NULL |
|
200 |
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
|
201 |
mailbox varchar(255) NOT NULL, |
|
202 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
|
203 |
data text NOT NULL, |
|
204 |
PRIMARY KEY (user_id, mailbox) |
|
205 |
); |
|
206 |
|
|
207 |
CREATE INDEX cache_thread_changed_idx ON cache_thread (changed); |
|
208 |
|
|
209 |
-- |
|
210 |
-- Table "cache_messages" |
|
211 |
-- Name: cache_messages; Type: TABLE; Schema: public; Owner: postgres |
|
212 |
-- |
|
213 |
|
|
214 |
CREATE TABLE cache_messages ( |
|
215 |
user_id integer NOT NULL |
|
216 |
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
|
217 |
mailbox varchar(255) NOT NULL, |
|
218 |
uid integer NOT NULL, |
|
219 |
changed timestamp with time zone DEFAULT now() NOT NULL, |
|
220 |
data text NOT NULL, |
609d39
|
221 |
flags integer NOT NULL DEFAULT 0, |
80152b
|
222 |
PRIMARY KEY (user_id, mailbox, uid) |
A |
223 |
); |
|
224 |
|
|
225 |
CREATE INDEX cache_messages_changed_idx ON cache_messages (changed); |
66df08
|
226 |
|
A |
227 |
-- |
|
228 |
-- Table "dictionary" |
|
229 |
-- Name: dictionary; Type: TABLE; Schema: public; Owner: postgres |
|
230 |
-- |
|
231 |
|
|
232 |
CREATE TABLE dictionary ( |
|
233 |
user_id integer DEFAULT NULL |
|
234 |
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
|
235 |
"language" varchar(5) NOT NULL, |
|
236 |
data text NOT NULL, |
|
237 |
CONSTRAINT dictionary_user_id_language_key UNIQUE (user_id, "language") |
|
238 |
); |
f8e48d
|
239 |
|
A |
240 |
-- |
|
241 |
-- Sequence "searches_ids" |
|
242 |
-- Name: searches_ids; Type: SEQUENCE; Schema: public; Owner: postgres |
|
243 |
-- |
|
244 |
|
|
245 |
CREATE SEQUENCE search_ids |
|
246 |
INCREMENT BY 1 |
|
247 |
NO MAXVALUE |
|
248 |
NO MINVALUE |
|
249 |
CACHE 1; |
|
250 |
|
|
251 |
-- |
|
252 |
-- Table "searches" |
|
253 |
-- Name: searches; Type: TABLE; Schema: public; Owner: postgres |
|
254 |
-- |
|
255 |
|
|
256 |
CREATE TABLE searches ( |
|
257 |
search_id integer DEFAULT nextval('search_ids'::text) PRIMARY KEY, |
|
258 |
user_id integer NOT NULL |
|
259 |
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE, |
|
260 |
"type" smallint DEFAULT 0 NOT NULL, |
|
261 |
name varchar(128) NOT NULL, |
|
262 |
data text NOT NULL, |
|
263 |
CONSTRAINT searches_user_id_key UNIQUE (user_id, "type", name) |
|
264 |
); |
b7e7c8
|
265 |
|
AM |
266 |
|
|
267 |
-- |
|
268 |
-- Table "system" |
|
269 |
-- Name: system; Type: TABLE; Schema: public; Owner: postgres |
|
270 |
-- |
|
271 |
|
|
272 |
CREATE TABLE "system" ( |
|
273 |
name varchar(64) NOT NULL PRIMARY KEY, |
|
274 |
value text |
|
275 |
); |
|
276 |
|
0ffb1a
|
277 |
INSERT INTO system (name, value) VALUES ('roundcube-version', '2013011700'); |