]> git.wh0rd.org - tt-rss.git/blame - schema/ttrss_schema_pgsql.sql
add schema indexes
[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(),
daa25e8a
AD
52 comments varchar(250) not null default '',
53 index (guid), index(title));
8bbb8466
AD
54
55create table ttrss_user_entries (
4c193675
AD
56 ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
57 feed_id int references ttrss_feeds(id) ON DELETE CASCADE not null,
8bbb8466
AD
58 owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
59 marked boolean not null default false,
60 last_read timestamp,
b82af8c3 61 unread boolean not null default true);
a0d53889 62
daa25e8a
AD
63create index ttrss_user_entries_feed_id_index on ttrss_user_entries(feed_id);
64create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
65create index ttrss_user_entries_ref_id_index on ttrss_user_entries(ref_id);
66
a0d53889
AD
67drop table ttrss_filters;
68drop table ttrss_filter_types;
69
2aaacbc0 70create table ttrss_filter_types (id integer not null primary key,
a0d53889
AD
71 name varchar(120) unique not null,
72 description varchar(250) not null unique);
73
74insert into ttrss_filter_types (id,name,description) values (1, 'title', 'Title');
75insert into ttrss_filter_types (id,name,description) values (2, 'content', 'Content');
76insert into ttrss_filter_types (id,name,description) values (3, 'both',
bdc00fe0 77 'Title or Content');
a0d53889 78
2aaacbc0 79create table ttrss_filters (id serial not null primary key,
4e9dd2cd 80 owner_uid integer not null references ttrss_users(id) on delete cascade,
a0d53889 81 filter_type integer not null references ttrss_filter_types(id),
4b3dff6e 82 reg_exp varchar(250) not null,
a0d53889
AD
83 description varchar(250) not null default '');
84
48f0adb0
AD
85drop table ttrss_labels;
86
2aaacbc0 87create table ttrss_labels (id serial not null primary key,
4e9dd2cd 88 owner_uid integer not null references ttrss_users(id) on delete cascade,
48f0adb0
AD
89 sql_exp varchar(250) not null,
90 description varchar(250) not null);
91
daa25e8a
AD
92create index ttrss_labels_owner_uid_index on ttrss_labels(owner_uid);
93
ee9008f9 94insert into ttrss_labels (owner_uid,sql_exp,description) values (1,'unread = true',
48f0adb0
AD
95 'Unread articles');
96
ee9008f9 97insert into ttrss_labels (owner_uid,sql_exp,description) values (1,
7cc6112a
AD
98 'last_read is null and unread = false', 'Updated articles');
99
2aaacbc0 100create table ttrss_tags (id serial not null primary key,
eb36b4eb 101 tag_name varchar(250) not null,
ee9008f9 102 owner_uid integer not null references ttrss_users(id) on delete cascade,
eb36b4eb
AD
103 post_id integer references ttrss_entries(id) ON DELETE CASCADE not null);
104
daa25e8a
AD
105create index ttrss_tags_owner_uid_index on ttrss_tags(owner_uid);
106
5f171894
AD
107drop table ttrss_version;
108
109create table ttrss_version (schema_version int not null);
110
1089b16b 111insert into ttrss_version values (2);
5f171894 112
e0257be1
AD
113drop table ttrss_prefs;
114drop table ttrss_prefs_types;
115drop table ttrss_prefs_sections;
116
2aaacbc0 117create table ttrss_prefs_types (id integer not null primary key,
e0257be1
AD
118 type_name varchar(100) not null);
119
120insert into ttrss_prefs_types (id, type_name) values (1, 'bool');
121insert into ttrss_prefs_types (id, type_name) values (2, 'string');
122insert into ttrss_prefs_types (id, type_name) values (3, 'integer');
123
2aaacbc0 124create table ttrss_prefs_sections (id integer not null primary key,
e0257be1
AD
125 section_name varchar(100) not null);
126
603e9ebe
AD
127insert into ttrss_prefs_sections (id, section_name) values (1, 'General');
128insert into ttrss_prefs_sections (id, section_name) values (2, 'Interface');
650bc435 129insert into ttrss_prefs_sections (id, section_name) values (3, 'Advanced');
e0257be1 130
2aaacbc0 131create table ttrss_prefs (pref_name varchar(250) not null primary key,
e0257be1
AD
132 type_id integer not null references ttrss_prefs_types(id),
133 section_id integer not null references ttrss_prefs_sections(id) default 1,
603e9ebe
AD
134 short_desc text not null,
135 help_text text not null default '',
ff485f1d
AD
136 def_value text not null);
137
138insert 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
139insert 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);
140insert 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);
141insert 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);
142insert 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
143 '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.');
144
ff485f1d
AD
145insert 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);
146insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_HEADER', 1, 'true', 'Display header',2);
147insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_FOOTER', 1, 'true', 'Display footer',2);
148insert 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);
149insert 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
150 'Default limit for articles to display, any custom number you like (0 - disables).');
151
ff485f1d 152insert 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
153 'Updates to all feeds will only run when the backend script is invoked with a "daemon" option on the URI stem.');
154
ff485f1d 155insert 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
156 'Display separate dropbox for feedlist actions, if disabled these actions are available in global actions menu.');
157
ff485f1d 158insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SPLASH', 1, 'false', 'Enable loading splashscreen',2);
e0257be1 159
4e9dd2cd
AD
160create table ttrss_user_prefs (
161 owner_uid integer not null references ttrss_users(id) on delete cascade,
162 pref_name varchar(250) not null references ttrss_prefs(pref_name),
163 value text not null);
164
daa25e8a
AD
165create index ttrss_user_prefs_owner_uid_index on ttrss_user_prefs(owner_uid);
166create index ttrss_user_prefs_value_index on ttrss_user_prefs(value);
167
4e9dd2cd 168