Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 225 lines (186 sloc) 6.135 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 Turkish l...
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; Postgr...
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; Postgr...
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; Postgr...
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,
28 UNIQUE (username, mail_host)
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
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; Postgr...
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; Postgr...
thomascube authored
39 CREATE TABLE "session" (
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
40 sess_id varchar(40) DEFAULT '' PRIMARY KEY,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
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; Postgr...
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; Postgr...
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; Postgr...
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
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 a ...
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 ski...
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 identiti...
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; Postgr...
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
106 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
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,
110 email varchar(128) DEFAULT '' NOT NULL,
111 firstname varchar(128) DEFAULT '' NOT NULL,
112 surname varchar(128) DEFAULT '' NOT NULL,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
thomascube authored
113 vcard text
f5dc2a4 more changes to reflect postgres support
svncommit authored
114 );
115
23b7656 @alecpl - use better index for contacts table
alecpl authored
116 CREATE INDEX contacts_user_id_idx ON contacts (user_id, email);
f5dc2a4 more changes to reflect postgres support
svncommit authored
117
118 --
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
119 -- Sequence "contactgroups_ids"
120 -- Name: contactgroups_ids; Type: SEQUENCE; Schema: public; Owner: postgres
121 --
122
123 CREATE SEQUENCE contactgroups_ids
124 INCREMENT BY 1
125 NO MAXVALUE
126 NO MINVALUE
127 CACHE 1;
128
129 --
130 -- Table "contactgroups"
131 -- Name: contactgroups; Type: TABLE; Schema: public; Owner: postgres
132 --
133
134 CREATE TABLE contactgroups (
135 contactgroup_id integer DEFAULT nextval('contactgroups_ids'::text) PRIMARY KEY,
136 user_id integer NOT NULL
137 REFERENCES users(user_id) ON DELETE CASCADE ON UPDATE CASCADE,
138 changed timestamp with time zone DEFAULT now() NOT NULL,
139 del smallint NOT NULL DEFAULT 0,
140 name varchar(128) NOT NULL DEFAULT ''
141 );
142
143 CREATE INDEX contactgroups_user_id_idx ON contactgroups (user_id, del);
144
145 --
146 -- Table "contactgroupmembers"
147 -- Name: contactgroupmembers; Type: TABLE; Schema: public; Owner: postgres
148 --
ace511a @alecpl - Add unique index on users.username+users.mail_host
alecpl authored
149
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
150 CREATE TABLE contactgroupmembers (
151 contactgroup_id integer NOT NULL
152 REFERENCES contactgroups(contactgroup_id) ON DELETE CASCADE ON UPDATE CASCADE,
153 contact_id integer NOT NULL
154 REFERENCES contacts(contact_id) ON DELETE CASCADE ON UPDATE CASCADE,
155 created timestamp with time zone DEFAULT now() NOT NULL,
156 PRIMARY KEY (contactgroup_id, contact_id)
157 );
158
159 --
b594741 @thomascube Add created date to message cache
thomascube authored
160 -- Sequence "cache_ids"
161 -- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres
162 --
163
164 CREATE SEQUENCE cache_ids
165 INCREMENT BY 1
166 NO MAXVALUE
167 NO MINVALUE
168 CACHE 1;
169
170 --
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
thomascube authored
171 -- Table "cache"
172 -- Name: cache; Type: TABLE; Schema: public; Owner: postgres
f5dc2a4 more changes to reflect postgres support
svncommit authored
173 --
174
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
thomascube authored
175 CREATE TABLE "cache" (
15a9d1c @thomascube Optimized loading time; added periodic mail check; added EXPUNGE command
thomascube authored
176 cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
177 user_id integer NOT NULL
178 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
179 cache_key varchar(128) DEFAULT '' NOT NULL,
f5dc2a4 more changes to reflect postgres support
svncommit authored
180 created timestamp with time zone DEFAULT now() NOT NULL,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
thomascube authored
181 data text NOT NULL
f5dc2a4 more changes to reflect postgres support
svncommit authored
182 );
183
edc63c2 @alecpl fix: there's no ALTER TABLE ... ADD INDEX in postgresql
alecpl authored
184 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
185 CREATE INDEX cache_created_idx ON "cache" (created);
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
thomascube authored
186
f5dc2a4 more changes to reflect postgres support
svncommit authored
187 --
b594741 @thomascube Add created date to message cache
thomascube authored
188 -- Sequence "message_ids"
189 -- Name: message_ids; Type: SEQUENCE; Schema: public; Owner: postgres
190 --
191
192 CREATE SEQUENCE message_ids
193 INCREMENT BY 1
194 NO MAXVALUE
195 NO MINVALUE
196 CACHE 1;
197
198 --
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
thomascube authored
199 -- Table "messages"
200 -- Name: messages; Type: TABLE; Schema: public; Owner: postgres
f5dc2a4 more changes to reflect postgres support
svncommit authored
201 --
202
c98f3b5 @alecpl #1485125: added index on messages.created
alecpl authored
203 CREATE TABLE messages (
15a9d1c @thomascube Optimized loading time; added periodic mail check; added EXPUNGE command
thomascube authored
204 message_id integer DEFAULT nextval('message_ids'::text) PRIMARY KEY,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
205 user_id integer NOT NULL
206 REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
a493ea8 @alecpl - change few "boolean" columns type from integer to smallint
alecpl authored
207 del smallint DEFAULT 0 NOT NULL,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
208 cache_key varchar(128) DEFAULT '' NOT NULL,
b594741 @thomascube Add created date to message cache
thomascube authored
209 created timestamp with time zone DEFAULT now() NOT NULL,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
thomascube authored
210 idx integer DEFAULT 0 NOT NULL,
211 uid integer DEFAULT 0 NOT NULL,
22d6b53 @alecpl - contactgroups DDL for postgres
alecpl authored
212 subject varchar(128) DEFAULT '' NOT NULL,
213 "from" varchar(128) DEFAULT '' NOT NULL,
214 "to" varchar(128) DEFAULT '' NOT NULL,
215 cc varchar(128) DEFAULT '' NOT NULL,
1cded85 @thomascube Re-design of caching (new database table added\!); some bugfixes; Postgr...
thomascube authored
216 date timestamp with time zone NOT NULL,
217 size integer DEFAULT 0 NOT NULL,
218 headers text NOT NULL,
ace511a @alecpl - Add unique index on users.username+users.mail_host
alecpl authored
219 structure text,
220 UNIQUE (user_id, cache_key, uid)
f5dc2a4 more changes to reflect postgres support
svncommit authored
221 );
222
3d601d2 @alecpl - added index in messages table
alecpl authored
223 CREATE INDEX messages_index_idx ON messages (user_id, cache_key, idx);
c98f3b5 @alecpl #1485125: added index on messages.created
alecpl authored
224 CREATE INDEX messages_created_idx ON messages (created);
Something went wrong with that request. Please try again.