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