source: github/SQL/sqlite.update.sql @ e8b2579

release-0.7
Last change on this file since e8b2579 was e8b2579, checked in by alecpl <alec@…>, 17 months ago
  • Aplied fixes from trunk up to r5615
  • Property mode set to 100644
File size: 10.0 KB
Line 
1-- Roundcube Webmail update script for SQLite databases
2-- Updates from version 0.1-stable to 0.1.1
3
4DROP TABLE messages;
5
6CREATE TABLE messages (
7  message_id integer NOT NULL PRIMARY KEY,
8  user_id integer NOT NULL default '0',
9  del tinyint NOT NULL default '0',
10  cache_key varchar(128) NOT NULL default '',
11  created datetime NOT NULL default '0000-00-00 00:00:00',
12  idx integer NOT NULL default '0',
13  uid integer NOT NULL default '0',
14  subject varchar(255) NOT NULL default '',
15  "from" varchar(255) NOT NULL default '',
16  "to" varchar(255) NOT NULL default '',
17  "cc" varchar(255) NOT NULL default '',
18  "date" datetime NOT NULL default '0000-00-00 00:00:00',
19  size integer NOT NULL default '0',
20  headers text NOT NULL,
21  structure text
22);
23
24CREATE INDEX ix_messages_user_cache_uid ON messages(user_id,cache_key,uid);
25CREATE INDEX ix_users_username ON users(username);
26CREATE INDEX ix_users_alias ON users(alias);
27
28-- Updates from version 0.2-alpha
29
30CREATE INDEX ix_messages_created ON messages (created);
31
32-- Updates from version 0.2-beta
33
34CREATE INDEX ix_session_changed ON session (changed);
35CREATE INDEX ix_cache_created ON cache (created);
36
37-- Updates from version 0.3-stable
38
39DELETE FROM messages;
40DROP INDEX ix_messages_user_cache_uid;
41CREATE UNIQUE INDEX ix_messages_user_cache_uid ON messages (user_id,cache_key,uid);
42CREATE INDEX ix_messages_index ON messages (user_id,cache_key,idx);
43DROP INDEX ix_contacts_user_id;
44CREATE INDEX ix_contacts_user_id ON contacts(user_id, email);
45
46-- Updates from version 0.3.1
47
48-- ALTER TABLE identities ADD COLUMN changed datetime NOT NULL default '0000-00-00 00:00:00'; --
49
50CREATE TABLE temp_identities (
51  identity_id integer NOT NULL PRIMARY KEY,
52  user_id integer NOT NULL default '0',
53  standard tinyint NOT NULL default '0',
54  name varchar(128) NOT NULL default '',
55  organization varchar(128) default '',
56  email varchar(128) NOT NULL default '',
57  "reply-to" varchar(128) NOT NULL default '',
58  bcc varchar(128) NOT NULL default '',
59  signature text NOT NULL default '',
60  html_signature tinyint NOT NULL default '0'
61);
62INSERT INTO temp_identities (identity_id, user_id, standard, name, organization, email, "reply-to", bcc, signature, html_signature)
63  SELECT identity_id, user_id, standard, name, organization, email, "reply-to", bcc, signature, html_signature
64  FROM identities WHERE del=0;
65
66DROP INDEX ix_identities_user_id;
67DROP TABLE identities;
68
69CREATE TABLE identities (
70  identity_id integer NOT NULL PRIMARY KEY,
71  user_id integer NOT NULL default '0',
72  changed datetime NOT NULL default '0000-00-00 00:00:00',
73  del tinyint NOT NULL default '0',
74  standard tinyint NOT NULL default '0',
75  name varchar(128) NOT NULL default '',
76  organization varchar(128) default '',
77  email varchar(128) NOT NULL default '',
78  "reply-to" varchar(128) NOT NULL default '',
79  bcc varchar(128) NOT NULL default '',
80  signature text NOT NULL default '',
81  html_signature tinyint NOT NULL default '0'
82);
83CREATE INDEX ix_identities_user_id ON identities(user_id, del);
84
85INSERT INTO identities (identity_id, user_id, standard, name, organization, email, "reply-to", bcc, signature, html_signature)
86  SELECT identity_id, user_id, standard, name, organization, email, "reply-to", bcc, signature, html_signature
87  FROM temp_identities;
88
89DROP TABLE temp_identities;
90
91CREATE TABLE contactgroups (
92  contactgroup_id integer NOT NULL PRIMARY KEY,
93  user_id integer NOT NULL default '0',
94  changed datetime NOT NULL default '0000-00-00 00:00:00',
95  del tinyint NOT NULL default '0',
96  name varchar(128) NOT NULL default ''
97);
98
99CREATE INDEX ix_contactgroups_user_id ON contactgroups(user_id, del);
100
101CREATE TABLE contactgroupmembers (
102  contactgroup_id integer NOT NULL,
103  contact_id integer NOT NULL default '0',
104  created datetime NOT NULL default '0000-00-00 00:00:00',
105  PRIMARY KEY (contactgroup_id, contact_id)
106);
107
108-- Updates from version 0.3.1
109
110CREATE TABLE tmp_users (
111  user_id integer NOT NULL PRIMARY KEY,
112  username varchar(128) NOT NULL default '',
113  mail_host varchar(128) NOT NULL default '',
114  alias varchar(128) NOT NULL default '',
115  created datetime NOT NULL default '0000-00-00 00:00:00',
116  last_login datetime NOT NULL default '0000-00-00 00:00:00',
117  language varchar(5),
118  preferences text NOT NULL default ''
119);
120
121INSERT INTO tmp_users (user_id, username, mail_host, alias, created, last_login, language, preferences)
122    SELECT user_id, username, mail_host, alias, created, last_login, language, preferences FROM users;
123
124DROP TABLE users;
125
126CREATE TABLE users (
127  user_id integer NOT NULL PRIMARY KEY,
128  username varchar(128) NOT NULL default '',
129  mail_host varchar(128) NOT NULL default '',
130  alias varchar(128) NOT NULL default '',
131  created datetime NOT NULL default '0000-00-00 00:00:00',
132  last_login datetime DEFAULT NULL,
133  language varchar(5),
134  preferences text NOT NULL default ''
135);
136
137INSERT INTO users (user_id, username, mail_host, alias, created, last_login, language, preferences)
138    SELECT user_id, username, mail_host, alias, created, last_login, language, preferences FROM tmp_users;
139
140CREATE INDEX ix_users_username ON users(username);
141CREATE INDEX ix_users_alias ON users(alias);
142DROP TABLE tmp_users;
143
144-- Updates from version 0.4.2
145
146DROP INDEX ix_users_username;
147CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host);
148
149CREATE TABLE contacts_tmp (
150    contact_id integer NOT NULL PRIMARY KEY,
151    user_id integer NOT NULL default '0',
152    changed datetime NOT NULL default '0000-00-00 00:00:00',
153    del tinyint NOT NULL default '0',
154    name varchar(128) NOT NULL default '',
155    email varchar(255) NOT NULL default '',
156    firstname varchar(128) NOT NULL default '',
157    surname varchar(128) NOT NULL default '',
158    vcard text NOT NULL default ''
159);
160
161INSERT INTO contacts_tmp (contact_id, user_id, changed, del, name, email, firstname, surname, vcard)
162    SELECT contact_id, user_id, changed, del, name, email, firstname, surname, vcard FROM contacts;
163
164DROP TABLE contacts;
165CREATE TABLE contacts (
166    contact_id integer NOT NULL PRIMARY KEY,
167    user_id integer NOT NULL default '0',
168    changed datetime NOT NULL default '0000-00-00 00:00:00',
169    del tinyint NOT NULL default '0',
170    name varchar(128) NOT NULL default '',
171    email varchar(255) NOT NULL default '',
172    firstname varchar(128) NOT NULL default '',
173    surname varchar(128) NOT NULL default '',
174    vcard text NOT NULL default ''
175);
176
177INSERT INTO contacts (contact_id, user_id, changed, del, name, email, firstname, surname, vcard)
178    SELECT contact_id, user_id, changed, del, name, email, firstname, surname, vcard FROM contacts_tmp;
179
180CREATE INDEX ix_contacts_user_id ON contacts(user_id, email);
181DROP TABLE contacts_tmp;
182
183DELETE FROM messages;
184
185
186-- Updates from version 0.5.1
187-- Updates from version 0.5.2
188-- Updates from version 0.5.3
189-- Updates from version 0.5.4
190
191CREATE TABLE contacts_tmp (
192    contact_id integer NOT NULL PRIMARY KEY,
193    user_id integer NOT NULL default '0',
194    changed datetime NOT NULL default '0000-00-00 00:00:00',
195    del tinyint NOT NULL default '0',
196    name varchar(128) NOT NULL default '',
197    email varchar(255) NOT NULL default '',
198    firstname varchar(128) NOT NULL default '',
199    surname varchar(128) NOT NULL default '',
200    vcard text NOT NULL default ''
201);
202
203INSERT INTO contacts_tmp (contact_id, user_id, changed, del, name, email, firstname, surname, vcard)
204    SELECT contact_id, user_id, changed, del, name, email, firstname, surname, vcard FROM contacts;
205
206DROP TABLE contacts;
207CREATE TABLE contacts (
208    contact_id integer NOT NULL PRIMARY KEY,
209    user_id integer NOT NULL default '0',
210    changed datetime NOT NULL default '0000-00-00 00:00:00',
211    del tinyint NOT NULL default '0',
212    name varchar(128) NOT NULL default '',
213    email varchar(255) NOT NULL default '',
214    firstname varchar(128) NOT NULL default '',
215    surname varchar(128) NOT NULL default '',
216    vcard text NOT NULL default '',
217    words text NOT NULL default ''
218);
219
220INSERT INTO contacts (contact_id, user_id, changed, del, name, email, firstname, surname, vcard)
221    SELECT contact_id, user_id, changed, del, name, email, firstname, surname, vcard FROM contacts_tmp;
222
223CREATE INDEX ix_contacts_user_id ON contacts(user_id, email);
224DROP TABLE contacts_tmp;
225
226
227DELETE FROM messages;
228DELETE FROM cache;
229CREATE INDEX ix_contactgroupmembers_contact_id ON contactgroupmembers (contact_id);
230
231-- Updates from version 0.6
232
233CREATE TABLE dictionary (
234    user_id integer DEFAULT NULL,
235   "language" varchar(5) NOT NULL,
236    data text NOT NULL
237);
238
239CREATE UNIQUE INDEX ix_dictionary_user_language ON dictionary (user_id, "language");
240
241CREATE TABLE searches (
242  search_id integer NOT NULL PRIMARY KEY,
243  user_id integer NOT NULL DEFAULT '0',
244  "type" smallint NOT NULL DEFAULT '0',
245  name varchar(128) NOT NULL,
246  data text NOT NULL
247);
248
249CREATE UNIQUE INDEX ix_searches_user_type_name ON searches (user_id, type, name);
250
251DROP TABLE messages;
252
253CREATE TABLE cache_index (
254    user_id integer NOT NULL,
255    mailbox varchar(255) NOT NULL,
256    changed datetime NOT NULL default '0000-00-00 00:00:00',
257    valid smallint NOT NULL DEFAULT '0',
258    data text NOT NULL,
259    PRIMARY KEY (user_id, mailbox)
260);
261
262CREATE INDEX ix_cache_index_changed ON cache_index (changed);
263
264CREATE TABLE cache_thread (
265    user_id integer NOT NULL,
266    mailbox varchar(255) NOT NULL,
267    changed datetime NOT NULL default '0000-00-00 00:00:00',
268    data text NOT NULL,
269    PRIMARY KEY (user_id, mailbox)
270);
271
272CREATE INDEX ix_cache_thread_changed ON cache_thread (changed);
273
274CREATE TABLE cache_messages (
275    user_id integer NOT NULL,
276    mailbox varchar(255) NOT NULL,
277    uid integer NOT NULL,
278    changed datetime NOT NULL default '0000-00-00 00:00:00',
279    data text NOT NULL,
280    flags integer NOT NULL DEFAULT '0',
281    PRIMARY KEY (user_id, mailbox, uid)
282);
283
284CREATE INDEX ix_cache_messages_changed ON cache_messages (changed);
285
286-- Updates from version 0.7-beta
287
288DROP TABLE session;
289CREATE TABLE session (
290  sess_id varchar(128) NOT NULL PRIMARY KEY,
291  created datetime NOT NULL default '0000-00-00 00:00:00',
292  changed datetime NOT NULL default '0000-00-00 00:00:00',
293  ip varchar(40) NOT NULL default '',
294  vars text NOT NULL
295);
296
297CREATE INDEX ix_session_changed ON session (changed);
Note: See TracBrowser for help on using the repository browser.