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