source: subversion/branches/release-0.7/SQL/sqlite.initial.sql @ 5481

Last change on this file since 5481 was 5481, checked in by alec, 18 months ago
  • Applied fixes from trunk up to r5479
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1-- Roundcube Webmail initial database structure
2
3--
4-- Table structure for table cache
5--
6
7CREATE TABLE cache (
8  cache_id integer NOT NULL PRIMARY KEY,
9  user_id integer NOT NULL default 0,
10  cache_key varchar(128) NOT NULL default '',
11  created datetime NOT NULL default '0000-00-00 00:00:00',
12  data text NOT NULL
13);
14
15CREATE INDEX ix_cache_user_cache_key ON cache(user_id, cache_key);
16CREATE INDEX ix_cache_created ON cache(created);
17
18
19-- --------------------------------------------------------
20
21--
22-- Table structure for table contacts and related
23--
24
25CREATE TABLE contacts (
26  contact_id integer NOT NULL PRIMARY KEY,
27  user_id integer NOT NULL default '0',
28  changed datetime NOT NULL default '0000-00-00 00:00:00',
29  del tinyint NOT NULL default '0',
30  name varchar(128) NOT NULL default '',
31  email varchar(255) NOT NULL default '',
32  firstname varchar(128) NOT NULL default '',
33  surname varchar(128) NOT NULL default '',
34  vcard text NOT NULL default '',
35  words text NOT NULL default ''
36);
37
38CREATE INDEX ix_contacts_user_id ON contacts(user_id, email);
39
40
41CREATE TABLE contactgroups (
42  contactgroup_id integer NOT NULL PRIMARY KEY,
43  user_id integer NOT NULL default '0',
44  changed datetime NOT NULL default '0000-00-00 00:00:00',
45  del tinyint NOT NULL default '0',
46  name varchar(128) NOT NULL default ''
47);
48
49CREATE INDEX ix_contactgroups_user_id ON contactgroups(user_id, del);
50
51
52CREATE TABLE contactgroupmembers (
53  contactgroup_id integer NOT NULL,
54  contact_id integer NOT NULL default '0',
55  created datetime NOT NULL default '0000-00-00 00:00:00',
56  PRIMARY KEY (contactgroup_id, contact_id)
57);
58
59CREATE INDEX ix_contactgroupmembers_contact_id ON contactgroupmembers (contact_id);
60
61
62-- --------------------------------------------------------
63
64--
65-- Table structure for table identities
66--
67
68CREATE TABLE identities (
69  identity_id integer NOT NULL PRIMARY KEY,
70  user_id integer NOT NULL default '0',
71  changed datetime NOT NULL default '0000-00-00 00:00:00',
72  del tinyint NOT NULL default '0',
73  standard tinyint NOT NULL default '0',
74  name varchar(128) NOT NULL default '',
75  organization varchar(128) default '',
76  email varchar(128) NOT NULL default '',
77  "reply-to" varchar(128) NOT NULL default '',
78  bcc varchar(128) NOT NULL default '',
79  signature text NOT NULL default '',
80  html_signature tinyint NOT NULL default '0'
81);
82
83CREATE INDEX ix_identities_user_id ON identities(user_id, del);
84
85
86-- --------------------------------------------------------
87
88--
89-- Table structure for table users
90--
91
92CREATE TABLE users (
93  user_id integer NOT NULL PRIMARY KEY,
94  username varchar(128) NOT NULL default '',
95  mail_host varchar(128) NOT NULL default '',
96  alias varchar(128) NOT NULL default '',
97  created datetime NOT NULL default '0000-00-00 00:00:00',
98  last_login datetime DEFAULT NULL,
99  language varchar(5),
100  preferences text NOT NULL default ''
101);
102
103CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host);
104CREATE INDEX ix_users_alias ON users(alias);
105
106-- --------------------------------------------------------
107
108--
109-- Table structure for table session
110--
111
112CREATE TABLE session (
113  sess_id varchar(128) NOT NULL PRIMARY KEY,
114  created datetime NOT NULL default '0000-00-00 00:00:00',
115  changed datetime NOT NULL default '0000-00-00 00:00:00',
116  ip varchar(40) NOT NULL default '',
117  vars text NOT NULL
118);
119
120CREATE INDEX ix_session_changed ON session (changed);
121
122-- --------------------------------------------------------
123
124--
125-- Table structure for table dictionary
126--
127
128CREATE TABLE dictionary (
129    user_id integer DEFAULT NULL,
130   "language" varchar(5) NOT NULL,
131    data text NOT NULL
132);
133
134CREATE UNIQUE INDEX ix_dictionary_user_language ON dictionary (user_id, "language");
135
136-- --------------------------------------------------------
137
138--
139-- Table structure for table searches
140--
141
142CREATE TABLE searches (
143  search_id integer NOT NULL PRIMARY KEY,
144  user_id integer NOT NULL DEFAULT '0',
145  "type" smallint NOT NULL DEFAULT '0',
146  name varchar(128) NOT NULL,
147  data text NOT NULL
148);
149
150CREATE UNIQUE INDEX ix_searches_user_type_name (user_id, type, name);
151
152-- --------------------------------------------------------
153
154--
155-- Table structure for table cache_index
156--
157
158CREATE TABLE cache_index (
159    user_id integer NOT NULL,
160    mailbox varchar(255) NOT NULL,
161    changed datetime NOT NULL default '0000-00-00 00:00:00',
162    valid smallint NOT NULL DEFAULT '0',
163    data text NOT NULL,
164    PRIMARY KEY (user_id, mailbox)
165);
166
167CREATE INDEX ix_cache_index_changed ON cache_index (changed);
168
169-- --------------------------------------------------------
170
171--
172-- Table structure for table cache_thread
173--
174
175CREATE TABLE cache_thread (
176    user_id integer NOT NULL,
177    mailbox varchar(255) NOT NULL,
178    changed datetime NOT NULL default '0000-00-00 00:00:00',
179    data text NOT NULL,
180    PRIMARY KEY (user_id, mailbox)
181);
182
183CREATE INDEX ix_cache_thread_changed ON cache_thread (changed);
184
185-- --------------------------------------------------------
186
187--
188-- Table structure for table cache_messages
189--
190
191CREATE TABLE cache_messages (
192    user_id integer NOT NULL,
193    mailbox varchar(255) NOT NULL,
194    uid integer NOT NULL,
195    changed datetime NOT NULL default '0000-00-00 00:00:00',
196    data text NOT NULL,
197    flags integer NOT NULL DEFAULT '0',
198    PRIMARY KEY (user_id, mailbox, uid)
199);
200
201CREATE INDEX ix_cache_messages_changed ON cache_messages (changed);
Note: See TracBrowser for help on using the repository browser.