source: subversion/trunk/roundcubemail/SQL/mysql.initial.sql

Last change on this file was 5755, checked in by alec, 16 months ago
  • Fix failure on MySQL database upgrade from 0.7 - text column can't have default value (#1488300)
File size: 7.2 KB
Line 
1-- Roundcube Webmail initial database structure
2
3
4/*!40014  SET FOREIGN_KEY_CHECKS=0 */;
5
6-- Table structure for table `session`
7
8CREATE TABLE `session` (
9 `sess_id` varchar(128) NOT NULL,
10 `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
11 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
12 `ip` varchar(40) NOT NULL,
13 `vars` mediumtext NOT NULL,
14 PRIMARY KEY(`sess_id`),
15 INDEX `changed_index` (`changed`)
16) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
17
18
19-- Table structure for table `users`
20
21CREATE TABLE `users` (
22 `user_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
23 `username` varchar(128) BINARY NOT NULL,
24 `mail_host` varchar(128) NOT NULL,
25 `alias` varchar(128) BINARY NOT NULL,
26 `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
27 `last_login` datetime DEFAULT NULL,
28 `language` varchar(5),
29 `preferences` text,
30 PRIMARY KEY(`user_id`),
31 UNIQUE `username` (`username`, `mail_host`),
32 INDEX `alias_index` (`alias`)
33) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
34
35
36-- Table structure for table `cache`
37
38CREATE TABLE `cache` (
39 `cache_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
40 `cache_key` varchar(128) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL ,
41 `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
42 `data` longtext NOT NULL,
43 `user_id` int(10) UNSIGNED NOT NULL,
44 PRIMARY KEY(`cache_id`),
45 CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
46   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
47 INDEX `created_index` (`created`),
48 INDEX `user_cache_index` (`user_id`,`cache_key`)
49) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
50
51
52-- Table structure for table `cache_index`
53
54CREATE TABLE `cache_index` (
55 `user_id` int(10) UNSIGNED NOT NULL,
56 `mailbox` varchar(255) BINARY NOT NULL,
57 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
58 `valid` tinyint(1) NOT NULL DEFAULT '0',
59 `data` longtext NOT NULL,
60 CONSTRAINT `user_id_fk_cache_index` FOREIGN KEY (`user_id`)
61   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
62 INDEX `changed_index` (`changed`),
63 PRIMARY KEY (`user_id`, `mailbox`)
64) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
65
66
67-- Table structure for table `cache_thread`
68
69CREATE TABLE `cache_thread` (
70 `user_id` int(10) UNSIGNED NOT NULL,
71 `mailbox` varchar(255) BINARY NOT NULL,
72 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
73 `data` longtext NOT NULL,
74 CONSTRAINT `user_id_fk_cache_thread` FOREIGN KEY (`user_id`)
75   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
76 INDEX `changed_index` (`changed`),
77 PRIMARY KEY (`user_id`, `mailbox`)
78) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
79
80
81-- Table structure for table `cache_messages`
82
83CREATE TABLE `cache_messages` (
84 `user_id` int(10) UNSIGNED NOT NULL,
85 `mailbox` varchar(255) BINARY NOT NULL,
86 `uid` int(11) UNSIGNED NOT NULL DEFAULT '0',
87 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
88 `data` longtext NOT NULL,
89 `flags` int(11) NOT NULL DEFAULT '0',
90 CONSTRAINT `user_id_fk_cache_messages` FOREIGN KEY (`user_id`)
91   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
92 INDEX `changed_index` (`changed`),
93 PRIMARY KEY (`user_id`, `mailbox`, `uid`)
94) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
95
96
97-- Table structure for table `contacts`
98
99CREATE TABLE `contacts` (
100 `contact_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
101 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
102 `del` tinyint(1) NOT NULL DEFAULT '0',
103 `name` varchar(128) NOT NULL DEFAULT '',
104 `email` text NOT NULL,
105 `firstname` varchar(128) NOT NULL DEFAULT '',
106 `surname` varchar(128) NOT NULL DEFAULT '',
107 `vcard` longtext NULL,
108 `words` text NULL,
109 `user_id` int(10) UNSIGNED NOT NULL,
110 PRIMARY KEY(`contact_id`),
111 CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`)
112   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
113 INDEX `user_contacts_index` (`user_id`,`del`)
114) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
115
116-- Table structure for table `contactgroups`
117
118CREATE TABLE `contactgroups` (
119  `contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
120  `user_id` int(10) UNSIGNED NOT NULL,
121  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
122  `del` tinyint(1) NOT NULL DEFAULT '0',
123  `name` varchar(128) NOT NULL DEFAULT '',
124  PRIMARY KEY(`contactgroup_id`),
125  CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`)
126    REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
127  INDEX `contactgroups_user_index` (`user_id`,`del`)
128) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
129
130CREATE TABLE `contactgroupmembers` (
131  `contactgroup_id` int(10) UNSIGNED NOT NULL,
132  `contact_id` int(10) UNSIGNED NOT NULL,
133  `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
134  PRIMARY KEY (`contactgroup_id`, `contact_id`),
135  CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`)
136    REFERENCES `contactgroups`(`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE,
137  CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`)
138    REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE,
139  INDEX `contactgroupmembers_contact_index` (`contact_id`)
140) /*!40000 ENGINE=INNODB */;
141
142
143-- Table structure for table `identities`
144
145CREATE TABLE `identities` (
146 `identity_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
147 `user_id` int(10) UNSIGNED NOT NULL,
148 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
149 `del` tinyint(1) NOT NULL DEFAULT '0',
150 `standard` tinyint(1) NOT NULL DEFAULT '0',
151 `name` varchar(128) NOT NULL,
152 `organization` varchar(128) NOT NULL DEFAULT '',
153 `email` varchar(128) NOT NULL,
154 `reply-to` varchar(128) NOT NULL DEFAULT '',
155 `bcc` varchar(128) NOT NULL DEFAULT '',
156 `signature` text,
157 `html_signature` tinyint(1) NOT NULL DEFAULT '0',
158 PRIMARY KEY(`identity_id`),
159 CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`)
160   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
161 INDEX `user_identities_index` (`user_id`, `del`)
162) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
163
164
165-- Table structure for table `dictionary`
166
167CREATE TABLE `dictionary` (
168  `user_id` int(10) UNSIGNED DEFAULT NULL,
169  `language` varchar(5) NOT NULL,
170  `data` longtext NOT NULL,
171  CONSTRAINT `user_id_fk_dictionary` FOREIGN KEY (`user_id`)
172    REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
173  UNIQUE `uniqueness` (`user_id`, `language`)
174) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
175
176
177-- Table structure for table `searches`
178
179CREATE TABLE `searches` (
180 `search_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
181 `user_id` int(10) UNSIGNED NOT NULL,
182 `type` int(3) NOT NULL DEFAULT '0',
183 `name` varchar(128) NOT NULL,
184 `data` text,
185 PRIMARY KEY(`search_id`),
186 CONSTRAINT `user_id_fk_searches` FOREIGN KEY (`user_id`)
187   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
188 UNIQUE `uniqueness` (`user_id`, `type`, `name`)
189) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
190
191
192/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
Note: See TracBrowser for help on using the repository browser.