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