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