]> git.wh0rd.org Git - tt-rss.git/blob - schema/ttrss_schema_mysql.sql
fix scheduled_updates drop position in schema
[tt-rss.git] / schema / ttrss_schema_mysql.sql
1 drop table if exists ttrss_version;
2 drop table if exists ttrss_labels;
3 drop table if exists ttrss_filters;
4 drop table if exists ttrss_filter_types;
5 drop table if exists ttrss_filter_actions;
6 drop table if exists ttrss_user_prefs;
7 drop table if exists ttrss_prefs;
8 drop table if exists ttrss_prefs_types;
9 drop table if exists ttrss_prefs_sections; 
10 drop table if exists ttrss_tags;
11 drop table if exists ttrss_entry_comments;
12 drop table if exists ttrss_user_entries;
13 drop table if exists ttrss_entries;
14 drop table if exists ttrss_scheduled_updates;
15 drop table if exists ttrss_feeds;
16 drop table if exists ttrss_feed_categories;
17 drop table if exists ttrss_users;
18 drop table if exists ttrss_themes;
19
20 begin;
21
22 create table ttrss_themes(id integer not null primary key auto_increment,
23         theme_name varchar(200) not null,
24         theme_path varchar(200) not null) TYPE=InnoDB;
25
26 create table ttrss_users (id integer primary key not null auto_increment,
27         login varchar(120) not null unique,
28         pwd_hash varchar(250) not null,
29         last_login datetime default null,
30         access_level integer not null default 0,
31         theme_id integer default null,
32         email varchar(250) not null default '',
33         index (theme_id),
34         foreign key (theme_id) references ttrss_themes(id)) TYPE=InnoDB;
35
36 insert into ttrss_users (login,pwd_hash,access_level) values ('admin', 'password', 10);
37
38 create table ttrss_feed_categories(id integer not null primary key auto_increment,
39         owner_uid integer not null,
40         title varchar(200) not null,
41         collapsed bool not null default false,
42         index(owner_uid),
43         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) TYPE=InnoDB;
44
45 create table ttrss_feeds (id integer not null auto_increment primary key,
46         owner_uid integer not null,
47         title varchar(200) not null, 
48         cat_id integer default null,
49         feed_url varchar(250) not null, 
50         icon_url varchar(250) not null default '',
51         update_interval integer not null default 0,
52         purge_interval integer not null default 0,
53         last_updated datetime default 0,
54         last_error text not null default '',
55         site_url varchar(250) not null default '',
56         auth_login varchar(250) not null default '',
57         auth_pass varchar(250) not null default '',
58         parent_feed integer default null,
59         private bool not null default false,
60         index(owner_uid),
61         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE,
62         index(cat_id),
63         foreign key (cat_id) references ttrss_feed_categories(id),
64         index(parent_feed),
65         foreign key (parent_feed) references ttrss_feeds(id) ON DELETE SET NULL) TYPE=InnoDB;
66
67 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Footnotes', 'http://gnomedesktop.org/node/feed');
68 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Latest Linux Kernel Versions','http://kernel.org/kdist/rss.xml');
69 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'RPGDot Newsfeed',
70    'http://www.rpgdot.com/team/rss/rss0.xml');
71 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Digg.com News',
72    'http://digg.com/rss/index.xml');
73 insert into ttrss_feeds (owner_uid,title,feed_url) values (1,'Technocrat.net',
74    'http://syndication.technocrat.net/rss');
75
76 create table ttrss_entries (id integer not null primary key auto_increment, 
77         title text not null, 
78         guid varchar(255) not null unique, 
79         link text not null, 
80         updated datetime not null, 
81         content text not null,
82         content_hash varchar(250) not null,
83         no_orig_date bool not null default 0,
84         date_entered datetime not null,
85         num_comments integer not null default 0,
86         comments varchar(250) not null default '') TYPE=InnoDB;
87
88 create table ttrss_user_entries (
89         int_id integer not null primary key auto_increment,
90         ref_id integer not null,
91         feed_id int not null, 
92         owner_uid integer not null,
93         marked bool not null default 0,
94         last_read datetime,
95         unread bool not null default 1,
96         index (ref_id),
97         foreign key (ref_id) references ttrss_entries(id) ON DELETE CASCADE,
98         index (feed_id),
99         foreign key (feed_id) references ttrss_feeds(id) ON DELETE CASCADE,
100         index (owner_uid),
101         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) TYPE=InnoDB;
102
103 create table ttrss_entry_comments (id integer not null primary key,
104         ref_id integer not null,
105         owner_uid integer not null,
106         private bool not null default 0,
107         date_entered datetime not null,
108         index (ref_id),
109         foreign key (ref_id) references ttrss_entries(id) ON DELETE CASCADE,
110         index (owner_uid),
111         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) TYPE=InnoDB;
112
113 create table ttrss_filter_types (id integer primary key, 
114         name varchar(120) unique not null, 
115         description varchar(250) not null unique) TYPE=InnoDB;
116
117 insert into ttrss_filter_types (id,name,description) values (1, 'title', 'Title');
118 insert into ttrss_filter_types (id,name,description) values (2, 'content', 'Content');
119 insert into ttrss_filter_types (id,name,description) values (3, 'both', 
120         'Title or Content');
121 insert into ttrss_filter_types (id,name,description) values (4, 'link', 
122         'Link');
123
124 create table ttrss_filter_actions (id integer not null primary key, 
125         name varchar(120) unique not null, 
126         description varchar(250) not null unique) TYPE=InnoDB;
127
128 insert into ttrss_filter_actions (id,name,description) values (1, 'filter', 
129         'Filter article');
130
131 insert into ttrss_filter_actions (id,name,description) values (2, 'catchup', 
132         'Mark as read');
133
134 create table ttrss_filters (id integer not null primary key auto_increment,
135         owner_uid integer not null, 
136         feed_id integer default null,
137         filter_type integer not null,
138         reg_exp varchar(250) not null,
139         description varchar(250) not null default '',
140         action_id integer not null default 1,
141         index (filter_type),
142         foreign key (filter_type) references ttrss_filter_types(id) ON DELETE CASCADE,
143         index (owner_uid),
144         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE,
145         index (feed_id),
146         foreign key (feed_id) references ttrss_feeds(id) ON DELETE CASCADE,
147         index (action_id),
148         foreign key (action_id) references ttrss_filter_actions(id) ON DELETE CASCADE) TYPE=InnoDB;
149
150 create table ttrss_labels (id integer not null primary key auto_increment, 
151         owner_uid integer not null, 
152         sql_exp varchar(250) not null,
153         description varchar(250) not null,
154         index (owner_uid),
155         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) TYPE=InnoDB;
156
157 insert into ttrss_labels (owner_uid,sql_exp,description) values (1,'unread = true', 
158         'Unread articles');
159
160 insert into ttrss_labels (owner_uid,sql_exp,description) values (1,
161         'last_read is null and unread = false', 'Updated articles');
162
163 create table ttrss_tags (id integer primary key auto_increment, 
164         owner_uid integer not null, 
165         tag_name varchar(250) not null,
166         post_int_id integer not null,
167         index (post_int_id),
168         foreign key (post_int_id) references ttrss_user_entries(int_id) ON DELETE CASCADE,
169         index (owner_uid),
170         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE) TYPE=InnoDB;
171
172 create table ttrss_version (schema_version int not null) TYPE=InnoDB;
173
174 insert into ttrss_version values (5);
175
176 create table ttrss_prefs_types (id integer not null primary key, 
177         type_name varchar(100) not null) TYPE=InnoDB;
178
179 insert into ttrss_prefs_types (id, type_name) values (1, 'bool');
180 insert into ttrss_prefs_types (id, type_name) values (2, 'string');
181 insert into ttrss_prefs_types (id, type_name) values (3, 'integer');
182
183 create table ttrss_prefs_sections (id integer not null primary key, 
184         section_name varchar(100) not null) TYPE=InnoDB;
185
186 insert into ttrss_prefs_sections (id, section_name) values (1, 'General');
187 insert into ttrss_prefs_sections (id, section_name) values (2, 'Interface');
188 insert into ttrss_prefs_sections (id, section_name) values (3, 'Advanced');
189
190 create table ttrss_prefs (pref_name varchar(250) not null primary key,
191         type_id integer not null,
192         section_id integer not null default 1,
193         short_desc text not null,
194         help_text text not null default '',
195         def_value text not null,
196         index(type_id),
197         foreign key (type_id) references ttrss_prefs_types(id),
198         index(section_id),
199         foreign key (section_id) references ttrss_prefs_sections(id)) TYPE=InnoDB;
200
201 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);
202 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);
203 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);
204 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);
205 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('ENABLE_LABELS', 1, 'false', 'Enable labels',3,
206    '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.');
207
208 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);
209 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_HEADER', 1, 'true', 'Display header',2);
210 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('DISPLAY_FOOTER', 1, 'true', 'Display footer',2);
211 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);
212 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,
213    'Default limit for articles to display, any custom number you like (0 - disables).');
214
215 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,
216    'Display separate dropbox for feedlist actions, if disabled these actions are available in global actions menu.');
217
218 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,
219         'This option is useful when you are reading several planet-type aggregators with partially colliding userbase. 
220         When disabled, it forces same posts from different feeds to appear only once.');
221
222 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,
223         'Link to user stylesheet to override default style, disabled if empty.');
224
225 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_FEED_CATS', 1, 'false', 'Enable feed categories',2);
226
227 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);
228
229 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);
230 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);
231
232 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);
233
234 insert 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,
235         'Display expanded list of feed articles, instead of separate displays for headlines and article content');
236
237 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('ENABLE_SEARCH_TOOLBAR', 1, 'false', 'Enable search toolbar',2);
238
239 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('HIDE_READ_FEEDS', 1, 'false', 'Hide feeds with no unread messages',2);
240
241 create table ttrss_user_prefs (
242    owner_uid integer not null,
243    pref_name varchar(250),
244    value text not null,
245         index (owner_uid),
246         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE,
247         index (pref_name),
248         foreign key (pref_name) references ttrss_prefs(pref_name) ON DELETE CASCADE) TYPE=InnoDB;
249
250 create table ttrss_scheduled_updates (id integer not null primary key auto_increment,
251         owner_uid integer not null,
252         feed_id integer default null,
253         entered datetime not null,
254         foreign key (owner_uid) references ttrss_users(id) ON DELETE CASCADE,
255         foreign key (feed_id) references ttrss_feeds(id) ON DELETE CASCADE) TYPE=InnoDB;
256
257 commit;