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
RevLine 
[3989]1-- Roundcube Webmail initial database structure
[22]2
3--
[5190]4-- Table structure for table cache
[22]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',
[5190]12  data text NOT NULL
[22]13);
14
[1218]15CREATE INDEX ix_cache_user_cache_key ON cache(user_id, cache_key);
[2087]16CREATE INDEX ix_cache_created ON cache(created);
[22]17
[88]18
[22]19-- --------------------------------------------------------
20
21--
[3425]22-- Table structure for table contacts and related
[22]23--
24
25CREATE TABLE contacts (
26  contact_id integer NOT NULL PRIMARY KEY,
27  user_id integer NOT NULL default '0',
[130]28  changed datetime NOT NULL default '0000-00-00 00:00:00',
[88]29  del tinyint NOT NULL default '0',
[22]30  name varchar(128) NOT NULL default '',
[4166]31  email varchar(255) NOT NULL default '',
[22]32  firstname varchar(128) NOT NULL default '',
33  surname varchar(128) NOT NULL default '',
[4541]34  vcard text NOT NULL default '',
35  words text NOT NULL default ''
[22]36);
37
[2999]38CREATE INDEX ix_contacts_user_id ON contacts(user_id, email);
[22]39
[3425]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
[4567]59CREATE INDEX ix_contactgroupmembers_contact_id ON contactgroupmembers (contact_id);
[3425]60
[4567]61
[22]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',
[3489]71  changed datetime NOT NULL default '0000-00-00 00:00:00',
[88]72  del tinyint NOT NULL default '0',
73  standard tinyint NOT NULL default '0',
[22]74  name varchar(128) NOT NULL default '',
[88]75  organization varchar(128) default '',
[22]76  email varchar(128) NOT NULL default '',
77  "reply-to" varchar(128) NOT NULL default '',
78  bcc varchar(128) NOT NULL default '',
[344]79  signature text NOT NULL default '',
80  html_signature tinyint NOT NULL default '0'
[22]81);
82
[3333]83CREATE INDEX ix_identities_user_id ON identities(user_id, del);
[22]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',
[3572]98  last_login datetime DEFAULT NULL,
[2090]99  language varchar(5),
[22]100  preferences text NOT NULL default ''
101);
[88]102
[4053]103CREATE UNIQUE INDEX ix_users_username ON users(username, mail_host);
[1242]104CREATE INDEX ix_users_alias ON users(alias);
[88]105
106-- --------------------------------------------------------
107
108--
109-- Table structure for table session
110--
111
112CREATE TABLE session (
[5481]113  sess_id varchar(128) NOT NULL PRIMARY KEY,
[88]114  created datetime NOT NULL default '0000-00-00 00:00:00',
115  changed datetime NOT NULL default '0000-00-00 00:00:00',
[803]116  ip varchar(40) NOT NULL default '',
[88]117  vars text NOT NULL
118);
119
[2076]120CREATE INDEX ix_session_changed ON session (changed);
[88]121
122-- --------------------------------------------------------
123
[5181]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
[5182]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);
[5190]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',
[5233]162    valid smallint NOT NULL DEFAULT '0',
[5190]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,
[5233]197    flags integer NOT NULL DEFAULT '0',
[5190]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.