]> git.wh0rd.org - tt-rss.git/blob - schema/ttrss_schema_pgsql.sql
new option: HIDE_READ_FEEDS (+ pref setting RPC calls) (closes #23)
[tt-rss.git] / schema / ttrss_schema_pgsql.sql
1 drop table ttrss_version;
2 drop table ttrss_labels;
3 drop table ttrss_filters;
4 drop table ttrss_filter_types;
5 drop table ttrss_filter_actions;
6 drop table ttrss_user_prefs;
7 drop table ttrss_prefs;
8 drop table ttrss_prefs_types;
9 drop table ttrss_prefs_sections;
10 drop table ttrss_tags;
11 drop table ttrss_entry_comments;
12 drop table ttrss_user_entries;
13 drop table ttrss_entries;
14 drop table ttrss_feeds;
15 drop table ttrss_feed_categories;
16 drop table ttrss_users;
17 drop table ttrss_themes;
18
19 begin;
20
21 create table ttrss_themes(id serial not null primary key,
22 theme_name varchar(200) not null,
23 theme_path varchar(200) not null);
24
25 create table ttrss_users (id serial not null primary key,
26 login varchar(120) not null unique,
27 pwd_hash varchar(250) not null,
28 last_login timestamp default null,
29 access_level integer not null default 0,
30 email varchar(250) not null default '',
31 theme_id integer references ttrss_themes(id) default null);
32
33 insert into ttrss_users (login,pwd_hash,access_level) values ('admin', 'password', 10);
34
35 create table ttrss_feed_categories(id serial not null primary key,
36 owner_uid integer not null references ttrss_users(id) on delete cascade,
37 collapsed boolean not null default false,
38 title varchar(200) not null);
39
40 create table ttrss_feeds (id serial not null primary key,
41 owner_uid integer not null references ttrss_users(id) on delete cascade,
42 title varchar(200) not null,
43 cat_id integer references ttrss_feed_categories(id) default null,
44 feed_url varchar(250) not null,
45 icon_url varchar(250) not null default '',
46 update_interval integer not null default 0,
47 purge_interval integer not null default 0,
48 last_updated timestamp default null,
49 last_error text not null default '',
50 site_url varchar(250) not null default '',
51 auth_login varchar(250) not null default '',
52 parent_feed integer default null references ttrss_feeds(id) on delete set null,
53 private boolean not null default false,
54 auth_pass varchar(250) not null default '');
55
56 create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid);
57
58 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Footnotes', 'http://gnomedesktop.org/node/feed');
59 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Latest Linux Kernel Versions','http://kernel.org/kdist/rss.xml');
60 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'RPGDot Newsfeed',
61 'http://www.rpgdot.com/team/rss/rss0.xml');
62 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Digg.com News',
63 'http://digg.com/rss/index.xml');
64 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Technocrat.net',
65 'http://syndication.technocrat.net/rss');
66
67 create table ttrss_entries (id serial not null primary key,
68 title text not null,
69 guid text not null unique,
70 link text not null,
71 updated timestamp not null,
72 content text not null,
73 content_hash varchar(250) not null,
74 no_orig_date boolean not null default false,
75 date_entered timestamp not null default NOW(),
76 num_comments integer not null default 0,
77 comments varchar(250) not null default '');
78
79 create index ttrss_entries_guid_index on ttrss_entries(guid);
80 create index ttrss_entries_title_index on ttrss_entries(title);
81
82 create table ttrss_user_entries (
83 int_id serial not null primary key,
84 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
85 feed_id int references ttrss_feeds(id) ON DELETE CASCADE not null,
86 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
87 marked boolean not null default false,
88 last_read timestamp,
89 unread boolean not null default true);
90
91 create index ttrss_user_entries_feed_id_index on ttrss_user_entries(feed_id);
92 create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
93 create index ttrss_user_entries_ref_id_index on ttrss_user_entries(ref_id);
94
95 create table ttrss_entry_comments (id serial not null primary key,
96 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
97 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
98 private boolean not null default false,
99 date_entered timestamp not null);
100
101 create index ttrss_entry_comments_ref_id_index on ttrss_entry_comments(ref_id);
102 create index ttrss_entry_comments_owner_uid_index on ttrss_entry_comments(owner_uid);
103
104 create table ttrss_filter_types (id integer not null primary key,
105 name varchar(120) unique not null,
106 description varchar(250) not null unique);
107
108 insert into ttrss_filter_types (id,name,description) values (1, 'title', 'Title');
109 insert into ttrss_filter_types (id,name,description) values (2, 'content', 'Content');
110 insert into ttrss_filter_types (id,name,description) values (3, 'both',
111 'Title or Content');
112 insert into ttrss_filter_types (id,name,description) values (4, 'link',
113 'Link');
114
115 create table ttrss_filter_actions (id integer not null primary key,
116 name varchar(120) unique not null,
117 description varchar(250) not null unique);
118
119 insert into ttrss_filter_actions (id,name,description) values (1, 'filter',
120 'Filter article');
121
122 insert into ttrss_filter_actions (id,name,description) values (2, 'catchup',
123 'Mark as read');
124
125 create table ttrss_filters (id serial not null primary key,
126 owner_uid integer not null references ttrss_users(id) on delete cascade,
127 feed_id integer references ttrss_feeds(id) on delete cascade default null,
128 filter_type integer not null references ttrss_filter_types(id),
129 reg_exp varchar(250) not null,
130 description varchar(250) not null default '',
131 action_id integer not null default 1 references ttrss_filter_actions(id) on delete cascade);
132
133 create table ttrss_labels (id serial not null primary key,
134 owner_uid integer not null references ttrss_users(id) on delete cascade,
135 sql_exp varchar(250) not null,
136 description varchar(250) not null);
137
138 create index ttrss_labels_owner_uid_index on ttrss_labels(owner_uid);
139
140 insert into ttrss_labels (owner_uid,sql_exp,description) values (1,'unread = true',
141 'Unread articles');
142
143 insert into ttrss_labels (owner_uid,sql_exp,description) values (1,
144 'last_read is null and unread = false', 'Updated articles');
145
146 create table ttrss_tags (id serial not null primary key,
147 tag_name varchar(250) not null,
148 owner_uid integer not null references ttrss_users(id) on delete cascade,
149 post_int_id integer references ttrss_user_entries(int_id) ON DELETE CASCADE not null);
150
151 create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
152
153 create table ttrss_version (schema_version int not null);
154
155 insert into ttrss_version values (4);
156
157 create table ttrss_prefs_types (id integer not null primary key,
158 type_name varchar(100) not null);
159
160 insert into ttrss_prefs_types (id, type_name) values (1, 'bool');
161 insert into ttrss_prefs_types (id, type_name) values (2, 'string');
162 insert into ttrss_prefs_types (id, type_name) values (3, 'integer');
163
164 create table ttrss_prefs_sections (id integer not null primary key,
165 section_name varchar(100) not null);
166
167 insert into ttrss_prefs_sections (id, section_name) values (1, 'General');
168 insert into ttrss_prefs_sections (id, section_name) values (2, 'Interface');
169 insert into ttrss_prefs_sections (id, section_name) values (3, 'Advanced');
170
171 create table ttrss_prefs (pref_name varchar(250) not null primary key,
172 type_id integer not null references ttrss_prefs_types(id),
173 section_id integer not null references ttrss_prefs_sections(id) default 1,
174 short_desc text not null,
175 help_text text not null default '',
176 def_value text not null);
177
178 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_ICONS', 1, 'true', 'Enable icons in feedlist',2);
179 insert 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);
180 insert 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);
181 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_PREFS_CATCHUP_UNCATCHUP', 1, 'false', 'Enable catchup/uncatchup buttons in feed editor',2);
182 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_LABELS', 1, 'false', 'Enable labels',3,
183 '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.');
184
185 insert 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);
186 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_HEADER', 1, 'true', 'Display header',2);
187 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_FOOTER', 1, 'true', 'Display footer',2);
188 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USE_COMPACT_STYLESHEET', 1, 'false', 'Use compact stylesheet by default',2);
189 insert 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,
190 'Default limit for articles to display, any custom number you like (0 - disables).');
191
192 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DISPLAY_FEEDLIST_ACTIONS', 1, 'false', 'Display feedlist actions',2,
193 'Display separate dropbox for feedlist actions, if disabled these actions are available in global actions menu.');
194
195 insert 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,
196 'This option is useful when you are reading several planet-type aggregators with partially colliding userbase.
197 When disabled, it forces same posts from different feeds to appear only once.');
198
199 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('USER_STYLESHEET_URL', 2, '', 'User stylesheet URL',2,
200 'Link to user stylesheet to override default style, disabled if empty.');
201
202 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_CATS', 1, 'false', 'Enable feed categories',2);
203
204 insert 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);
205
206 insert 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);
207 insert 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);
208
209 insert 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);
210
211 insert 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,
212 'Display expanded list of feed articles, instead of separate displays for headlines and article content');
213
214 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SEARCH_TOOLBAR', 1, 'false', 'Enable search toolbar',2);
215
216 insert 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);
217
218 create table ttrss_user_prefs (
219 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
220 pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
221 value text not null);
222
223 create index ttrss_user_prefs_owner_uid_index on ttrss_user_prefs(owner_uid);
224 create index ttrss_user_prefs_value_index on ttrss_user_prefs(value);
225
226 commit;