Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 279 lines (229 sloc) 7.593 kB
e019f2d @alecpl - s/RoundCube/Roundcube/
alecpl authored
1 -- Roundcube Webmail initial database structure
798ad5e @alecpl - remove version number from *.initial.sql
alecpl authored
2
977a295 @thomascube Usage of virtusertable; mail_domain for new users; Chinese and Turkis…
thomascube authored
3 --
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
f5dc2a4 more changes to reflect postgres support
svncommit authored
14 --
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
15 -- Table "users"
16 -- Name: users; Type: TABLE; Schema: public; Owner: postgres
f5dc2a4 more changes to reflect postgres support
svncommit authored
17 --
18
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
19 CREATE TABLE users (
15a9d1c @thomascube Optimized loading time; added periodic mail check; added EXPUNGE command
thomascube authored
20 user_id integer DEFAULT nextval('user_ids'::text) PRIMARY KEY,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
21 username varchar(128) DEFAULT '' NOT NULL,
22 mail_host varchar(128) DEFAULT '' NOT NULL,
23 alias varchar(128) DEFAULT '' NOT NULL,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
24 created timestamp with time zone DEFAULT now() NOT NULL,
e2402ef @alecpl - Set DEFAULT NULL for users.last_login
alecpl authored
25 last_login timestamp with time zone DEFAULT NULL,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
26 "language" varchar(5),
ace511a @alecpl - Add unique index on users.username+users.mail_host
alecpl authored
27 preferences text DEFAULT ''::text NOT NULL,
8381ec1 @alecpl - Force names of unique constraints in PostgreSQL DDL (postgres 9.x u…
alecpl authored
28 CONSTRAINT users_username_key UNIQUE (username, mail_host)
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
29 );
f5dc2a4 more changes to reflect postgres support
svncommit authored
30
6cb7786 @alecpl #1484854
alecpl authored
31 CREATE INDEX users_alias_id_idx ON users (alias);
f5dc2a4 more changes to reflect postgres support
svncommit authored
32
b594741 @thomascube Add created date to message cache
thomascube authored
33
f5dc2a4 more changes to reflect postgres support
svncommit authored
34 --
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
35 -- Table "session"
36 -- Name: session; Type: TABLE; Schema: public; Owner: postgres
f5dc2a4 more changes to reflect postgres support
svncommit authored
37 --
38
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
39 CREATE TABLE "session" (
b8ae0ec @alecpl - Fixed bug where session ID's length was limited to 40 characters. S…
alecpl authored
40 sess_id varchar(128) DEFAULT '' PRIMARY KEY,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
41 created timestamp with time zone DEFAULT now() NOT NULL,
42 changed timestamp with time zone DEFAULT now() NOT NULL,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
43 ip varchar(41) NOT NULL,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
44 vars text NOT NULL
45 );
f5dc2a4 more changes to reflect postgres support
svncommit authored
46
3e48d2e @alecpl - Increase speed of session destroy and garbage clean up
alecpl authored
47 CREATE INDEX session_changed_idx ON session (changed);
f5dc2a4 more changes to reflect postgres support
svncommit authored
48
49
50 --
b594741 @thomascube Add created date to message cache
thomascube authored
51 -- Sequence "identity_ids"
52 -- Name: identity_ids; Type: SEQUENCE; Schema: public; Owner: postgres
53 --
54
55 CREATE SEQUENCE identity_ids
56 START WITH 1
57 INCREMENT BY 1
58 NO MAXVALUE
59 NO MINVALUE
60 CACHE 1;
61
62 --
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
63 -- Table "identities"
64 -- Name: identities; Type: TABLE; Schema: public; Owner: postgres
f5dc2a4 more changes to reflect postgres support
svncommit authored
65 --
66
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
67 CREATE TABLE identities (
15a9d1c @thomascube Optimized loading time; added periodic mail check; added EXPUNGE command
thomascube authored
68 identity_id integer DEFAULT nextval('identity_ids'::text) PRIMARY KEY,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
69 user_id integer NOT NULL
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
70 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
a35062a @thomascube Always set changed date when marking a DB record as deleted + provide…
thomascube authored
71 changed timestamp with time zone DEFAULT now() NOT NULL,
a493ea8 @alecpl - change few "boolean" columns type from integer to smallint
alecpl authored
72 del smallint DEFAULT 0 NOT NULL,
73 standard smallint DEFAULT 0 NOT NULL,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
74 name varchar(128) NOT NULL,
75 organization varchar(128),
76 email varchar(128) NOT NULL,
77 "reply-to" varchar(128),
78 bcc varchar(128),
a0109c4 Initial TinyMCE editor support (still need to work on spellcheck and …
svncommit authored
79 signature text,
80 html_signature integer DEFAULT 0 NOT NULL
f5dc2a4 more changes to reflect postgres support
svncommit authored
81 );
82
94fe9ca @alecpl - re-fix (#1486474) + require MySQL 4.0.8 + add index/update in ident…
alecpl authored
83 CREATE INDEX identities_user_id_idx ON identities (user_id, del);
f5dc2a4 more changes to reflect postgres support
svncommit authored
84
b594741 @thomascube Add created date to message cache
thomascube authored
85
86 --
87 -- Sequence "contact_ids"
88 -- Name: contact_ids; Type: SEQUENCE; Schema: public; Owner: postgres
89 --
90
91 CREATE SEQUENCE contact_ids
92 START WITH 1
93 INCREMENT BY 1
94 NO MAXVALUE
95 NO MINVALUE
96 CACHE 1;
97
f5dc2a4 more changes to reflect postgres support
svncommit authored
98 --
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
99 -- Table "contacts"
f5dc2a4 more changes to reflect postgres support
svncommit authored
100 -- Name: contacts; Type: TABLE; Schema: public; Owner: postgres
101 --
102
103 CREATE TABLE contacts (
15a9d1c @thomascube Optimized loading time; added periodic mail check; added EXPUNGE command
thomascube authored
104 contact_id integer DEFAULT nextval('contact_ids'::text) PRIMARY KEY,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
105 user_id integer NOT NULL
3e26373 @thomascube Fulltext search over contact fields. Attention: DATABASE SCHEMA CHANG…
thomascube authored
106 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
107 changed timestamp with time zone DEFAULT now() NOT NULL,
a493ea8 @alecpl - change few "boolean" columns type from integer to smallint
alecpl authored
108 del smallint DEFAULT 0 NOT NULL,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
109 name varchar(128) DEFAULT '' NOT NULL,
6f09681 @alecpl - Support contact's email addresses up to 255 characters long (#1487095)
alecpl authored
110 email varchar(255) DEFAULT '' NOT NULL,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
111 firstname varchar(128) DEFAULT '' NOT NULL,
112 surname varchar(128) DEFAULT '' NOT NULL,
3e26373 @thomascube Fulltext search over contact fields. Attention: DATABASE SCHEMA CHANG…
thomascube authored
113 vcard text,
114 words text
f5dc2a4 more changes to reflect postgres support
svncommit authored
115 );
116
23b7656 @alecpl - use better index for contacts table
alecpl authored
117 CREATE INDEX contacts_user_id_idx ON contacts (user_id, email);
f5dc2a4 more changes to reflect postgres support
svncommit authored
118
119 --
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
120 -- Sequence "contactgroups_ids"
121 -- Name: contactgroups_ids; Type: SEQUENCE; Schema: public; Owner: postgres
122 --
123
124 CREATE SEQUENCE contactgroups_ids
125 INCREMENT BY 1
126 NO MAXVALUE
127 NO MINVALUE
128 CACHE 1;
129
130 --
131 -- Table "contactgroups"
132 -- Name: contactgroups; Type: TABLE; Schema: public; Owner: postgres
133 --
134
135 CREATE TABLE contactgroups (
136 contactgroup_id integer DEFAULT nextval('contactgroups_ids'::text) PRIMARY KEY,
137 user_id integer NOT NULL
138 REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE,
139 changed timestamp with time zone DEFAULT now() NOT NULL,
140 del smallint NOT NULL DEFAULT 0,
141 name varchar(128) NOT NULL DEFAULT ''
142 );
143
144 CREATE INDEX contactgroups_user_id_idx ON contactgroups (user_id, del);
145
146 --
147 -- Table "contactgroupmembers"
148 -- Name: contactgroupmembers; Type: TABLE; Schema: public; Owner: postgres
149 --
ace511a @alecpl - Add unique index on users.username+users.mail_host
alecpl authored
150
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
151 CREATE TABLE contactgroupmembers (
152 contactgroup_id integer NOT NULL
153 REFERENCES contactgroups(contactgroup_id) ON DELETE CASCADE ON UPDATE CASCADE,
154 contact_id integer NOT NULL
155 REFERENCES contacts(contact_id) ON DELETE CASCADE ON UPDATE CASCADE,
156 created timestamp with time zone DEFAULT now() NOT NULL,
157 PRIMARY KEY (contactgroup_id, contact_id)
158 );
159
3a5476d @alecpl - Add index on contactgroupmembers.contact_id column.
alecpl authored
160 CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id);
161
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
162 --
b594741 @thomascube Add created date to message cache
thomascube authored
163 -- Sequence "cache_ids"
164 -- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres
165 --
166
167 CREATE SEQUENCE cache_ids
168 INCREMENT BY 1
169 NO MAXVALUE
170 NO MINVALUE
171 CACHE 1;
172
173 --
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
174 -- Table "cache"
175 -- Name: cache; Type: TABLE; Schema: public; Owner: postgres
f5dc2a4 more changes to reflect postgres support
svncommit authored
176 --
177
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
178 CREATE TABLE "cache" (
15a9d1c @thomascube Optimized loading time; added periodic mail check; added EXPUNGE command
thomascube authored
179 cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
180 user_id integer NOT NULL
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
181 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
182 cache_key varchar(128) DEFAULT '' NOT NULL,
f5dc2a4 more changes to reflect postgres support
svncommit authored
183 created timestamp with time zone DEFAULT now() NOT NULL,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
184 data text NOT NULL
f5dc2a4 more changes to reflect postgres support
svncommit authored
185 );
186
edc63c2 @alecpl fix: there's no ALTER TABLE ... ADD INDEX in postgresql
alecpl authored
187 CREATE INDEX cache_user_id_idx ON "cache" (user_id, cache_key);
e4d9f05 @alecpl - Added index on cache.created + small fixes in mssql DDL script
alecpl authored
188 CREATE INDEX cache_created_idx ON "cache" (created);
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Pos…
thomascube authored
189
f5dc2a4 more changes to reflect postgres support
svncommit authored
190 --
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
191 -- Table "cache_index"
192 -- Name: cache_index; Type: TABLE; Schema: public; Owner: postgres
b594741 @thomascube Add created date to message cache
thomascube authored
193 --
194
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
195 CREATE TABLE cache_index (
196 user_id integer NOT NULL
197 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
198 mailbox varchar(255) NOT NULL,
199 changed timestamp with time zone DEFAULT now() NOT NULL,
609d392 @alecpl - Cache synchronization using QRESYNC/CONDSTORE
alecpl authored
200 valid smallint NOT NULL DEFAULT 0,
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
201 data text NOT NULL,
202 PRIMARY KEY (user_id, mailbox)
203 );
204
205 CREATE INDEX cache_index_changed_idx ON cache_index (changed);
b594741 @thomascube Add created date to message cache
thomascube authored
206
207 --
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
208 -- Table "cache_thread"
209 -- Name: cache_thread; Type: TABLE; Schema: public; Owner: postgres
f5dc2a4 more changes to reflect postgres support
svncommit authored
210 --
211
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
212 CREATE TABLE cache_thread (
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
213 user_id integer NOT NULL
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
214 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
215 mailbox varchar(255) NOT NULL,
216 changed timestamp with time zone DEFAULT now() NOT NULL,
217 data text NOT NULL,
218 PRIMARY KEY (user_id, mailbox)
219 );
220
221 CREATE INDEX cache_thread_changed_idx ON cache_thread (changed);
222
223 --
224 -- Table "cache_messages"
225 -- Name: cache_messages; Type: TABLE; Schema: public; Owner: postgres
226 --
227
228 CREATE TABLE cache_messages (
229 user_id integer NOT NULL
230 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
231 mailbox varchar(255) NOT NULL,
232 uid integer NOT NULL,
233 changed timestamp with time zone DEFAULT now() NOT NULL,
234 data text NOT NULL,
609d392 @alecpl - Cache synchronization using QRESYNC/CONDSTORE
alecpl authored
235 flags integer NOT NULL DEFAULT 0,
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
236 PRIMARY KEY (user_id, mailbox, uid)
f5dc2a4 more changes to reflect postgres support
svncommit authored
237 );
238
80152b3 @alecpl - Rewritten messages caching (merged devel-mcache branch):
alecpl authored
239 CREATE INDEX cache_messages_changed_idx ON cache_messages (changed);
66df084 @alecpl - Merge devel-spellcheck branch:
alecpl authored
240
241 --
242 -- Table "dictionary"
243 -- Name: dictionary; Type: TABLE; Schema: public; Owner: postgres
244 --
245
246 CREATE TABLE dictionary (
247 user_id integer DEFAULT NULL
248 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
249 "language" varchar(5) NOT NULL,
250 data text NOT NULL,
251 CONSTRAINT dictionary_user_id_language_key UNIQUE (user_id, "language")
252 );
f8e48df @alecpl - Merge devel-saved_search branch (Addressbook Saved Searches)
alecpl authored
253
254 --
255 -- Sequence "searches_ids"
256 -- Name: searches_ids; Type: SEQUENCE; Schema: public; Owner: postgres
257 --
258
259 CREATE SEQUENCE search_ids
260 INCREMENT BY 1
261 NO MAXVALUE
262 NO MINVALUE
263 CACHE 1;
264
265 --
266 -- Table "searches"
267 -- Name: searches; Type: TABLE; Schema: public; Owner: postgres
268 --
269
270 CREATE TABLE searches (
271 search_id integer DEFAULT nextval('search_ids'::text) PRIMARY KEY,
272 user_id integer NOT NULL
273 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
274 "type" smallint DEFAULT 0 NOT NULL,
275 name varchar(128) NOT NULL,
276 data text NOT NULL,
277 CONSTRAINT searches_user_id_key UNIQUE (user_id, "type", name)
278 );
Something went wrong with that request. Please try again.