]> git.wh0rd.org - tt-rss.git/blob - schema/ttrss_schema_mysql.sql
aae0abf204571ca54857f307c5689370a64d6fda
[tt-rss.git] / schema / ttrss_schema_mysql.sql
1 SET NAMES utf8;
2 SET CHARACTER SET utf8;
3
4 drop table if exists ttrss_error_log;
5 drop table if exists ttrss_plugin_storage;
6 drop table if exists ttrss_linked_feeds;
7 drop table if exists ttrss_linked_instances;
8 drop table if exists ttrss_access_keys;
9 drop table if exists ttrss_user_labels2;
10 drop table if exists ttrss_labels2;
11 drop table if exists ttrss_feedbrowser_cache;
12 drop table if exists ttrss_version;
13 drop table if exists ttrss_labels;
14 drop table if exists ttrss_filters2_actions;
15 drop table if exists ttrss_filters2_rules;
16 drop table if exists ttrss_filters2;
17 drop table if exists ttrss_filters;
18 drop table if exists ttrss_filter_types;
19 drop table if exists ttrss_filter_actions;
20 drop table if exists ttrss_user_prefs;
21 drop table if exists ttrss_prefs;
22 drop table if exists ttrss_prefs_types;
23 drop table if exists ttrss_prefs_sections;
24 drop table if exists ttrss_tags;
25 drop table if exists ttrss_enclosures;
26 drop table if exists ttrss_settings_profiles;
27 drop table if exists ttrss_entry_comments;
28 drop table if exists ttrss_user_entries;
29 drop table if exists ttrss_entries;
30 drop table if exists ttrss_scheduled_updates;
31 drop table if exists ttrss_counters_cache;
32 drop table if exists ttrss_cat_counters_cache;
33 drop table if exists ttrss_feeds;
34 drop table if exists ttrss_archived_feeds;
35 drop table if exists ttrss_feed_categories;
36 drop table if exists ttrss_users;
37 drop table if exists ttrss_themes;
38 drop table if exists ttrss_sessions;
39
40 begin;
41
42 create table ttrss_users (id integer primary key not null auto_increment,
43 login varchar(120) not null unique,
44 pwd_hash varchar(250) not null,
45 last_login datetime default null,
46 access_level integer not null default 0,
47 theme_id integer default null,
48 email varchar(250) not null default '',
49 full_name varchar(250) not null default '',
50 email_digest bool not null default false,
51 last_digest_sent datetime default null,
52 salt varchar(250) not null default '',
53 created datetime default null,
54 twitter_oauth longtext default null,
55 otp_enabled boolean not null default false,
56 index (theme_id)) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
57
58 insert into ttrss_users (login,pwd_hash,access_level) values ('admin',
59 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', 10);
60
61 create table ttrss_feed_categories(id integer not null primary key auto_increment,
62 owner_uid integer not null,
63 title varchar(200) not null,
64 collapsed bool not null default false,
65 order_id integer not null default 0,
66 parent_cat integer,
67 view_settings varchar(250) not null default '',
68 index(parent_cat),
69 foreign key (parent_cat) references ttrss_feed_categories(id) ON DELETE SET NULL,
70 index(owner_uid),
71 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
72
73 create table ttrss_archived_feeds (id integer not null primary key,
74 owner_uid integer not null,
75 title varchar(200) not null,
76 feed_url text not null,
77 site_url varchar(250) not null default '',
78 index(owner_uid),
79 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
80
81 create table ttrss_counters_cache (
82 feed_id integer not null,
83 owner_uid integer not null,
84 value integer not null default 0,
85 updated datetime not null,
86 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE
87 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
88
89 create index ttrss_counters_cache_feed_id_idx on ttrss_counters_cache(feed_id);
90 create index ttrss_counters_cache_owner_uid_idx on ttrss_counters_cache(owner_uid);
91 create index ttrss_counters_cache_value_idx on ttrss_counters_cache(value);
92
93 create table ttrss_cat_counters_cache (
94 feed_id integer not null,
95 owner_uid integer not null,
96 value integer not null default 0,
97 updated datetime not null,
98 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE
99 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
100
101 create index ttrss_cat_counters_cache_owner_uid_idx on ttrss_cat_counters_cache(owner_uid);
102
103 create table ttrss_feeds (id integer not null auto_increment primary key,
104 owner_uid integer not null,
105 title varchar(200) not null,
106 cat_id integer default null,
107 feed_url text not null,
108 icon_url varchar(250) not null default '',
109 update_interval integer not null default 0,
110 purge_interval integer not null default 0,
111 last_updated datetime default 0,
112 last_error varchar(250) not null default '',
113 favicon_avg_color varchar(11) default null,
114 site_url varchar(250) not null default '',
115 auth_login varchar(250) not null default '',
116 auth_pass varchar(250) not null default '',
117 parent_feed integer default null,
118 private bool not null default false,
119 rtl_content bool not null default false,
120 hidden bool not null default false,
121 include_in_digest boolean not null default true,
122 cache_images boolean not null default false,
123 hide_images boolean not null default false,
124 cache_content boolean not null default false,
125 auth_pass_encrypted boolean not null default false,
126 last_viewed datetime default null,
127 last_update_started datetime default null,
128 always_display_enclosures boolean not null default false,
129 update_method integer not null default 0,
130 order_id integer not null default 0,
131 mark_unread_on_update boolean not null default false,
132 update_on_checksum_change boolean not null default false,
133 strip_images boolean not null default false,
134 view_settings varchar(250) not null default '',
135 pubsub_state integer not null default 0,
136 favicon_last_checked datetime default null,
137 index(owner_uid),
138 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE,
139 index(cat_id),
140 foreign key (cat_id) references ttrss_feed_categories(id) ON DELETE SET NULL,
141 index(parent_feed),
142 foreign key (parent_feed) references ttrss_feeds(id) ON DELETE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
143
144 create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid);
145 create index ttrss_feeds_cat_id_idx on ttrss_feeds(cat_id);
146
147 insert into ttrss_feeds (owner_uid, title, feed_url) values
148 (1, 'Tiny Tiny RSS: New Releases', 'http://tt-rss.org/releases.rss');
149
150 insert into ttrss_feeds (owner_uid, title, feed_url) values
151 (1, 'Tiny Tiny RSS: Forum', 'http://tt-rss.org/forum/rss.php');
152
153 create table ttrss_entries (id integer not null primary key auto_increment,
154 title text not null,
155 guid varchar(255) not null unique,
156 link text not null,
157 updated datetime not null,
158 content longtext not null,
159 content_hash varchar(250) not null,
160 cached_content longtext,
161 no_orig_date bool not null default 0,
162 date_entered datetime not null,
163 date_updated datetime not null,
164 num_comments integer not null default 0,
165 plugin_data longtext,
166 lang varchar(2),
167 comments varchar(250) not null default '',
168 author varchar(250) not null default '') ENGINE=InnoDB DEFAULT CHARSET=UTF8;
169
170 create index ttrss_entries_date_entered_index on ttrss_entries(date_entered);
171 create index ttrss_entries_guid_index on ttrss_entries(guid);
172 create index ttrss_entries_updated_idx on ttrss_entries(updated);
173
174 create table ttrss_user_entries (
175 int_id integer not null primary key auto_increment,
176 ref_id integer not null,
177 uuid varchar(200) not null,
178 feed_id int,
179 orig_feed_id int,
180 owner_uid integer not null,
181 marked bool not null default 0,
182 published bool not null default 0,
183 tag_cache text not null,
184 label_cache text not null,
185 last_read datetime,
186 score int not null default 0,
187 note longtext,
188 last_marked datetime,
189 last_published datetime,
190 unread bool not null default 1,
191 index (ref_id),
192 foreign key (ref_id) references ttrss_entries(id) ON DELETE CASCADE,
193 index (feed_id),
194 foreign key (feed_id) references ttrss_feeds(id) ON DELETE CASCADE,
195 index (orig_feed_id),
196 foreign key (orig_feed_id) references ttrss_archived_feeds(id) ON DELETE SET NULL,
197 index (owner_uid),
198 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
199
200 create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
201 create index ttrss_user_entries_ref_id_index on ttrss_user_entries(ref_id);
202 create index ttrss_user_entries_feed_id on ttrss_user_entries(feed_id);
203 create index ttrss_user_entries_unread_idx on ttrss_user_entries(unread);
204
205 create table ttrss_entry_comments (id integer not null primary key,
206 ref_id integer not null,
207 owner_uid integer not null,
208 private bool not null default 0,
209 date_entered datetime not null,
210 index (ref_id),
211 foreign key (ref_id) references ttrss_entries(id) ON DELETE CASCADE,
212 index (owner_uid),
213 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
214
215 create table ttrss_filter_types (id integer primary key,
216 name varchar(120) unique not null,
217 description varchar(250) not null unique) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
218
219 insert into ttrss_filter_types (id,name,description) values (1, 'title', 'Title');
220 insert into ttrss_filter_types (id,name,description) values (2, 'content', 'Content');
221 insert into ttrss_filter_types (id,name,description) values (3, 'both',
222 'Title or Content');
223 insert into ttrss_filter_types (id,name,description) values (4, 'link',
224 'Link');
225 insert into ttrss_filter_types (id,name,description) values (5, 'date',
226 'Article Date');
227 insert into ttrss_filter_types (id,name,description) values (6, 'author', 'Author');
228 insert into ttrss_filter_types (id,name,description) values (7, 'tag', 'Article Tags');
229
230 create table ttrss_filter_actions (id integer not null primary key,
231 name varchar(120) unique not null,
232 description varchar(250) not null unique) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
233
234 insert into ttrss_filter_actions (id,name,description) values (1, 'filter',
235 'Delete article');
236
237 insert into ttrss_filter_actions (id,name,description) values (2, 'catchup',
238 'Mark as read');
239
240 insert into ttrss_filter_actions (id,name,description) values (3, 'mark',
241 'Set starred');
242
243 insert into ttrss_filter_actions (id,name,description) values (4, 'tag',
244 'Assign tags');
245
246 insert into ttrss_filter_actions (id,name,description) values (5, 'publish',
247 'Publish article');
248
249 insert into ttrss_filter_actions (id,name,description) values (6, 'score',
250 'Modify score');
251
252 insert into ttrss_filter_actions (id,name,description) values (7, 'label',
253 'Assign label');
254
255 insert into ttrss_filter_actions (id,name,description) values (8, 'stop',
256 'Stop / Do nothing');
257
258 create table ttrss_filters2(id integer primary key auto_increment,
259 owner_uid integer not null,
260 match_any_rule boolean not null default false,
261 enabled boolean not null default true,
262 inverse bool not null default false,
263 title varchar(250) not null default '',
264 order_id integer not null default 0,
265 index(owner_uid),
266 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
267
268 create table ttrss_filters2_rules(id integer primary key auto_increment,
269 filter_id integer not null references ttrss_filters2(id) on delete cascade,
270 reg_exp varchar(250) not null,
271 inverse bool not null default false,
272 filter_type integer not null,
273 feed_id integer default null,
274 cat_id integer default null,
275 cat_filter boolean not null default false,
276 index (filter_id),
277 foreign key (filter_id) references ttrss_filters2(id) on delete cascade,
278 index (filter_type),
279 foreign key (filter_type) references ttrss_filter_types(id) ON DELETE CASCADE,
280 index (feed_id),
281 foreign key (feed_id) references ttrss_feeds(id) ON DELETE CASCADE,
282 index (cat_id),
283 foreign key (cat_id) references ttrss_feed_categories(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
284
285 create table ttrss_filters2_actions(id integer primary key auto_increment,
286 filter_id integer not null,
287 action_id integer not null default 1 references ttrss_filter_actions(id) on delete cascade,
288 action_param varchar(250) not null default '',
289 index (filter_id),
290 foreign key (filter_id) references ttrss_filters2(id) on delete cascade,
291 index (action_id),
292 foreign key (action_id) references ttrss_filter_actions(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
293
294 create table ttrss_tags (id integer primary key auto_increment,
295 owner_uid integer not null,
296 tag_name varchar(250) not null,
297 post_int_id integer not null,
298 index (post_int_id),
299 foreign key (post_int_id) references ttrss_user_entries(int_id) ON DELETE CASCADE,
300 index (owner_uid),
301 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
302
303 create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
304
305 insert into ttrss_version values (123);
306
307 create table ttrss_enclosures (id integer primary key auto_increment,
308 content_url text not null,
309 content_type varchar(250) not null,
310 post_id integer not null,
311 title text not null,
312 duration text not null,
313 index (post_id),
314 foreign key (post_id) references ttrss_entries(id) ON DELETE cascade) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
315
316 create index ttrss_enclosures_post_id_idx on ttrss_enclosures(post_id);
317
318 create table ttrss_settings_profiles(id integer primary key auto_increment,
319 title varchar(250) not null,
320 owner_uid integer not null,
321 index (owner_uid),
322 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
323
324 create table ttrss_prefs_types (id integer not null primary key,
325 type_name varchar(100) not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
326
327 insert into ttrss_prefs_types (id, type_name) values (1, 'bool');
328 insert into ttrss_prefs_types (id, type_name) values (2, 'string');
329 insert into ttrss_prefs_types (id, type_name) values (3, 'integer');
330
331 create table ttrss_prefs_sections (id integer not null primary key,
332 order_id integer not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
333
334 insert into ttrss_prefs_sections (id, order_id) values (1, 0);
335 insert into ttrss_prefs_sections (id, order_id) values (2, 1);
336 insert into ttrss_prefs_sections (id, order_id) values (3, 3);
337 insert into ttrss_prefs_sections (id, order_id) values (4, 2);
338
339 create table ttrss_prefs (pref_name varchar(250) not null primary key,
340 type_id integer not null,
341 section_id integer not null default 1,
342 access_level integer not null default 0,
343 def_value text not null,
344 index(type_id),
345 foreign key (type_id) references ttrss_prefs_types(id),
346 index(section_id),
347 foreign key (section_id) references ttrss_prefs_sections(id)) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
348
349 create index ttrss_prefs_pref_name_idx on ttrss_prefs(pref_name);
350
351 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('PURGE_OLD_DAYS', 3, '60', 1);
352 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('DEFAULT_UPDATE_INTERVAL', 3, '30', 1);
353 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('DEFAULT_ARTICLE_LIMIT', 3, '30', 2);
354 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('ALLOW_DUPLICATE_POSTS', 1, 'false', 1);
355 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('ENABLE_FEED_CATS', 1, 'true', 2);
356 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('SHOW_CONTENT_PREVIEW', 1, 'true', 2);
357 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('SHORT_DATE_FORMAT', 2, 'M d, G:i', 3);
358 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('LONG_DATE_FORMAT', 2, 'D, M d Y - G:i', 3);
359 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('COMBINED_DISPLAY_MODE', 1, 'true', 2);
360 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('HIDE_READ_FEEDS', 1, 'false', 2);
361 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('ON_CATCHUP_SHOW_NEXT_FEED', 1, 'false', 2);
362 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('FEEDS_SORT_BY_UNREAD', 1, 'false', 2);
363 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('REVERSE_HEADLINES', 1, 'false', 2);
364 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('DIGEST_ENABLE', 1, 'false', 4);
365 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('CONFIRM_FEED_CATCHUP', 1, 'true', 2);
366 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('CDM_AUTO_CATCHUP', 1, 'false', 2);
367 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', 1);
368 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', 1);
369 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_PREFS_ACTIVE_TAB', 2, '', 1);
370 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('STRIP_UNSAFE_TAGS', 1, 'true', 3);
371 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('BLACKLISTED_TAGS', 2, 'main, generic, misc, uncategorized, blog, blogroll, general, news', 3);
372 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('FRESH_ARTICLE_MAX_AGE', 3, '24', 2);
373 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('DIGEST_CATCHUP', 1, 'false', 4);
374 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('CDM_EXPANDED', 1, 'true', 2);
375 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('PURGE_UNREAD_ARTICLES', 1, 'true', 3);
376 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('HIDE_READ_SHOWS_SPECIAL', 1, 'true', 2);
377 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('VFEED_GROUP_BY_FEED', 1, 'false', 2);
378 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('STRIP_IMAGES', 1, 'false', 2);
379 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_DEFAULT_VIEW_ORDER_BY', 2, 'default', 1);
380 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('ENABLE_API_ACCESS', 1, 'false', 1);
381 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_COLLAPSED_SPECIAL', 1, 'false', 1);
382 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_COLLAPSED_LABELS', 1, 'false', 1);
383 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_COLLAPSED_UNCAT', 1, 'false', 1);
384 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_COLLAPSED_FEEDLIST', 1, 'false', 1);
385 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_MOBILE_ENABLE_CATS', 1, 'false', 1);
386 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_MOBILE_SHOW_IMAGES', 1, 'false', 1);
387 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_MOBILE_HIDE_READ', 1, 'false', 1);
388 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_MOBILE_SORT_FEEDS_UNREAD', 1, 'false', 1);
389 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_THEME_ID', 2, '0', 1);
390 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_TIMEZONE', 2, 'Automatic', 1);
391 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_STYLESHEET', 2, '', 2);
392 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'false', 2);
393 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_MOBILE_BROWSE_CATS', 1, 'true', 1);
394 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('SSL_CERT_SERIAL', 2, '', 3);
395 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('DIGEST_PREFERRED_TIME', 2, '00:00', 4);
396 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', 1);
397 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_DEFAULT_INCLUDE_CHILDREN', 1, 'false', 1);
398 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('AUTO_ASSIGN_LABELS', 1, 'false', 3);
399 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_ENABLED_PLUGINS', 2, '', 1);
400 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('_MOBILE_REVERSE_HEADLINES', 1, 'false', 1);
401 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_CSS_THEME', 2, '', 2);
402 insert into ttrss_prefs (pref_name,type_id,def_value,section_id) values('USER_LANGUAGE', 2, '', 2);
403
404 update ttrss_prefs set access_level = 1 where pref_name in ('ON_CATCHUP_SHOW_NEXT_FEED',
405 'SORT_HEADLINES_BY_FEED_DATE',
406 'VFEED_GROUP_BY_FEED',
407 'FRESH_ARTICLE_MAX_AGE',
408 'CDM_EXPANDED',
409 'SHOW_CONTENT_PREVIEW',
410 'AUTO_ASSIGN_LABELS',
411 'HIDE_READ_SHOWS_SPECIAL');
412
413 create table ttrss_user_prefs (
414 owner_uid integer not null,
415 pref_name varchar(250),
416 value longtext not null,
417 profile integer,
418 index (profile),
419 foreign key (profile) references ttrss_settings_profiles(id) ON DELETE CASCADE,
420 index (owner_uid),
421 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE,
422 index (pref_name),
423 foreign key (pref_name) references ttrss_prefs(pref_name) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
424
425 create index ttrss_user_prefs_owner_uid_index on ttrss_user_prefs(owner_uid);
426 create index ttrss_user_prefs_pref_name_idx on ttrss_user_prefs(pref_name);
427
428 create table ttrss_sessions (id varchar(250) unique not null primary key,
429 data text,
430 expire integer not null,
431 index (id),
432 index (expire)) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
433
434 create table ttrss_feedbrowser_cache (
435 feed_url text not null,
436 site_url text not null,
437 title text not null,
438 subscribers integer not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
439
440 create table ttrss_labels2 (id integer not null primary key auto_increment,
441 owner_uid integer not null,
442 caption varchar(250) not null,
443 fg_color varchar(15) not null default '',
444 bg_color varchar(15) not null default '',
445 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE
446 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
447
448 create table ttrss_user_labels2 (label_id integer not null,
449 article_id integer not null,
450 foreign key (label_id) references ttrss_labels2(id) ON DELETE CASCADE,
451 foreign key (article_id) references ttrss_entries(id) ON DELETE CASCADE
452 ) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
453
454 create table ttrss_access_keys (id integer not null primary key auto_increment,
455 access_key varchar(250) not null,
456 feed_id varchar(250) not null,
457 is_cat bool not null default false,
458 owner_uid integer not null,
459 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
460
461 create table ttrss_linked_instances (id integer not null primary key auto_increment,
462 last_connected datetime not null,
463 last_status_in integer not null,
464 last_status_out integer not null,
465 access_key varchar(250) not null unique,
466 access_url text not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
467
468 create table ttrss_linked_feeds (
469 feed_url text not null,
470 site_url text not null,
471 title text not null,
472 created datetime not null,
473 updated datetime not null,
474 instance_id integer not null,
475 subscribers integer not null,
476 foreign key (instance_id) references ttrss_linked_instances(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
477
478 create table ttrss_plugin_storage (
479 id integer not null auto_increment primary key,
480 name varchar(100) not null,
481 owner_uid integer not null,
482 content longtext not null,
483 foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
484
485 create table ttrss_error_log(
486 id integer not null auto_increment primary key,
487 owner_uid integer,
488 errno integer not null,
489 errstr text not null,
490 filename text not null,
491 lineno integer not null,
492 context text not null,
493 created_at datetime not null,
494 foreign key (owner_uid) references ttrss_users(id) ON DELETE SET NULL) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
495
496 commit;