]> git.wh0rd.org - tt-rss.git/blame_incremental - schema/ttrss_schema_pgsql.sql
add stub for published items
[tt-rss.git] / schema / ttrss_schema_pgsql.sql
... / ...
CommitLineData
1drop table ttrss_version;
2drop table ttrss_labels;
3drop table ttrss_filters;
4drop table ttrss_filter_types;
5drop table ttrss_filter_actions;
6drop table ttrss_user_prefs;
7drop table ttrss_prefs;
8drop table ttrss_prefs_types;
9drop table ttrss_prefs_sections;
10drop table ttrss_tags;
11drop table ttrss_entry_comments;
12drop table ttrss_user_entries;
13drop table ttrss_entries;
14drop table ttrss_scheduled_updates;
15drop table ttrss_feeds;
16drop table ttrss_feed_categories;
17drop table ttrss_users;
18drop table ttrss_themes;
19drop table ttrss_sessions;
20
21begin;
22
23create table ttrss_themes(id serial not null primary key,
24 theme_name varchar(200) not null,
25 theme_path varchar(200) not null);
26
27insert into ttrss_themes (theme_name, theme_path) values ('Old-skool', 'compat');
28insert into ttrss_themes (theme_name, theme_path) values ('Graycube', 'graycube');
29insert into ttrss_themes (theme_name, theme_path) values ('Default (Compact)', 'compact');
30
31create table ttrss_users (id serial not null primary key,
32 login varchar(120) not null unique,
33 pwd_hash varchar(250) not null,
34 last_login timestamp default null,
35 access_level integer not null default 0,
36 email varchar(250) not null default '',
37 email_digest boolean not null default false,
38 last_digest_sent timestamp default null,
39 theme_id integer references ttrss_themes(id) default null);
40
41insert into ttrss_users (login,pwd_hash,access_level) values ('admin',
42 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', 10);
43
44create table ttrss_feed_categories(id serial not null primary key,
45 owner_uid integer not null references ttrss_users(id) on delete cascade,
46 collapsed boolean not null default false,
47 title varchar(200) not null);
48
49create table ttrss_feeds (id serial not null primary key,
50 owner_uid integer not null references ttrss_users(id) on delete cascade,
51 title varchar(200) not null,
52 cat_id integer references ttrss_feed_categories(id) default null,
53 feed_url varchar(250) not null,
54 icon_url varchar(250) not null default '',
55 update_interval integer not null default 0,
56 purge_interval integer not null default 0,
57 last_updated timestamp default null,
58 last_error text not null default '',
59 site_url varchar(250) not null default '',
60 auth_login varchar(250) not null default '',
61 parent_feed integer default null references ttrss_feeds(id) on delete set null,
62 private boolean not null default false,
63 auth_pass varchar(250) not null default '',
64 hidden boolean not null default false,
65 include_in_digest boolean not null default true,
66 rtl_content boolean not null default false,
67 auth_pass_encrypted boolean not null default false);
68
69create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid);
70
71insert into ttrss_feeds (owner_uid, title, feed_url) values
72 (1, 'Tiny Tiny RSS: New Releases', 'http://tt-rss.spb.ru/releases.rss');
73
74insert into ttrss_feeds (owner_uid, title, feed_url) values
75 (1, 'Tiny Tiny RSS: Forum', 'http://tt-rss.spb.ru/forum/rss.php');
76
77create table ttrss_entries (id serial not null primary key,
78 title text not null,
79 guid text not null unique,
80 link text not null,
81 updated timestamp not null,
82 content text not null,
83 content_hash varchar(250) not null,
84 no_orig_date boolean not null default false,
85 date_entered timestamp not null default NOW(),
86 num_comments integer not null default 0,
87 comments varchar(250) not null default '',
88 author varchar(250) not null default '');
89
90create index ttrss_entries_guid_index on ttrss_entries(guid);
91-- create index ttrss_entries_title_index on ttrss_entries(title);
92-- create index ttrss_entries_date_entered_index on ttrss_entries(date_entered);
93
94create table ttrss_user_entries (
95 int_id serial not null primary key,
96 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
97 feed_id int references ttrss_feeds(id) ON DELETE CASCADE not null,
98 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
99 marked boolean not null default false,
100 last_read timestamp,
101 unread boolean not null default true);
102
103-- create index ttrss_user_entries_feed_id_index on ttrss_user_entries(feed_id);
104-- create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
105create index ttrss_user_entries_ref_id_index on ttrss_user_entries(ref_id);
106create index ttrss_user_entries_feed_id on ttrss_user_entries(feed_id);
107
108create table ttrss_entry_comments (id serial not null primary key,
109 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
110 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
111 private boolean not null default false,
112 date_entered timestamp not null);
113
114create index ttrss_entry_comments_ref_id_index on ttrss_entry_comments(ref_id);
115-- create index ttrss_entry_comments_owner_uid_index on ttrss_entry_comments(owner_uid);
116
117create table ttrss_filter_types (id integer not null primary key,
118 name varchar(120) unique not null,
119 description varchar(250) not null unique);
120
121insert into ttrss_filter_types (id,name,description) values (1, 'title', 'Title');
122insert into ttrss_filter_types (id,name,description) values (2, 'content', 'Content');
123insert into ttrss_filter_types (id,name,description) values (3, 'both',
124 'Title or Content');
125insert into ttrss_filter_types (id,name,description) values (4, 'link',
126 'Link');
127
128create table ttrss_filter_actions (id integer not null primary key,
129 name varchar(120) unique not null,
130 description varchar(250) not null unique);
131
132insert into ttrss_filter_actions (id,name,description) values (1, 'filter',
133 'Filter article');
134
135insert into ttrss_filter_actions (id,name,description) values (2, 'catchup',
136 'Mark as read');
137
138insert into ttrss_filter_actions (id,name,description) values (3, 'mark',
139 'Set starred');
140
141insert into ttrss_filter_actions (id,name,description) values (4, 'tag',
142 'Assign tags');
143
144create table ttrss_filters (id serial not null primary key,
145 owner_uid integer not null references ttrss_users(id) on delete cascade,
146 feed_id integer references ttrss_feeds(id) on delete cascade default null,
147 filter_type integer not null references ttrss_filter_types(id),
148 reg_exp varchar(250) not null,
149 enabled boolean not null default true,
150 inverse boolean not null default false,
151 action_id integer not null default 1 references ttrss_filter_actions(id) on delete cascade,
152 action_param varchar(200) not null default '');
153
154create table ttrss_labels (id serial not null primary key,
155 owner_uid integer not null references ttrss_users(id) on delete cascade,
156 sql_exp varchar(250) not null,
157 description varchar(250) not null);
158
159create index ttrss_labels_owner_uid_index on ttrss_labels(owner_uid);
160
161insert into ttrss_labels (owner_uid,sql_exp,description) values (1,'unread = true',
162 'Unread articles');
163
164insert into ttrss_labels (owner_uid,sql_exp,description) values (1,
165 'last_read is null and unread = false', 'Updated articles');
166
167create table ttrss_tags (id serial not null primary key,
168 tag_name varchar(250) not null,
169 owner_uid integer not null references ttrss_users(id) on delete cascade,
170 post_int_id integer references ttrss_user_entries(int_id) ON DELETE CASCADE not null);
171
172create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
173
174create table ttrss_version (schema_version int not null);
175
176insert into ttrss_version values (19);
177
178create table ttrss_prefs_types (id integer not null primary key,
179 type_name varchar(100) not null);
180
181insert into ttrss_prefs_types (id, type_name) values (1, 'bool');
182insert into ttrss_prefs_types (id, type_name) values (2, 'string');
183insert into ttrss_prefs_types (id, type_name) values (3, 'integer');
184
185create table ttrss_prefs_sections (id integer not null primary key,
186 section_name varchar(100) not null);
187
188insert into ttrss_prefs_sections (id, section_name) values (1, 'General');
189insert into ttrss_prefs_sections (id, section_name) values (2, 'Interface');
190insert into ttrss_prefs_sections (id, section_name) values (3, 'Advanced');
191
192create table ttrss_prefs (pref_name varchar(250) not null primary key,
193 type_id integer not null references ttrss_prefs_types(id),
194 section_id integer not null references ttrss_prefs_sections(id) default 1,
195 short_desc text not null,
196 help_text text not null default '',
197 def_value text not null);
198
199insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_ICONS', 1, 'true', 'Enable icons in feedlist',3);
200insert 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);
201insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('UPDATE_POST_ON_CHECKSUM_CHANGE', 1, 'true', 'Update post on checksum change',1);
202insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_LABELS', 1, 'false', 'Enable labels',3,
203 'Experimental support for virtual feeds based on user crafted SQL queries. This feature is highly experimental and at this point not user friendly. Use with caution.');
204
205insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DEFAULT_UPDATE_INTERVAL', 3, '30', 'Default interval between feed updates (in minutes)',1);
206insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DEFAULT_ARTICLE_LIMIT', 3, '0', 'Default article limit',2,
207 'Default limit for articles to display, any custom number you like (0 - disables).');
208
209insert 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,
210 'This option is useful when you are reading several planet-type aggregators with partially colliding userbase.
211 When disabled, it forces same posts from different feeds to appear only once.');
212
213insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('USER_STYLESHEET_URL', 2, '', 'User stylesheet URL',2,
214 'Link to user stylesheet to override default style, disabled if empty.');
215
216insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_CATS', 1, 'false', 'Enable feed categories',2);
217
218insert 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);
219
220insert 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);
221insert 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);
222
223insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HEADLINES_SMART_DATE', 1, 'true', 'Use more accessible date/time format for headlines',3);
224
225insert 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,
226 'Display expanded list of feed articles, instead of separate displays for headlines and article content');
227
228insert 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);
229
230insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('OPEN_LINKS_IN_NEW_WINDOW', 1, 'true', 'Open article links in new browser window',2);
231
232insert 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,
233 'When "Mark as read" button is clicked in toolbar, automatically open next feed with unread articles.');
234
235insert 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);
236
237insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('EXTENDED_FEEDLIST', 1, 'false', 'Show additional information in feedlist',3);
238
239insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('MARK_UNREAD_ON_UPDATE', 1, 'false', 'Set articles as unread on update',3);
240
241insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('REVERSE_HEADLINES', 1, 'false', 'Reverse headline order (oldest first)',2);
242
243insert 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,
244'This option enables sending daily digest of new (and unread) headlines on your configured e-mail address');
245
246insert 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);
247
248insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('CDM_AUTO_CATCHUP', 1, 'false', 'Mark articles as read automatically',2,
249'This option enables marking articles as read automatically in combined mode while you scroll article list.');
250
251insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_MODE', 2, 'adaptive', '', 1);
252
253insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_DEFAULT_VIEW_LIMIT', 3, '30', '', 1);
254
255insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_ACTIVE_TAB', 2, '', '', 1);
256
257insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_INFOBOX_DISABLE_OVERLAY', 1, 'false', '', 1);
258
259insert 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,
260'Strip all but most common HTML tags when reading articles.');
261
262insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('BLACKLISTED_TAGS', 2, 'main, generic, misc', 'Blacklisted tags', 3,
263'When auto-detecting tags in articles these tags will not be applied (comma-separated list).');
264
265insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SEARCH_TOOLBAR', 1, 'false', 'Enable search toolbar',2);
266
267insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_ENABLE_PAGINATION', 2, '', '', 1);
268
269insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('_PREFS_PUBLISH_KEY', 2, '', '', 1);
270
271create table ttrss_user_prefs (
272 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
273 pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
274 value text not null);
275
276create index ttrss_user_prefs_owner_uid_index on ttrss_user_prefs(owner_uid);
277-- create index ttrss_user_prefs_value_index on ttrss_user_prefs(value);
278
279create table ttrss_scheduled_updates (id serial not null primary key,
280 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
281 feed_id integer default null references ttrss_feeds(id) ON DELETE CASCADE,
282 entered timestamp not null default NOW());
283
284create table ttrss_sessions (id varchar(250) unique not null primary key,
285 data text,
286 expire integer not null);
287
288create index ttrss_sessions_expire_index on ttrss_sessions(expire);
289
290commit;