]> git.wh0rd.org - tt-rss.git/blame - schema/ttrss_schema_pgsql.sql
add upgrade schema files for 1.2.3, new option: DIGEST_ENABLE
[tt-rss.git] / schema / ttrss_schema_pgsql.sql
CommitLineData
81dde650
AD
1drop table ttrss_version;
2drop table ttrss_labels;
3drop table ttrss_filters;
4drop table ttrss_filter_types;
53d6935b 5drop table ttrss_filter_actions;
81dde650
AD
6drop table ttrss_user_prefs;
7drop table ttrss_prefs;
8drop table ttrss_prefs_types;
9drop table ttrss_prefs_sections;
eb36b4eb 10drop table ttrss_tags;
8caa7999 11drop table ttrss_entry_comments;
81dde650 12drop table ttrss_user_entries;
28a80fbf 13drop table ttrss_entries;
ab5eb26f 14drop table ttrss_scheduled_updates;
28a80fbf 15drop table ttrss_feeds;
4a9a8bd8 16drop table ttrss_feed_categories;
4e9dd2cd 17drop table ttrss_users;
e552e5a2 18drop table ttrss_themes;
36bfab86 19drop table ttrss_sessions;
e552e5a2 20
855d0ecf
AD
21begin;
22
e552e5a2
AD
23create table ttrss_themes(id serial not null primary key,
24 theme_name varchar(200) not null,
25 theme_path varchar(200) not null);
4e9dd2cd 26
e52d6bc4
AD
27insert into ttrss_themes (theme_name, theme_path) values ('Old-skool', 'compat');
28
2aaacbc0 29create table ttrss_users (id serial not null primary key,
4e9dd2cd
AD
30 login varchar(120) not null unique,
31 pwd_hash varchar(250) not null,
4f628ae5 32 last_login timestamp default null,
53d6935b 33 access_level integer not null default 0,
8629e09d 34 email varchar(250) not null default '',
32be4b10
AD
35 email_digest boolean not null default false,
36 last_digest_sent timestamp default null,
e552e5a2 37 theme_id integer references ttrss_themes(id) default null);
4e9dd2cd 38
7f16656e
AD
39insert into ttrss_users (login,pwd_hash,access_level) values ('admin',
40 'SHA1:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', 10);
4e9dd2cd 41
4a9a8bd8 42create table ttrss_feed_categories(id serial not null primary key,
5a214f9d 43 owner_uid integer not null references ttrss_users(id) on delete cascade,
28bcadff 44 collapsed boolean not null default false,
4a9a8bd8
AD
45 title varchar(200) not null);
46
28a80fbf 47create table ttrss_feeds (id serial not null primary key,
4e9dd2cd 48 owner_uid integer not null references ttrss_users(id) on delete cascade,
6318df0e 49 title varchar(200) not null,
4a9a8bd8 50 cat_id integer references ttrss_feed_categories(id) default null,
6318df0e 51 feed_url varchar(250) not null,
b7f4bda2 52 icon_url varchar(250) not null default '',
d148926e 53 update_interval integer not null default 0,
1089b16b 54 purge_interval integer not null default 0,
ab3d0b99 55 last_updated timestamp default null,
37d379de 56 last_error text not null default '',
e93a3c96
AD
57 site_url varchar(250) not null default '',
58 auth_login varchar(250) not null default '',
de99f500 59 parent_feed integer default null references ttrss_feeds(id) on delete set null,
5b35b4de 60 private boolean not null default false,
70f6dbb1 61 auth_pass varchar(250) not null default '',
7da377ca 62 hidden boolean not null default false,
70f6dbb1 63 rtl_content boolean not null default false);
28a80fbf 64
daa25e8a
AD
65create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid);
66
4e9dd2cd 67insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Footnotes', 'http://gnomedesktop.org/node/feed');
cd42edf1
AD
68insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Latest Linux Kernel Versions','http://kernel.org/kdist/rss.xml');
69insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'RPGDot Newsfeed',
70 'http://www.rpgdot.com/team/rss/rss0.xml');
71insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Digg.com News',
72 'http://digg.com/rss/index.xml');
73insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Technocrat.net',
74 'http://syndication.technocrat.net/rss');
28a80fbf 75
28a80fbf 76create table ttrss_entries (id serial not null primary key,
9ad5b0de 77 title text not null,
8bbb8466 78 guid text not null unique,
49a0dd3d 79 link text not null,
8bbb8466 80 updated timestamp not null,
d76a3b03 81 content text not null,
466001c4 82 content_hash varchar(250) not null,
b82af8c3 83 no_orig_date boolean not null default false,
8bbb8466 84 date_entered timestamp not null default NOW(),
eb40e11b 85 num_comments integer not null default 0,
4bc760da
AD
86 comments varchar(250) not null default '',
87 author varchar(250) not null default '');
c62d62f6
AD
88
89create index ttrss_entries_guid_index on ttrss_entries(guid);
894ebcf5
AD
90-- create index ttrss_entries_title_index on ttrss_entries(title);
91-- create index ttrss_entries_date_entered_index on ttrss_entries(date_entered);
8bbb8466
AD
92
93create table ttrss_user_entries (
05732aa0 94 int_id serial not null primary key,
4c193675
AD
95 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
96 feed_id int references ttrss_feeds(id) ON DELETE CASCADE not null,
8bbb8466
AD
97 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
98 marked boolean not null default false,
99 last_read timestamp,
b82af8c3 100 unread boolean not null default true);
a0d53889 101
894ebcf5
AD
102-- create index ttrss_user_entries_feed_id_index on ttrss_user_entries(feed_id);
103-- create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
daa25e8a 104create index ttrss_user_entries_ref_id_index on ttrss_user_entries(ref_id);
894ebcf5 105create index ttrss_user_entries_feed_id on ttrss_user_entries(feed_id);
daa25e8a 106
8caa7999
AD
107create table ttrss_entry_comments (id serial not null primary key,
108 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
109 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
110 private boolean not null default false,
111 date_entered timestamp not null);
112
113create index ttrss_entry_comments_ref_id_index on ttrss_entry_comments(ref_id);
894ebcf5 114-- create index ttrss_entry_comments_owner_uid_index on ttrss_entry_comments(owner_uid);
8caa7999 115
2aaacbc0 116create table ttrss_filter_types (id integer not null primary key,
a0d53889
AD
117 name varchar(120) unique not null,
118 description varchar(250) not null unique);
119
120insert into ttrss_filter_types (id,name,description) values (1, 'title', 'Title');
121insert into ttrss_filter_types (id,name,description) values (2, 'content', 'Content');
122insert into ttrss_filter_types (id,name,description) values (3, 'both',
bdc00fe0 123 'Title or Content');
3a933f22
AD
124insert into ttrss_filter_types (id,name,description) values (4, 'link',
125 'Link');
a0d53889 126
53d6935b
AD
127create table ttrss_filter_actions (id integer not null primary key,
128 name varchar(120) unique not null,
129 description varchar(250) not null unique);
130
131insert into ttrss_filter_actions (id,name,description) values (1, 'filter',
132 'Filter article');
133
134insert into ttrss_filter_actions (id,name,description) values (2, 'catchup',
135 'Mark as read');
136
dd7d3187
AD
137insert into ttrss_filter_actions (id,name,description) values (3, 'mark',
138 'Set starred');
139
2bbd16b9 140create table ttrss_filters (id serial not null primary key,
4e9dd2cd 141 owner_uid integer not null references ttrss_users(id) on delete cascade,
e55a298d 142 feed_id integer references ttrss_feeds(id) on delete cascade default null,
a0d53889 143 filter_type integer not null references ttrss_filter_types(id),
4b3dff6e 144 reg_exp varchar(250) not null,
4fd52ba4 145 enabled boolean not null default true,
53d6935b 146 action_id integer not null default 1 references ttrss_filter_actions(id) on delete cascade);
a0d53889 147
2aaacbc0 148create table ttrss_labels (id serial not null primary key,
4e9dd2cd 149 owner_uid integer not null references ttrss_users(id) on delete cascade,
48f0adb0
AD
150 sql_exp varchar(250) not null,
151 description varchar(250) not null);
152
daa25e8a
AD
153create index ttrss_labels_owner_uid_index on ttrss_labels(owner_uid);
154
ee9008f9 155insert into ttrss_labels (owner_uid,sql_exp,description) values (1,'unread = true',
48f0adb0
AD
156 'Unread articles');
157
ee9008f9 158insert into ttrss_labels (owner_uid,sql_exp,description) values (1,
7cc6112a
AD
159 'last_read is null and unread = false', 'Updated articles');
160
2aaacbc0 161create table ttrss_tags (id serial not null primary key,
eb36b4eb 162 tag_name varchar(250) not null,
ee9008f9 163 owner_uid integer not null references ttrss_users(id) on delete cascade,
05732aa0 164 post_int_id integer references ttrss_user_entries(int_id) ON DELETE CASCADE not null);
eb36b4eb 165
daa25e8a
AD
166create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
167
5f171894
AD
168create table ttrss_version (schema_version int not null);
169
4919fb42 170insert into ttrss_version values (9);
5f171894 171
2aaacbc0 172create table ttrss_prefs_types (id integer not null primary key,
e0257be1
AD
173 type_name varchar(100) not null);
174
175insert into ttrss_prefs_types (id, type_name) values (1, 'bool');
176insert into ttrss_prefs_types (id, type_name) values (2, 'string');
177insert into ttrss_prefs_types (id, type_name) values (3, 'integer');
178
2aaacbc0 179create table ttrss_prefs_sections (id integer not null primary key,
e0257be1
AD
180 section_name varchar(100) not null);
181
603e9ebe
AD
182insert into ttrss_prefs_sections (id, section_name) values (1, 'General');
183insert into ttrss_prefs_sections (id, section_name) values (2, 'Interface');
650bc435 184insert into ttrss_prefs_sections (id, section_name) values (3, 'Advanced');
e0257be1 185
2aaacbc0 186create table ttrss_prefs (pref_name varchar(250) not null primary key,
e0257be1
AD
187 type_id integer not null references ttrss_prefs_types(id),
188 section_id integer not null references ttrss_prefs_sections(id) default 1,
603e9ebe
AD
189 short_desc text not null,
190 help_text text not null default '',
ff485f1d
AD
191 def_value text not null);
192
53c98a9a 193insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_ICONS', 1, 'true', 'Enable icons in feedlist',3);
ff485f1d
AD
194insert 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);
195insert 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);
ff485f1d 196insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_LABELS', 1, 'false', 'Enable labels',3,
36990e33
AD
197 '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.');
198
ff485f1d
AD
199insert 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);
200insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_HEADER', 1, 'true', 'Display header',2);
201insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_FOOTER', 1, 'true', 'Display footer',2);
202insert 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);
203insert 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,
36990e33 204 'Default limit for articles to display, any custom number you like (0 - disables).');
36990e33 205
71604ca4
AD
206insert 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,
207 'This option is useful when you are reading several planet-type aggregators with partially colliding userbase.
14c8eca7 208 When disabled, it forces same posts from different feeds to appear only once.');
71604ca4 209
386d7b5b
AD
210insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('USER_STYLESHEET_URL', 2, '', 'User stylesheet URL',2,
211 'Link to user stylesheet to override default style, disabled if empty.');
212
91ff844a 213insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_CATS', 1, 'false', 'Enable feed categories',2);
10dc37ac 214
591c396d
AD
215insert 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);
216
9167e250
AD
217insert 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);
218insert 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);
219
be773442
AD
220insert 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);
221
30ccc2f1
AD
222insert 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,
223 'Display expanded list of feed articles, instead of separate displays for headlines and article content');
386cbf27 224
53c98a9a 225insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SEARCH_TOOLBAR', 1, 'false', 'Enable search toolbar',3);
5238347d 226
7f123cda
AD
227insert 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);
228
68511f86
AD
229insert 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);
230
e52d6bc4
AD
231insert 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,
232 'When "Mark as read" button is clicked in toolbar, automatically open next feed with unread articles.');
233
c9268ed5
AD
234insert 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);
235
53c98a9a 236insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('EXTENDED_FEEDLIST', 1, 'false', 'Show additional information in feedlist',3);
78d5212c 237
4919fb42
AD
238insert 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);
239
d6e5706d
AD
240insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('REVERSE_HEADLINES', 1, 'false', 'Reverse headline order (oldest first)',2);
241
9a61ce6d
AD
242insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DIGEST_ENABLE', 1, 'false', 'Enable email digest',1,
243'This option enables sending daily digest of new (and unread) headlines on your configured e-mail address');
244
4e9dd2cd 245create table ttrss_user_prefs (
00a0bcc8
AD
246 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
247 pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
4e9dd2cd
AD
248 value text not null);
249
daa25e8a 250create index ttrss_user_prefs_owner_uid_index on ttrss_user_prefs(owner_uid);
894ebcf5 251-- create index ttrss_user_prefs_value_index on ttrss_user_prefs(value);
daa25e8a 252
de696427
AD
253create table ttrss_scheduled_updates (id serial not null primary key,
254 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
255 feed_id integer default null references ttrss_feeds(id) ON DELETE CASCADE,
256 entered timestamp not null default NOW());
257
04febb04 258create table ttrss_sessions (id varchar(250) unique not null primary key,
09018e95 259 data text,
a2e9b457 260 expire integer not null);
36bfab86 261
36bfab86
AD
262create index ttrss_sessions_expire_index on ttrss_sessions(expire);
263
855d0ecf 264commit;