Permalink
Newer
Older
100644 211 lines (164 sloc) 7.79 KB
1
-- Roundcube Webmail update script for MySQL databases
2
3
-- Updates from version 0.1-stable
5
TRUNCATE TABLE `messages`;
6
8
DROP INDEX `idx`,
9
DROP INDEX `uid`;
11
ALTER TABLE `cache`
12
DROP INDEX `cache_key`,
13
DROP INDEX `session_id`,
14
ADD INDEX `user_cache_index` (`user_id`,`cache_key`);
Apr 3, 2008
15
16
ALTER TABLE `users`
Apr 5, 2008
17
ADD INDEX `username_index` (`username`),
Apr 3, 2008
18
ADD INDEX `alias_index` (`alias`);
19
20
-- Updates from version 0.1.1
21
22
ALTER TABLE `identities`
23
MODIFY `signature` text,
24
MODIFY `bcc` varchar(128) NOT NULL DEFAULT '',
25
MODIFY `reply-to` varchar(128) NOT NULL DEFAULT '',
26
MODIFY `organization` varchar(128) NOT NULL DEFAULT '',
27
MODIFY `name` varchar(128) NOT NULL,
28
MODIFY `email` varchar(128) NOT NULL;
29
30
-- Updates from version 0.2-alpha
31
32
ALTER TABLE `messages`
33
ADD INDEX `created_index` (`created`);
35
-- Updates from version 0.2-beta (InnoDB required)
40
ALTER TABLE `session`
41
ADD INDEX `changed_index` (`changed`);
42
43
ALTER TABLE `cache`
44
ADD INDEX `created_index` (`created`);
45
46
ALTER TABLE `users`
47
CHANGE `language` `language` varchar(5);
49
ALTER TABLE `cache` ENGINE=InnoDB;
50
ALTER TABLE `session` ENGINE=InnoDB;
51
ALTER TABLE `messages` ENGINE=InnoDB;
52
ALTER TABLE `users` ENGINE=InnoDB;
53
ALTER TABLE `contacts` ENGINE=InnoDB;
54
ALTER TABLE `identities` ENGINE=InnoDB;
55
56
-- Updates from version 0.3-stable
57
58
TRUNCATE `messages`;
59
60
ALTER TABLE `messages`
61
ADD INDEX `index_index` (`user_id`, `cache_key`, `idx`);
63
ALTER TABLE `session`
64
CHANGE `vars` `vars` MEDIUMTEXT NOT NULL;
65
66
ALTER TABLE `contacts`
67
ADD INDEX `user_contacts_index` (`user_id`,`email`);
68
69
-- Updates from version 0.3.1
70
-- WARNING: Make sure that all tables are using InnoDB engine!!!
71
-- If not, use: ALTER TABLE xxx ENGINE=InnoDB;
72
73
/* MySQL bug workaround: http://bugs.mysql.com/bug.php?id=46293 */
Feb 6, 2010
74
/*!40014 SET FOREIGN_KEY_CHECKS=0 */;
75
76
ALTER TABLE `messages` DROP FOREIGN KEY `user_id_fk_messages`;
77
ALTER TABLE `cache` DROP FOREIGN KEY `user_id_fk_cache`;
78
ALTER TABLE `contacts` DROP FOREIGN KEY `user_id_fk_contacts`;
79
ALTER TABLE `identities` DROP FOREIGN KEY `user_id_fk_identities`;
80
81
ALTER TABLE `messages` ADD CONSTRAINT `user_id_fk_messages` FOREIGN KEY (`user_id`)
82
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
83
ALTER TABLE `cache` ADD CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
84
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
85
ALTER TABLE `contacts` ADD CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`)
86
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
87
ALTER TABLE `identities` ADD CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`)
88
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
90
ALTER TABLE `contacts` ALTER `name` SET DEFAULT '';
91
ALTER TABLE `contacts` ALTER `firstname` SET DEFAULT '';
92
ALTER TABLE `contacts` ALTER `surname` SET DEFAULT '';
93
Mar 9, 2010
94
ALTER TABLE `identities` ADD INDEX `user_identities_index` (`user_id`, `del`);
95
ALTER TABLE `identities` ADD `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00' AFTER `user_id`;
97
CREATE TABLE `contactgroups` (
98
`contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
99
`user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
100
`changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
101
`del` tinyint(1) NOT NULL DEFAULT '0',
102
`name` varchar(128) NOT NULL DEFAULT '',
103
PRIMARY KEY(`contactgroup_id`),
104
CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`)
105
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
106
INDEX `contactgroups_user_index` (`user_id`,`del`)
107
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
108
109
CREATE TABLE `contactgroupmembers` (
110
`contactgroup_id` int(10) UNSIGNED NOT NULL,
111
`contact_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
112
`created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
113
PRIMARY KEY (`contactgroup_id`, `contact_id`),
114
CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`)
115
REFERENCES `contactgroups`(`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE,
116
CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`)
117
REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE
118
) /*!40000 ENGINE=INNODB */;
119
Feb 6, 2010
120
/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
121
122
-- Updates from version 0.4-beta
123
124
ALTER TABLE `users` CHANGE `last_login` `last_login` datetime DEFAULT NULL;
125
UPDATE `users` SET `last_login` = NULL WHERE `last_login` = '1000-01-01 00:00:00';
126
127
-- Updates from version 0.4.2
128
129
ALTER TABLE `users` DROP INDEX `username_index`;
130
ALTER TABLE `users` ADD UNIQUE `username` (`username`, `mail_host`);
131
132
ALTER TABLE `contacts` MODIFY `email` varchar(255) NOT NULL;
133
134
TRUNCATE TABLE `messages`;
135
136
-- Updates from version 0.5.1
137
-- Updates from version 0.5.2
138
-- Updates from version 0.5.3
139
-- Updates from version 0.5.4
140
141
ALTER TABLE `contacts` ADD `words` TEXT NULL AFTER `vcard`;
142
ALTER TABLE `contacts` CHANGE `vcard` `vcard` LONGTEXT /*!40101 CHARACTER SET utf8 */ NULL DEFAULT NULL;
143
ALTER TABLE `contactgroupmembers` ADD INDEX `contactgroupmembers_contact_index` (`contact_id`);
144
145
TRUNCATE TABLE `messages`;
146
TRUNCATE TABLE `cache`;
147
148
-- Updates from version 0.6-stable
149
150
ALTER TABLE `users` CHANGE `alias` `alias` varchar(128) BINARY NOT NULL;
151
ALTER TABLE `users` CHANGE `username` `username` varchar(128) BINARY NOT NULL;
152
153
CREATE TABLE `dictionary` (
154
`user_id` int(10) UNSIGNED DEFAULT NULL,
155
`language` varchar(5) NOT NULL,
156
`data` longtext NOT NULL,
157
CONSTRAINT `user_id_fk_dictionary` FOREIGN KEY (`user_id`)
158
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
159
UNIQUE `uniqueness` (`user_id`, `language`)
160
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
161
162
CREATE TABLE `searches` (
163
`search_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
164
`user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
165
`type` int(3) NOT NULL DEFAULT '0',
166
`name` varchar(128) NOT NULL,
167
`data` text,
168
PRIMARY KEY(`search_id`),
169
CONSTRAINT `user_id_fk_searches` FOREIGN KEY (`user_id`)
170
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
171
UNIQUE `uniqueness` (`user_id`, `type`, `name`)
172
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
173
174
DROP TABLE `messages`;
175
176
CREATE TABLE `cache_index` (
177
`user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
178
`mailbox` varchar(255) BINARY NOT NULL,
179
`changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
180
`valid` tinyint(1) NOT NULL DEFAULT '0',
181
`data` longtext NOT NULL,
182
CONSTRAINT `user_id_fk_cache_index` FOREIGN KEY (`user_id`)
183
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
184
INDEX `changed_index` (`changed`),
185
PRIMARY KEY (`user_id`, `mailbox`)
186
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
187
188
CREATE TABLE `cache_thread` (
189
`user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
190
`mailbox` varchar(255) BINARY NOT NULL,
191
`changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
192
`data` longtext NOT NULL,
193
CONSTRAINT `user_id_fk_cache_thread` FOREIGN KEY (`user_id`)
194
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
195
INDEX `changed_index` (`changed`),
196
PRIMARY KEY (`user_id`, `mailbox`)
197
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
198
199
CREATE TABLE `cache_messages` (
200
`user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
201
`mailbox` varchar(255) BINARY NOT NULL,
202
`uid` int(11) UNSIGNED NOT NULL DEFAULT '0',
203
`changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
204
`data` longtext NOT NULL,
205
`flags` int(11) NOT NULL DEFAULT '0',
206
CONSTRAINT `user_id_fk_cache_messages` FOREIGN KEY (`user_id`)
207
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
208
INDEX `changed_index` (`changed`),
209
PRIMARY KEY (`user_id`, `mailbox`, `uid`)
210
) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;