source: github/SQL/mysql.initial.sql @ 3a5476d1

HEADcourier-fixdev-browser-capabilitiespdorelease-0.6release-0.7release-0.8
Last change on this file since 3a5476d1 was 3a5476d1, checked in by alecpl <alec@…>, 2 years ago
  • Add index on contactgroupmembers.contact_id column. Improves performance and fixes problem with contactgroupmembers table creation on MySQL 4.x
  • Property mode set to 100644
File size: 5.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 `messages`
37
38CREATE TABLE `messages` (
39 `message_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
40 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
41 `del` tinyint(1) NOT NULL DEFAULT '0',
42 `cache_key` varchar(128) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL,
43 `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
44 `idx` int(11) UNSIGNED NOT NULL DEFAULT '0',
45 `uid` int(11) UNSIGNED NOT NULL DEFAULT '0',
46 `subject` varchar(255) NOT NULL,
47 `from` varchar(255) NOT NULL,
48 `to` varchar(255) NOT NULL,
49 `cc` varchar(255) NOT NULL,
50 `date` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
51 `size` int(11) UNSIGNED NOT NULL DEFAULT '0',
52 `headers` text NOT NULL,
53 `structure` text,
54 PRIMARY KEY(`message_id`),
55 CONSTRAINT `user_id_fk_messages` FOREIGN KEY (`user_id`)
56   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
57 INDEX `created_index` (`created`),
58 INDEX `index_index` (`user_id`, `cache_key`, `idx`),
59 UNIQUE `uniqueness` (`user_id`, `cache_key`, `uid`)
60) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
61
62
63-- Table structure for table `cache`
64
65CREATE TABLE `cache` (
66 `cache_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
67 `cache_key` varchar(128) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL ,
68 `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
69 `data` longtext NOT NULL,
70 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
71 PRIMARY KEY(`cache_id`),
72 CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
73   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
74 INDEX `created_index` (`created`),
75 INDEX `user_cache_index` (`user_id`,`cache_key`)
76) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
77
78
79-- Table structure for table `contacts`
80
81CREATE TABLE `contacts` (
82 `contact_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
83 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
84 `del` tinyint(1) NOT NULL DEFAULT '0',
85 `name` varchar(128) NOT NULL DEFAULT '',
86 `email` varchar(255) NOT NULL,
87 `firstname` varchar(128) NOT NULL DEFAULT '',
88 `surname` varchar(128) NOT NULL DEFAULT '',
89 `vcard` text NULL,
90 `words` text NULL,
91 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
92 PRIMARY KEY(`contact_id`),
93 CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`)
94   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
95 INDEX `user_contacts_index` (`user_id`,`email`)
96) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
97
98-- Table structure for table `contactgroups`
99
100CREATE TABLE `contactgroups` (
101  `contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
102  `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
103  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
104  `del` tinyint(1) NOT NULL DEFAULT '0',
105  `name` varchar(128) NOT NULL DEFAULT '',
106  PRIMARY KEY(`contactgroup_id`),
107  CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`)
108    REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
109  INDEX `contactgroups_user_index` (`user_id`,`del`)
110) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
111
112CREATE TABLE `contactgroupmembers` (
113  `contactgroup_id` int(10) UNSIGNED NOT NULL,
114  `contact_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
115  `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
116  PRIMARY KEY (`contactgroup_id`, `contact_id`),
117  CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`)
118    REFERENCES `contactgroups`(`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE,
119  CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`)
120    REFERENCES `contacts`(`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE,
121  INDEX `contactgroupmembers_contact_index` (`contact_id`)
122) /*!40000 ENGINE=INNODB */;
123
124
125-- Table structure for table `identities`
126
127CREATE TABLE `identities` (
128 `identity_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
129 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
130 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
131 `del` tinyint(1) NOT NULL DEFAULT '0',
132 `standard` tinyint(1) NOT NULL DEFAULT '0',
133 `name` varchar(128) NOT NULL,
134 `organization` varchar(128) NOT NULL DEFAULT '',
135 `email` varchar(128) NOT NULL,
136 `reply-to` varchar(128) NOT NULL DEFAULT '',
137 `bcc` varchar(128) NOT NULL DEFAULT '',
138 `signature` text,
139 `html_signature` tinyint(1) NOT NULL DEFAULT '0',
140 PRIMARY KEY(`identity_id`),
141 CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`)
142   REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
143 INDEX `user_identities_index` (`user_id`, `del`)
144) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
145
146
147/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
Note: See TracBrowser for help on using the repository browser.