]> git.wh0rd.org - tt-rss.git/blame_incremental - schema/ttrss_schema_pgsql.sql
pref-feeds: apply patch by gmargo@forum to show/hide empty categories
[tt-rss.git] / schema / ttrss_schema_pgsql.sql
... / ...
CommitLineData
1drop table if exists ttrss_linked_feeds;
2drop table if exists ttrss_linked_instances;
3drop table if exists ttrss_access_keys;
4drop table if exists ttrss_user_labels2;
5drop table if exists ttrss_labels2;
6drop table if exists ttrss_feedbrowser_cache;
7drop table if exists ttrss_version;
8drop table if exists ttrss_labels;
9drop table if exists ttrss_filters;
10drop table if exists ttrss_filter_types;
11drop table if exists ttrss_filter_actions;
12drop table if exists ttrss_user_prefs;
13drop table if exists ttrss_prefs;
14drop table if exists ttrss_prefs_types;
15drop table if exists ttrss_prefs_sections;
16drop table if exists ttrss_tags;
17drop table if exists ttrss_enclosures;
18drop table if exists ttrss_settings_profiles;
19drop table if exists ttrss_entry_comments;
20drop table if exists ttrss_user_entries;
21drop table if exists ttrss_entries;
22drop table if exists ttrss_scheduled_updates;
23drop table if exists ttrss_counters_cache;
24drop table if exists ttrss_cat_counters_cache;
25drop table if exists ttrss_archived_feeds;
26drop table if exists ttrss_feeds;
27drop table if exists ttrss_feed_categories;
28drop table if exists ttrss_users;
29drop table if exists ttrss_themes;
30drop table if exists ttrss_sessions;
31drop function if exists SUBSTRING_FOR_DATE(timestamp, int, int);
32
33begin;
34
35create table ttrss_users (id serial not null primary key,
36 login varchar(120) not null unique,
37 pwd_hash varchar(250) not null,
38 last_login timestamp default null,
39 access_level integer not null default 0,
40 email varchar(250) not null default '',
41 full_name varchar(250) not null default '',
42 email_digest boolean not null default false,
43 last_digest_sent timestamp default null,
44 salt varchar(250) not null default '',
45 twitter_oauth text default null,
46 created timestamp default null);
47
48insert into ttrss_users (login,pwd_hash,access_level) values ('admin',
49 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', 10);
50
51create table ttrss_feed_categories(id serial not null primary key,
52 owner_uid integer not null references ttrss_users(id) on delete cascade,
53 collapsed boolean not null default false,
54 order_id integer not null default 0,
55 title varchar(200) not null);
56
57create table ttrss_feeds (id serial not null primary key,
58 owner_uid integer not null references ttrss_users(id) on delete cascade,
59 title varchar(200) not null,
60 cat_id integer default null references ttrss_feed_categories(id) on delete set null,
61 feed_url text not null,
62 icon_url varchar(250) not null default '',
63 update_interval integer not null default 0,
64 purge_interval integer not null default 0,
65 last_updated timestamp default null,
66 last_error text not null default '',
67 site_url varchar(250) not null default '',
68 auth_login varchar(250) not null default '',
69 parent_feed integer default null references ttrss_feeds(id) on delete set null,
70 private boolean not null default false,
71 auth_pass varchar(250) not null default '',
72 hidden boolean not null default false,
73 include_in_digest boolean not null default true,
74 rtl_content boolean not null default false,
75 cache_images boolean not null default false,
76 last_viewed timestamp default null,
77 last_update_started timestamp default null,
78 update_method integer not null default 0,
79 always_display_enclosures boolean not null default false,
80 order_id integer not null default 0,
81 mark_unread_on_update boolean not null default false,
82 update_on_checksum_change boolean not null default false,
83 strip_images boolean not null default false,
84 pubsub_state integer not null default 0,
85 auth_pass_encrypted boolean not null default false);
86
87create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid);
88
89insert into ttrss_feeds (owner_uid, title, feed_url) values
90 (1, 'Tiny Tiny RSS: New Releases', 'http://tt-rss.org/releases.rss');
91
92insert into ttrss_feeds (owner_uid, title, feed_url) values
93 (1, 'Tiny Tiny RSS: Forum', 'http://tt-rss.org/forum/rss.php');
94
95create table ttrss_archived_feeds (id integer not null primary key,
96 owner_uid integer not null references ttrss_users(id) on delete cascade,
97 title varchar(200) not null,
98 feed_url text not null,
99 site_url varchar(250) not null default '');
100
101create table ttrss_counters_cache (
102 feed_id integer not null,
103 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
104 updated timestamp not null,
105 value integer not null default 0);
106
107create index ttrss_counters_cache_feed_id_idx on ttrss_counters_cache(feed_id);
108create index ttrss_counters_cache_owner_uid_idx on ttrss_counters_cache(owner_uid);
109create index ttrss_counters_cache_value_idx on ttrss_counters_cache(value);
110
111create table ttrss_cat_counters_cache (
112 feed_id integer not null,
113 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
114 updated timestamp not null,
115 value integer not null default 0);
116
117create index ttrss_cat_counters_cache_owner_uid_idx on ttrss_cat_counters_cache(owner_uid);
118
119create table ttrss_entries (id serial not null primary key,
120 title text not null,
121 guid text not null unique,
122 link text not null,
123 updated timestamp not null,
124 content text not null,
125 content_hash varchar(250) not null,
126 no_orig_date boolean not null default false,
127 date_entered timestamp not null,
128 date_updated timestamp not null,
129 num_comments integer not null default 0,
130 comments varchar(250) not null default '',
131 author varchar(250) not null default '');
132
133create index ttrss_entries_guid_index on ttrss_entries(guid);
134-- create index ttrss_entries_title_index on ttrss_entries(title);
135create index ttrss_entries_date_entered_index on ttrss_entries(date_entered);
136create index ttrss_entries_updated_idx on ttrss_entries(updated);
137
138create table ttrss_user_entries (
139 int_id serial not null primary key,
140 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
141 uuid varchar(200) not null,
142 feed_id int references ttrss_feeds(id) ON DELETE CASCADE,
143 orig_feed_id integer references ttrss_archived_feeds(id) ON DELETE SET NULL,
144 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
145 marked boolean not null default false,
146 published boolean not null default false,
147 tag_cache text not null,
148 label_cache text not null,
149 last_read timestamp,
150 score int not null default 0,
151 note text,
152 unread boolean not null default true);
153
154-- create index ttrss_user_entries_feed_id_index on ttrss_user_entries(feed_id);
155create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
156create index ttrss_user_entries_ref_id_index on ttrss_user_entries(ref_id);
157create index ttrss_user_entries_feed_id on ttrss_user_entries(feed_id);
158create index ttrss_user_entries_unread_idx on ttrss_user_entries(unread);
159
160create table ttrss_entry_comments (id serial not null primary key,
161 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
162 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
163 private boolean not null default false,
164 date_entered timestamp not null);
165
166create index ttrss_entry_comments_ref_id_index on ttrss_entry_comments(ref_id);
167-- create index ttrss_entry_comments_owner_uid_index on ttrss_entry_comments(owner_uid);
168
169create table ttrss_filter_types (id integer not null primary key,
170 name varchar(120) unique not null,
171 description varchar(250) not null unique);
172
173insert into ttrss_filter_types (id,name,description) values (1, 'title', 'Title');
174insert into ttrss_filter_types (id,name,description) values (2, 'content', 'Content');
175insert into ttrss_filter_types (id,name,description) values (3, 'both',
176 'Title or Content');
177insert into ttrss_filter_types (id,name,description) values (4, 'link',
178 'Link');
179insert into ttrss_filter_types (id,name,description) values (5, 'date',
180 'Article Date');
181insert into ttrss_filter_types (id,name,description) values (6, 'author', 'Author');
182insert into ttrss_filter_types (id,name,description) values (7, 'tag', 'Article Tags');
183
184create table ttrss_filter_actions (id integer not null primary key,
185 name varchar(120) unique not null,
186 description varchar(250) not null unique);
187
188insert into ttrss_filter_actions (id,name,description) values (1, 'filter',
189 'Delete article');
190
191insert into ttrss_filter_actions (id,name,description) values (2, 'catchup',
192 'Mark as read');
193
194insert into ttrss_filter_actions (id,name,description) values (3, 'mark',
195 'Set starred');
196
197insert into ttrss_filter_actions (id,name,description) values (4, 'tag',
198 'Assign tags');
199
200insert into ttrss_filter_actions (id,name,description) values (5, 'publish',
201 'Publish article');
202
203insert into ttrss_filter_actions (id,name,description) values (6, 'score',
204 'Modify score');
205
206insert into ttrss_filter_actions (id,name,description) values (7, 'label',
207 'Assign label');
208
209create table ttrss_filters (id serial not null primary key,
210 owner_uid integer not null references ttrss_users(id) on delete cascade,
211 feed_id integer references ttrss_feeds(id) on delete cascade default null,
212 filter_type integer not null references ttrss_filter_types(id),
213 reg_exp varchar(250) not null,
214 filter_param varchar(250) not null default '',
215 enabled boolean not null default true,
216 inverse boolean not null default false,
217 cat_filter boolean not null default false,
218 cat_id integer references ttrss_feed_categories(id) on delete cascade default null,
219 action_id integer not null default 1 references ttrss_filter_actions(id) on delete cascade,
220 action_param varchar(250) not null default '');
221
222create table ttrss_tags (id serial not null primary key,
223 tag_name varchar(250) not null,
224 owner_uid integer not null references ttrss_users(id) on delete cascade,
225 post_int_id integer references ttrss_user_entries(int_id) ON DELETE CASCADE not null);
226
227create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
228create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
229
230create table ttrss_version (schema_version int not null);
231
232insert into ttrss_version values (90);
233
234create table ttrss_enclosures (id serial not null primary key,
235 content_url text not null,
236 content_type varchar(250) not null,
237 title text not null,
238 duration text not null,
239 post_id integer references ttrss_entries(id) ON DELETE cascade NOT NULL);
240
241create index ttrss_enclosures_post_id_idx on ttrss_enclosures(post_id);
242
243create table ttrss_settings_profiles(id serial not null primary key,
244 title varchar(250) not null,
245 owner_uid integer not null references ttrss_users(id) on delete cascade);
246
247create table ttrss_prefs_types (id integer not null primary key,
248 type_name varchar(100) not null);
249
250insert into ttrss_prefs_types (id, type_name) values (1, 'bool');
251insert into ttrss_prefs_types (id, type_name) values (2, 'string');
252insert into ttrss_prefs_types (id, type_name) values (3, 'integer');
253
254create table ttrss_prefs_sections (id integer not null primary key,
255 section_name varchar(100) not null);
256
257insert into ttrss_prefs_sections (id, section_name) values (1, 'General');
258insert into ttrss_prefs_sections (id, section_name) values (2, 'Interface');
259insert into ttrss_prefs_sections (id, section_name) values (3, 'Advanced');
260
261create table ttrss_prefs (pref_name varchar(250) not null primary key,
262 type_id integer not null references ttrss_prefs_types(id),
263 section_id integer not null references ttrss_prefs_sections(id) default 1,
264 short_desc text not null,
265 help_text text not null default '',
266 access_level integer not null default 0,
267 def_value text not null);
268
269insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_OLD_DAYS', 3, '60', 'Purge old posts after this number of days (0 - disables)',1);
270
271insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DEFAULT_UPDATE_INTERVAL', 3, '30', 'Default interval between feed updates',1);
272
273insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DEFAULT_ARTICLE_LIMIT', 3, '30', 'Amount of articles to display at once',2);
274
275insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ALLOW_DUPLICATE_POSTS', 1, 'true', 'Allow duplicate posts',1, 'This option is useful when you are reading several planet-type aggregators with partially colliding userbase. When disabled, it forces same posts from different feeds to appear only once.');
276
277insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_CATS', 1, 'true', 'Enable feed categories',2);
278
279insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SHOW_CONTENT_PREVIEW', 1, 'true', 'Show content preview in headlines list',2);
280
281insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('SHORT_DATE_FORMAT', 2, 'M d, G:i', 'Short date format',3);
282
283insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('LONG_DATE_FORMAT', 2, 'D, M d Y - G:i', 'Long date format',3);
284
285insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('COMBINED_DISPLAY_MODE', 1, 'false', 'Combined feed display',2, 'Display expanded list of feed articles, instead of separate displays for headlines and article content');
286
287insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
288
289insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ON_CATCHUP_SHOW_NEXT_FEED', 1, 'false', 'On catchup show next feed',2, 'When "Mark as read" button is clicked in toolbar, automatically open next feed with unread articles.');
290
291insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('FEEDS_SORT_BY_UNREAD', 1, 'false', 'Sort feeds by unread articles count',2);
292
293insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('REVERSE_HEADLINES', 1, 'false', 'Reverse headline order (oldest first)',2);
294
295insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_ENABLE', 1, 'false', 'Enable e-mail digest',1, 'This option enables sending daily digest of new (and unread) headlines on your configured e-mail address');
296
297insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('CONFIRM_FEED_CATCHUP', 1, 'true', 'Confirm marking feed as read',3);
298
299insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('CDM_AUTO_CATCHUP', 1, 'false', 'Automatically mark articles as read',3, 'This option enables marking articles as read automatically while you scroll article list.');
300
301insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1);
302
303insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1);
304
305insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_ACTIVE_TAB', 2, '', '', 1);
306
307insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('STRIP_UNSAFE_TAGS', 1, 'true', 'Strip unsafe tags from articles', 3, 'Strip all but most common HTML tags when reading articles.');
308
309insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('BLACKLISTED_TAGS', 2, 'main, generic, misc, uncategorized, blog, blogroll, general, news', 'Blacklisted tags', 3, 'When auto-detecting tags in articles these tags will not be applied (comma-separated list).');
310
311insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('FRESH_ARTICLE_MAX_AGE', 3, '24', 'Maximum age of fresh articles (in hours)',2);
312
313insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DIGEST_CATCHUP', 1, 'false', 'Mark articles in e-mail digest as read',1);
314
315insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('CDM_EXPANDED', 1, 'true', 'Automatically expand articles in combined mode',3);
316
317insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('PURGE_UNREAD_ARTICLES', 1, 'true', 'Purge unread articles',3);
318
319insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_SHOWS_SPECIAL', 1, 'true', 'Show special feeds when hiding read feeds',3);
320
321insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('VFEED_GROUP_BY_FEED', 1, 'false', 'Group headlines in virtual feeds',2, 'When this option is enabled, headlines in Special feeds and Labels are grouped by feeds');
322
323insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('STRIP_IMAGES', 1, 'false', 'Do not show images in articles', 2);
324
325insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_ORDER_BY', 2, 'default', '', 1);
326
327insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_API_ACCESS', 1, 'false', 'Enable external API', 3);
328
329insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_SPECIAL', 1, 'false', '', 1);
330
331insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_LABELS', 1, 'false', '', 1);
332
333insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_UNCAT', 1, 'false', '', 1);
334
335insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_COLLAPSED_FEEDLIST', 1, 'false', '', 1);
336
337insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_ENABLE_CATS', 1, 'false', '', 1);
338
339insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_SHOW_IMAGES', 1, 'false', '', 1);
340
341insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_HIDE_READ', 1, 'false', '', 1);
342
343insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_SORT_FEEDS_UNREAD', 1, 'false', '', 1);
344
345insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_THEME_ID', 2, '0', '', 1);
346
347insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
348
349insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3, 'Use feed-specified date to sort headlines instead of local import date.');
350
351insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('USER_STYLESHEET', 2, '', 'Customize stylesheet', 2, 'Customize CSS stylesheet to your liking');
352
353insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_MOBILE_BROWSE_CATS', 1, 'true', '', 1);
354
355insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SSL_CERT_SERIAL', 2, '', 'Login with an SSL certificate',3, 'Click to register your SSL client certificate with tt-rss');
356
357insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_PREFERRED_TIME', 2, '00:00', 'Try to send digests around specified time', 1, 'Uses UTC timezone');
358
359insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_SHOW_EMPTY_CATS', 1, 'false', '', 1);
360
361create table ttrss_user_prefs (
362 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
363 pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
364 profile integer references ttrss_settings_profiles(id) ON DELETE CASCADE,
365 value text not null);
366
367create index ttrss_user_prefs_owner_uid_index on ttrss_user_prefs(owner_uid);
368-- create index ttrss_user_prefs_value_index on ttrss_user_prefs(value);
369
370create table ttrss_sessions (id varchar(250) unique not null primary key,
371 data text,
372 expire integer not null);
373
374create index ttrss_sessions_expire_index on ttrss_sessions(expire);
375
376create function SUBSTRING_FOR_DATE(timestamp, int, int) RETURNS text AS 'SELECT SUBSTRING(CAST($1 AS text), $2, $3)' LANGUAGE 'sql';
377
378create table ttrss_feedbrowser_cache (
379 feed_url text not null primary key,
380 title text not null,
381 site_url text not null,
382 subscribers integer not null);
383
384create table ttrss_labels2 (id serial not null primary key,
385 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
386 fg_color varchar(15) not null default '',
387 bg_color varchar(15) not null default '',
388 caption varchar(250) not null
389);
390
391create table ttrss_user_labels2 (
392 label_id integer not null references ttrss_labels2(id) ON DELETE CASCADE,
393 article_id integer not null references ttrss_entries(id) ON DELETE CASCADE
394);
395
396create table ttrss_access_keys (id serial not null primary key,
397 access_key varchar(250) not null,
398 feed_id varchar(250) not null,
399 is_cat boolean not null default false,
400 owner_uid integer not null references ttrss_users(id) on delete cascade);
401
402create table ttrss_linked_instances (id serial not null primary key,
403 last_connected timestamp not null,
404 last_status_in integer not null,
405 last_status_out integer not null,
406 access_key varchar(250) not null unique,
407 access_url text not null);
408
409create table ttrss_linked_feeds (
410 feed_url text not null,
411 site_url text not null,
412 title text not null,
413 created timestamp not null,
414 updated timestamp not null,
415 instance_id integer not null references ttrss_linked_instances(id) ON DELETE CASCADE,
416 subscribers integer not null);
417
418commit;