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

Last change on this file since 3255 was 3255, checked in by alec, 3 years ago
File size: 4.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 NOT NULL DEFAULT '1000-01-01 00:00:00',
28 `language` varchar(5),
29 `preferences` text,
30 PRIMARY KEY(`user_id`),
31 INDEX `username_index` (`username`),
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 INDEX `created_index` (`created`),
56 INDEX `index_index` (`user_id`, `cache_key`, `idx`),
57 UNIQUE `uniqueness` (`user_id`, `cache_key`, `uid`)
58) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
59
60/* create foreign keys outside of create table, because of MySQL bug #46293 */
61ALTER TABLE `messages` ADD CONSTRAINT `user_id_fk_messages` FOREIGN KEY (`user_id`)
62 REFERENCES `users`(`user_id`) /*!40008 ON DELETE CASCADE ON UPDATE CASCADE */;
63
64
65-- Table structure for table `cache`
66
67CREATE TABLE `cache` (
68 `cache_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
69 `cache_key` varchar(128) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL ,
70 `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
71 `data` longtext NOT NULL,
72 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
73 PRIMARY KEY(`cache_id`),
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/* create foreign keys outside of create table, because of MySQL bug #46293 */
79ALTER TABLE `cache` ADD CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
80 REFERENCES `users`(`user_id`) /*!40008 ON DELETE CASCADE ON UPDATE CASCADE */;
81
82
83-- Table structure for table `contacts`
84
85CREATE TABLE `contacts` (
86 `contact_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
87 `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
88 `del` tinyint(1) NOT NULL DEFAULT '0',
89 `name` varchar(128) NOT NULL,
90 `email` varchar(128) NOT NULL,
91 `firstname` varchar(128) NOT NULL,
92 `surname` varchar(128) NOT NULL,
93 `vcard` text NULL,
94 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
95 PRIMARY KEY(`contact_id`),
96 INDEX `user_contacts_index` (`user_id`,`email`)
97) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
98
99/* create foreign keys outside of create table, because of MySQL bug #46293 */
100ALTER TABLE `contacts` ADD CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`)
101 REFERENCES `users`(`user_id`) /*!40008 ON DELETE CASCADE ON UPDATE CASCADE */;
102
103
104-- Table structure for table `identities`
105
106CREATE TABLE `identities` (
107 `identity_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
108 `del` tinyint(1) NOT NULL DEFAULT '0',
109 `standard` tinyint(1) NOT NULL DEFAULT '0',
110 `name` varchar(128) NOT NULL,
111 `organization` varchar(128) NOT NULL DEFAULT '',
112 `email` varchar(128) NOT NULL,
113 `reply-to` varchar(128) NOT NULL DEFAULT '',
114 `bcc` varchar(128) NOT NULL DEFAULT '',
115 `signature` text,
116 `html_signature` tinyint(1) NOT NULL DEFAULT '0',
117 `user_id` int(10) UNSIGNED NOT NULL DEFAULT '0',
118 PRIMARY KEY(`identity_id`)
119) /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */;
120
121/* create foreign keys outside of create table, because of MySQL bug #46293 */
122ALTER TABLE `identities` ADD CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`)
123 REFERENCES `users`(`user_id`) /*!40008 ON DELETE CASCADE ON UPDATE CASCADE */;
124
125
126/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
Note: See TracBrowser for help on using the repository browser.