source: subversion/branches/devel-mcache/roundcubemail/SQL/mysql.initial.sql @ 5131

Last change on this file since 5131 was 5131, checked in by alec, 21 months ago
  • Redesign: Use only one index row per-folder, small improvements
File size: 6.7 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(40) 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) NOT NULL,
24 `mail_host` varchar(128) NOT NULL,
25 `alias` varchar(128) 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 DEFAULT '0',
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 DEFAULT '0',
56 `mailbox` varchar(255) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL,
57 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
58 `data` longtext NOT NULL,
59 CONSTRAINT `user_id_fk_cache_index` FOREIGN KEY (`user_id`)
60   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
61 INDEX `changed_index` (`changed`),
62 PRIMARY KEY (`user_id`, `mailbox`)
63) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
64
65
66-- Table structure for table `cache_thread`
67
68CREATE TABLE `cache_thread` (
69 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
70 `mailbox` varchar(255) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL,
71 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
72 `data` longtext NOT NULL,
73 CONSTRAINT `user_id_fk_cache_thread` FOREIGN KEY (`user_id`)
74   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
75 INDEX `changed_index` (`changed`),
76 PRIMARY KEY (`user_id`, `mailbox`)
77) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
78
79
80-- Table structure for table `cache_messages`
81
82CREATE TABLE `cache_messages` (
83 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
84 `mailbox` varchar(255) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL,
85 `uid` int(11) UNSIGNED NOT NULL DEFAULT '0',
86 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
87 `data` longtext NOT NULL,
88 `seen` tinyint(1) NOT NULL DEFAULT '0',
89 `deleted` tinyint(1) NOT NULL DEFAULT '0',
90 `answered` tinyint(1) NOT NULL DEFAULT '0',
91 `forwarded` tinyint(1) NOT NULL DEFAULT '0',
92 `flagged` tinyint(1) NOT NULL DEFAULT '0',
93 `mdnsent` tinyint(1) NOT NULL DEFAULT '0',
94 CONSTRAINT `user_id_fk_cache_messages` FOREIGN KEY (`user_id`)
95   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
96 INDEX `changed_index` (`changed`),
97 PRIMARY KEY (`user_id`, `mailbox`, `uid`)
98) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
99
100
101-- Table structure for table `contacts`
102
103CREATE TABLE `contacts` (
104 `contact_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
105 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
106 `del` tinyint(1) NOT NULL DEFAULT '0',
107 `name` varchar(128) NOT NULL DEFAULT '',
108 `email` varchar(255) NOT NULL,
109 `firstname` varchar(128) NOT NULL DEFAULT '',
110 `surname` varchar(128) NOT NULL DEFAULT '',
111 `vcard` longtext NULL,
112 `words` text NULL,
113 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
114 PRIMARY KEY(`contact_id`),
115 CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`)
116   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
117 INDEX `user_contacts_index` (`user_id`,`email`)
118) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
119
120-- Table structure for table `contactgroups`
121
122CREATE TABLE `contactgroups` (
123  `contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
124  `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
125  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
126  `del` tinyint(1) NOT NULL DEFAULT '0',
127  `name` varchar(128) NOT NULL DEFAULT '',
128  PRIMARY KEY(`contactgroup_id`),
129  CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`)
130    REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
131  INDEX `contactgroups_user_index` (`user_id`,`del`)
132) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
133
134CREATE TABLE `contactgroupmembers` (
135  `contactgroup_id` int(10) UNSIGNED NOT NULL,
136  `contact_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
137  `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
138  PRIMARY KEY (`contactgroup_id`, `contact_id`),
139  CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`)
140    REFERENCES `contactgroups`(`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE,
141  CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`)
142    REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE,
143  INDEX `contactgroupmembers_contact_index` (`contact_id`)
144) /*!40000 ENGINE=INNODB */;
145
146
147-- Table structure for table `identities`
148
149CREATE TABLE `identities` (
150 `identity_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
151 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
152 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
153 `del` tinyint(1) NOT NULL DEFAULT '0',
154 `standard` tinyint(1) NOT NULL DEFAULT '0',
155 `name` varchar(128) NOT NULL,
156 `organization` varchar(128) NOT NULL DEFAULT '',
157 `email` varchar(128) NOT NULL,
158 `reply-to` varchar(128) NOT NULL DEFAULT '',
159 `bcc` varchar(128) NOT NULL DEFAULT '',
160 `signature` text,
161 `html_signature` tinyint(1) NOT NULL DEFAULT '0',
162 PRIMARY KEY(`identity_id`),
163 CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`)
164   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
165 INDEX `user_identities_index` (`user_id`, `del`)
166) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
167
168
169/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
Note: See TracBrowser for help on using the repository browser.