]> git.wh0rd.org - tt-rss.git/blame - schema/ttrss_schema_pgsql.sql
fix possible bug in tag-processing part of update_rss_feed
[tt-rss.git] / schema / ttrss_schema_pgsql.sql
CommitLineData
eb36b4eb 1drop table ttrss_tags;
daa25e8a 2
8bbb8466 3drop table ttrss_user_entries;
28a80fbf 4drop table ttrss_entries;
daa25e8a 5
28a80fbf 6drop table ttrss_feeds;
ee9008f9
AD
7drop table ttrss_labels;
8drop table ttrss_filters;
28a80fbf 9
4e9dd2cd
AD
10drop table ttrss_user_prefs;
11drop table ttrss_users;
12
2aaacbc0 13create table ttrss_users (id serial not null primary key,
4e9dd2cd
AD
14 login varchar(120) not null unique,
15 pwd_hash varchar(250) not null,
4f628ae5 16 last_login timestamp default null,
4e9dd2cd
AD
17 access_level integer not null default 0);
18
19insert into ttrss_users (login,pwd_hash,access_level) values ('admin', 'password', 10);
20
28a80fbf 21create table ttrss_feeds (id serial not null primary key,
4e9dd2cd 22 owner_uid integer not null references ttrss_users(id) on delete cascade,
6318df0e
AD
23 title varchar(200) not null,
24 feed_url varchar(250) not null,
b7f4bda2 25 icon_url varchar(250) not null default '',
d148926e 26 update_interval integer not null default 0,
1089b16b 27 purge_interval integer not null default 0,
ab3d0b99 28 last_updated timestamp default null,
37d379de
AD
29 last_error text not null default '',
30 site_url varchar(250) not null default '');
28a80fbf 31
daa25e8a
AD
32create index ttrss_feeds_owner_uid_index on ttrss_feeds(owner_uid);
33
4e9dd2cd 34insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Footnotes', 'http://gnomedesktop.org/node/feed');
cd42edf1
AD
35insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Latest Linux Kernel Versions','http://kernel.org/kdist/rss.xml');
36insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'RPGDot Newsfeed',
37 'http://www.rpgdot.com/team/rss/rss0.xml');
38insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Digg.com News',
39 'http://digg.com/rss/index.xml');
40insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Technocrat.net',
41 'http://syndication.technocrat.net/rss');
28a80fbf 42
28a80fbf 43create table ttrss_entries (id serial not null primary key,
9ad5b0de 44 title text not null,
8bbb8466 45 guid text not null unique,
49a0dd3d 46 link text not null,
8bbb8466 47 updated timestamp not null,
d76a3b03 48 content text not null,
466001c4 49 content_hash varchar(250) not null,
b82af8c3 50 no_orig_date boolean not null default false,
8bbb8466 51 date_entered timestamp not null default NOW(),
c62d62f6
AD
52 comments varchar(250) not null default '');
53
54create index ttrss_entries_guid_index on ttrss_entries(guid);
55create index ttrss_entries_title_index on ttrss_entries(title);
8bbb8466
AD
56
57create table ttrss_user_entries (
05732aa0 58 int_id serial not null primary key,
4c193675
AD
59 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
60 feed_id int references ttrss_feeds(id) ON DELETE CASCADE not null,
8bbb8466
AD
61 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
62 marked boolean not null default false,
63 last_read timestamp,
b82af8c3 64 unread boolean not null default true);
a0d53889 65
daa25e8a
AD
66create index ttrss_user_entries_feed_id_index on ttrss_user_entries(feed_id);
67create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
68create index ttrss_user_entries_ref_id_index on ttrss_user_entries(ref_id);
69
a0d53889
AD
70drop table ttrss_filters;
71drop table ttrss_filter_types;
72
2aaacbc0 73create table ttrss_filter_types (id integer not null primary key,
a0d53889
AD
74 name varchar(120) unique not null,
75 description varchar(250) not null unique);
76
77insert into ttrss_filter_types (id,name,description) values (1, 'title', 'Title');
78insert into ttrss_filter_types (id,name,description) values (2, 'content', 'Content');
79insert into ttrss_filter_types (id,name,description) values (3, 'both',
bdc00fe0 80 'Title or Content');
a0d53889 81
2aaacbc0 82create table ttrss_filters (id serial not null primary key,
4e9dd2cd 83 owner_uid integer not null references ttrss_users(id) on delete cascade,
a0d53889 84 filter_type integer not null references ttrss_filter_types(id),
4b3dff6e 85 reg_exp varchar(250) not null,
a0d53889
AD
86 description varchar(250) not null default '');
87
48f0adb0
AD
88drop table ttrss_labels;
89
2aaacbc0 90create table ttrss_labels (id serial not null primary key,
4e9dd2cd 91 owner_uid integer not null references ttrss_users(id) on delete cascade,
48f0adb0
AD
92 sql_exp varchar(250) not null,
93 description varchar(250) not null);
94
daa25e8a
AD
95create index ttrss_labels_owner_uid_index on ttrss_labels(owner_uid);
96
ee9008f9 97insert into ttrss_labels (owner_uid,sql_exp,description) values (1,'unread = true',
48f0adb0
AD
98 'Unread articles');
99
ee9008f9 100insert into ttrss_labels (owner_uid,sql_exp,description) values (1,
7cc6112a
AD
101 'last_read is null and unread = false', 'Updated articles');
102
2aaacbc0 103create table ttrss_tags (id serial not null primary key,
eb36b4eb 104 tag_name varchar(250) not null,
ee9008f9 105 owner_uid integer not null references ttrss_users(id) on delete cascade,
05732aa0 106 post_int_id integer references ttrss_user_entries(int_id) ON DELETE CASCADE not null);
eb36b4eb 107
daa25e8a
AD
108create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
109
5f171894
AD
110drop table ttrss_version;
111
112create table ttrss_version (schema_version int not null);
113
1089b16b 114insert into ttrss_version values (2);
5f171894 115
e0257be1
AD
116drop table ttrss_prefs;
117drop table ttrss_prefs_types;
118drop table ttrss_prefs_sections;
119
2aaacbc0 120create table ttrss_prefs_types (id integer not null primary key,
e0257be1
AD
121 type_name varchar(100) not null);
122
123insert into ttrss_prefs_types (id, type_name) values (1, 'bool');
124insert into ttrss_prefs_types (id, type_name) values (2, 'string');
125insert into ttrss_prefs_types (id, type_name) values (3, 'integer');
126
2aaacbc0 127create table ttrss_prefs_sections (id integer not null primary key,
e0257be1
AD
128 section_name varchar(100) not null);
129
603e9ebe
AD
130insert into ttrss_prefs_sections (id, section_name) values (1, 'General');
131insert into ttrss_prefs_sections (id, section_name) values (2, 'Interface');
650bc435 132insert into ttrss_prefs_sections (id, section_name) values (3, 'Advanced');
e0257be1 133
2aaacbc0 134create table ttrss_prefs (pref_name varchar(250) not null primary key,
e0257be1
AD
135 type_id integer not null references ttrss_prefs_types(id),
136 section_id integer not null references ttrss_prefs_sections(id) default 1,
603e9ebe
AD
137 short_desc text not null,
138 help_text text not null default '',
ff485f1d
AD
139 def_value text not null);
140
141insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_ICONS', 1, 'true', 'Enable icons in feedlist',2);
ff485f1d
AD
142insert 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);
143insert 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);
144insert 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);
145insert 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
146 '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.');
147
ff485f1d
AD
148insert 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);
149insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_HEADER', 1, 'true', 'Display header',2);
150insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_FOOTER', 1, 'true', 'Display footer',2);
151insert 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);
152insert 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
AD
153 'Default limit for articles to display, any custom number you like (0 - disables).');
154
ff485f1d 155insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('DAEMON_REFRESH_ONLY', 1, 'false', 'Daemon refresh only', 3,
36990e33
AD
156 'Updates to all feeds will only run when the backend script is invoked with a "daemon" option on the URI stem.');
157
ff485f1d 158insert 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,
36990e33
AD
159 'Display separate dropbox for feedlist actions, if disabled these actions are available in global actions menu.');
160
ff485f1d 161insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SPLASH', 1, 'false', 'Enable loading splashscreen',2);
e0257be1 162
71604ca4
AD
163insert 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,
164 'This option is useful when you are reading several planet-type aggregators with partially colliding userbase.
14c8eca7 165 When disabled, it forces same posts from different feeds to appear only once.');
71604ca4 166
4e9dd2cd
AD
167create table ttrss_user_prefs (
168 owner_uid integer not null references ttrss_users(id) on delete cascade,
169 pref_name varchar(250) not null references ttrss_prefs(pref_name),
170 value text not null);
171
daa25e8a
AD
172create index ttrss_user_prefs_owner_uid_index on ttrss_user_prefs(owner_uid);
173create index ttrss_user_prefs_value_index on ttrss_user_prefs(value);
174
4e9dd2cd 175