0
|
1 -- Roundcube Webmail initial database structure
|
|
2
|
|
3 --
|
|
4 -- Sequence "users_seq"
|
|
5 -- Name: users_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
6 --
|
|
7
|
|
8 CREATE SEQUENCE users_seq
|
|
9 INCREMENT BY 1
|
|
10 NO MAXVALUE
|
|
11 NO MINVALUE
|
|
12 CACHE 1;
|
|
13
|
|
14 --
|
|
15 -- Table "users"
|
|
16 -- Name: users; Type: TABLE; Schema: public; Owner: postgres
|
|
17 --
|
|
18
|
|
19 CREATE TABLE users (
|
|
20 user_id integer DEFAULT nextval('users_seq'::text) PRIMARY KEY,
|
|
21 username varchar(128) DEFAULT '' NOT NULL,
|
|
22 mail_host varchar(128) DEFAULT '' NOT NULL,
|
|
23 created timestamp with time zone DEFAULT now() NOT NULL,
|
|
24 last_login timestamp with time zone DEFAULT NULL,
|
|
25 "language" varchar(5),
|
|
26 preferences text DEFAULT ''::text NOT NULL,
|
|
27 CONSTRAINT users_username_key UNIQUE (username, mail_host)
|
|
28 );
|
|
29
|
|
30
|
|
31 --
|
|
32 -- Table "session"
|
|
33 -- Name: session; Type: TABLE; Schema: public; Owner: postgres
|
|
34 --
|
|
35
|
|
36 CREATE TABLE "session" (
|
|
37 sess_id varchar(128) DEFAULT '' PRIMARY KEY,
|
|
38 created timestamp with time zone DEFAULT now() NOT NULL,
|
|
39 changed timestamp with time zone DEFAULT now() NOT NULL,
|
|
40 ip varchar(41) NOT NULL,
|
|
41 vars text NOT NULL
|
|
42 );
|
|
43
|
|
44 CREATE INDEX session_changed_idx ON session (changed);
|
|
45
|
|
46
|
|
47 --
|
|
48 -- Sequence "identities_seq"
|
|
49 -- Name: identities_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
50 --
|
|
51
|
|
52 CREATE SEQUENCE identities_seq
|
|
53 START WITH 1
|
|
54 INCREMENT BY 1
|
|
55 NO MAXVALUE
|
|
56 NO MINVALUE
|
|
57 CACHE 1;
|
|
58
|
|
59 --
|
|
60 -- Table "identities"
|
|
61 -- Name: identities; Type: TABLE; Schema: public; Owner: postgres
|
|
62 --
|
|
63
|
|
64 CREATE TABLE identities (
|
|
65 identity_id integer DEFAULT nextval('identities_seq'::text) PRIMARY KEY,
|
|
66 user_id integer NOT NULL
|
|
67 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
68 changed timestamp with time zone DEFAULT now() NOT NULL,
|
|
69 del smallint DEFAULT 0 NOT NULL,
|
|
70 standard smallint DEFAULT 0 NOT NULL,
|
|
71 name varchar(128) NOT NULL,
|
|
72 organization varchar(128),
|
|
73 email varchar(128) NOT NULL,
|
|
74 "reply-to" varchar(128),
|
|
75 bcc varchar(128),
|
|
76 signature text,
|
|
77 html_signature integer DEFAULT 0 NOT NULL
|
|
78 );
|
|
79
|
|
80 CREATE INDEX identities_user_id_idx ON identities (user_id, del);
|
|
81 CREATE INDEX identities_email_idx ON identities (email, del);
|
|
82
|
|
83
|
|
84 --
|
|
85 -- Sequence "contacts_seq"
|
|
86 -- Name: contacts_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
87 --
|
|
88
|
|
89 CREATE SEQUENCE contacts_seq
|
|
90 START WITH 1
|
|
91 INCREMENT BY 1
|
|
92 NO MAXVALUE
|
|
93 NO MINVALUE
|
|
94 CACHE 1;
|
|
95
|
|
96 --
|
|
97 -- Table "contacts"
|
|
98 -- Name: contacts; Type: TABLE; Schema: public; Owner: postgres
|
|
99 --
|
|
100
|
|
101 CREATE TABLE contacts (
|
|
102 contact_id integer DEFAULT nextval('contacts_seq'::text) PRIMARY KEY,
|
|
103 user_id integer NOT NULL
|
|
104 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
105 changed timestamp with time zone DEFAULT now() NOT NULL,
|
|
106 del smallint DEFAULT 0 NOT NULL,
|
|
107 name varchar(128) DEFAULT '' NOT NULL,
|
|
108 email text DEFAULT '' NOT NULL,
|
|
109 firstname varchar(128) DEFAULT '' NOT NULL,
|
|
110 surname varchar(128) DEFAULT '' NOT NULL,
|
|
111 vcard text,
|
|
112 words text
|
|
113 );
|
|
114
|
|
115 CREATE INDEX contacts_user_id_idx ON contacts (user_id, del);
|
|
116
|
|
117 --
|
|
118 -- Sequence "contactgroups_seq"
|
|
119 -- Name: contactgroups_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
120 --
|
|
121
|
|
122 CREATE SEQUENCE contactgroups_seq
|
|
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_seq'::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 --
|
|
148
|
|
149 CREATE TABLE contactgroupmembers (
|
|
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 );
|
|
157
|
|
158 CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id);
|
|
159
|
|
160 --
|
|
161 -- Table "cache"
|
|
162 -- Name: cache; Type: TABLE; Schema: public; Owner: postgres
|
|
163 --
|
|
164
|
|
165 CREATE TABLE "cache" (
|
|
166 user_id integer NOT NULL
|
|
167 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
168 cache_key varchar(128) DEFAULT '' NOT NULL,
|
|
169 created timestamp with time zone DEFAULT now() NOT NULL,
|
|
170 expires timestamp with time zone DEFAULT NULL,
|
|
171 data text NOT NULL
|
|
172 );
|
|
173
|
|
174 CREATE INDEX cache_user_id_idx ON "cache" (user_id, cache_key);
|
|
175 CREATE INDEX cache_expires_idx ON "cache" (expires);
|
|
176
|
|
177 --
|
|
178 -- Table "cache_shared"
|
|
179 -- Name: cache_shared; Type: TABLE; Schema: public; Owner: postgres
|
|
180 --
|
|
181
|
|
182 CREATE TABLE "cache_shared" (
|
|
183 cache_key varchar(255) NOT NULL,
|
|
184 created timestamp with time zone DEFAULT now() NOT NULL,
|
|
185 expires timestamp with time zone DEFAULT NULL,
|
|
186 data text NOT NULL
|
|
187 );
|
|
188
|
|
189 CREATE INDEX cache_shared_cache_key_idx ON "cache_shared" (cache_key);
|
|
190 CREATE INDEX cache_shared_expires_idx ON "cache_shared" (expires);
|
|
191
|
|
192 --
|
|
193 -- Table "cache_index"
|
|
194 -- Name: cache_index; Type: TABLE; Schema: public; Owner: postgres
|
|
195 --
|
|
196
|
|
197 CREATE TABLE cache_index (
|
|
198 user_id integer NOT NULL
|
|
199 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
200 mailbox varchar(255) NOT NULL,
|
|
201 expires timestamp with time zone DEFAULT NULL,
|
|
202 valid smallint NOT NULL DEFAULT 0,
|
|
203 data text NOT NULL,
|
|
204 PRIMARY KEY (user_id, mailbox)
|
|
205 );
|
|
206
|
|
207 CREATE INDEX cache_index_expires_idx ON cache_index (expires);
|
|
208
|
|
209 --
|
|
210 -- Table "cache_thread"
|
|
211 -- Name: cache_thread; Type: TABLE; Schema: public; Owner: postgres
|
|
212 --
|
|
213
|
|
214 CREATE TABLE cache_thread (
|
|
215 user_id integer NOT NULL
|
|
216 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
217 mailbox varchar(255) NOT NULL,
|
|
218 expires timestamp with time zone DEFAULT NULL,
|
|
219 data text NOT NULL,
|
|
220 PRIMARY KEY (user_id, mailbox)
|
|
221 );
|
|
222
|
|
223 CREATE INDEX cache_thread_expires_idx ON cache_thread (expires);
|
|
224
|
|
225 --
|
|
226 -- Table "cache_messages"
|
|
227 -- Name: cache_messages; Type: TABLE; Schema: public; Owner: postgres
|
|
228 --
|
|
229
|
|
230 CREATE TABLE cache_messages (
|
|
231 user_id integer NOT NULL
|
|
232 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
233 mailbox varchar(255) NOT NULL,
|
|
234 uid integer NOT NULL,
|
|
235 expires timestamp with time zone DEFAULT NULL,
|
|
236 data text NOT NULL,
|
|
237 flags integer NOT NULL DEFAULT 0,
|
|
238 PRIMARY KEY (user_id, mailbox, uid)
|
|
239 );
|
|
240
|
|
241 CREATE INDEX cache_messages_expires_idx ON cache_messages (expires);
|
|
242
|
|
243 --
|
|
244 -- Table "dictionary"
|
|
245 -- Name: dictionary; Type: TABLE; Schema: public; Owner: postgres
|
|
246 --
|
|
247
|
|
248 CREATE TABLE dictionary (
|
|
249 user_id integer DEFAULT NULL
|
|
250 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
251 "language" varchar(5) NOT NULL,
|
|
252 data text NOT NULL,
|
|
253 CONSTRAINT dictionary_user_id_language_key UNIQUE (user_id, "language")
|
|
254 );
|
|
255
|
|
256 --
|
|
257 -- Sequence "searches_seq"
|
|
258 -- Name: searches_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
259 --
|
|
260
|
|
261 CREATE SEQUENCE searches_seq
|
|
262 INCREMENT BY 1
|
|
263 NO MAXVALUE
|
|
264 NO MINVALUE
|
|
265 CACHE 1;
|
|
266
|
|
267 --
|
|
268 -- Table "searches"
|
|
269 -- Name: searches; Type: TABLE; Schema: public; Owner: postgres
|
|
270 --
|
|
271
|
|
272 CREATE TABLE searches (
|
|
273 search_id integer DEFAULT nextval('searches_seq'::text) PRIMARY KEY,
|
|
274 user_id integer NOT NULL
|
|
275 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
|
|
276 "type" smallint DEFAULT 0 NOT NULL,
|
|
277 name varchar(128) NOT NULL,
|
|
278 data text NOT NULL,
|
|
279 CONSTRAINT searches_user_id_key UNIQUE (user_id, "type", name)
|
|
280 );
|
|
281
|
|
282
|
|
283 --
|
|
284 -- Table "system"
|
|
285 -- Name: system; Type: TABLE; Schema: public; Owner: postgres
|
|
286 --
|
|
287
|
|
288 CREATE TABLE "system" (
|
|
289 name varchar(64) NOT NULL PRIMARY KEY,
|
|
290 value text
|
|
291 );
|
|
292
|
|
293 INSERT INTO system (name, value) VALUES ('roundcube-version', '2015030800');
|