source: github/SQL/postgres.initial.sql @ 66df084

HEADcourier-fixdev-browser-capabilitiespdorelease-0.7release-0.8
Last change on this file since 66df084 was 66df084, checked in by alecpl <alec@…>, 21 months ago
  • Merge devel-spellcheck branch:
    • Added spellchecker exceptions dictionary (shared or per-user)
    • Added possibility to ignore words containing caps, numbers, symbols (spellcheck_ignore_* options)
  • Property mode set to 100644
File size: 6.5 KB
Line 
1-- Roundcube Webmail initial database structure
2
3--
4-- Sequence "user_ids"
5-- Name: user_ids; Type: SEQUENCE; Schema: public; Owner: postgres
6--
7
8CREATE SEQUENCE user_ids
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
19CREATE TABLE users (
20    user_id integer DEFAULT nextval('user_ids'::text) PRIMARY KEY,
21    username varchar(128) DEFAULT '' NOT NULL,
22    mail_host varchar(128) DEFAULT '' NOT NULL,
23    alias varchar(128) DEFAULT '' NOT NULL,
24    created timestamp with time zone DEFAULT now() NOT NULL,
25    last_login timestamp with time zone DEFAULT NULL,
26    "language" varchar(5),
27    preferences text DEFAULT ''::text NOT NULL,
28    CONSTRAINT users_username_key UNIQUE (username, mail_host)
29);
30
31CREATE INDEX users_alias_id_idx ON users (alias);
32
33 
34--
35-- Table "session"
36-- Name: session; Type: TABLE; Schema: public; Owner: postgres
37--
38
39CREATE TABLE "session" (
40    sess_id varchar(40) DEFAULT '' PRIMARY KEY,
41    created timestamp with time zone DEFAULT now() NOT NULL,
42    changed timestamp with time zone DEFAULT now() NOT NULL,
43    ip varchar(41) NOT NULL,
44    vars text NOT NULL
45);
46
47CREATE INDEX session_changed_idx ON session (changed);
48
49
50--
51-- Sequence "identity_ids"
52-- Name: identity_ids; Type: SEQUENCE; Schema: public; Owner: postgres
53--
54
55CREATE SEQUENCE identity_ids
56    START WITH 1
57    INCREMENT BY 1
58    NO MAXVALUE
59    NO MINVALUE
60    CACHE 1;
61
62--
63-- Table "identities"
64-- Name: identities; Type: TABLE; Schema: public; Owner: postgres
65--
66
67CREATE TABLE identities (
68    identity_id integer DEFAULT nextval('identity_ids'::text) PRIMARY KEY,
69    user_id integer NOT NULL
70        REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
71    changed timestamp with time zone DEFAULT now() NOT NULL,
72    del smallint DEFAULT 0 NOT NULL,
73    standard smallint DEFAULT 0 NOT NULL,
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),
79    signature text,
80    html_signature integer DEFAULT 0 NOT NULL
81);
82
83CREATE INDEX identities_user_id_idx ON identities (user_id, del);
84
85
86--
87-- Sequence "contact_ids"
88-- Name: contact_ids; Type: SEQUENCE; Schema: public; Owner: postgres
89--
90
91CREATE SEQUENCE contact_ids
92    START WITH 1
93    INCREMENT BY 1
94    NO MAXVALUE
95    NO MINVALUE
96    CACHE 1;
97
98--
99-- Table "contacts"
100-- Name: contacts; Type: TABLE; Schema: public; Owner: postgres
101--
102
103CREATE TABLE contacts (
104    contact_id integer DEFAULT nextval('contact_ids'::text) PRIMARY KEY,
105    user_id integer NOT NULL
106        REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
107    changed timestamp with time zone DEFAULT now() NOT NULL,
108    del smallint DEFAULT 0 NOT NULL,
109    name varchar(128) DEFAULT '' NOT NULL,
110    email varchar(255) DEFAULT '' NOT NULL,
111    firstname varchar(128) DEFAULT '' NOT NULL,
112    surname varchar(128) DEFAULT '' NOT NULL,
113    vcard text,
114    words text
115);
116
117CREATE INDEX contacts_user_id_idx ON contacts (user_id, email);
118
119--
120-- Sequence "contactgroups_ids"
121-- Name: contactgroups_ids; Type: SEQUENCE; Schema: public; Owner: postgres
122--
123
124CREATE 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
135CREATE 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
144CREATE 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--
150
151CREATE 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
160CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id);
161
162--
163-- Sequence "cache_ids"
164-- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres
165--
166
167CREATE SEQUENCE cache_ids
168    INCREMENT BY 1
169    NO MAXVALUE
170    NO MINVALUE
171    CACHE 1;
172
173--
174-- Table "cache"
175-- Name: cache; Type: TABLE; Schema: public; Owner: postgres
176--
177
178CREATE TABLE "cache" (
179    cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY,
180    user_id integer NOT NULL
181        REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
182    cache_key varchar(128) DEFAULT '' NOT NULL,
183    created timestamp with time zone DEFAULT now() NOT NULL,
184    data text NOT NULL
185);
186
187CREATE INDEX cache_user_id_idx ON "cache" (user_id, cache_key);
188CREATE INDEX cache_created_idx ON "cache" (created);
189
190--
191-- Sequence "message_ids"
192-- Name: message_ids; Type: SEQUENCE; Schema: public; Owner: postgres
193--
194
195CREATE SEQUENCE message_ids
196    INCREMENT BY 1
197    NO MAXVALUE
198    NO MINVALUE
199    CACHE 1;
200
201--
202-- Table "messages"
203-- Name: messages; Type: TABLE; Schema: public; Owner: postgres
204--
205
206CREATE TABLE messages (
207    message_id integer DEFAULT nextval('message_ids'::text) PRIMARY KEY,
208    user_id integer NOT NULL
209        REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
210    del smallint DEFAULT 0 NOT NULL,
211    cache_key varchar(128) DEFAULT '' NOT NULL,
212    created timestamp with time zone DEFAULT now() NOT NULL,
213    idx integer DEFAULT 0 NOT NULL,
214    uid integer DEFAULT 0 NOT NULL,
215    subject varchar(128) DEFAULT '' NOT NULL,
216    "from" varchar(128) DEFAULT '' NOT NULL,
217    "to" varchar(128) DEFAULT '' NOT NULL,
218    cc varchar(128) DEFAULT '' NOT NULL,
219    date timestamp with time zone NOT NULL,
220    size integer DEFAULT 0 NOT NULL,
221    headers text NOT NULL,
222    structure text,
223    CONSTRAINT messages_user_id_key UNIQUE (user_id, cache_key, uid)
224);
225
226CREATE INDEX messages_index_idx ON messages (user_id, cache_key, idx);
227CREATE INDEX messages_created_idx ON messages (created);
228
229--
230-- Table "dictionary"
231-- Name: dictionary; Type: TABLE; Schema: public; Owner: postgres
232--
233
234CREATE TABLE dictionary (
235    user_id integer DEFAULT NULL
236        REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
237   "language" varchar(5) NOT NULL,
238    data text NOT NULL,
239    CONSTRAINT dictionary_user_id_language_key UNIQUE (user_id, "language")
240);
Note: See TracBrowser for help on using the repository browser.