2017-03-07 23:01:13 +00:00
-- settings
2017-03-28 04:12:12 +00:00
create table arsse_settings (
2017-03-07 23:01:13 +00:00
key varchar ( 255 ) primary key not null , -- setting key
value varchar ( 255 ) , -- setting value, serialized as a string
type varchar ( 255 ) not null check (
type in ( ' int ' , ' numeric ' , ' text ' , ' timestamp ' , ' date ' , ' time ' , ' bool ' , ' null ' , ' json ' )
) default ' text ' -- the deserialized type of the value
2017-03-09 15:15:28 +00:00
) without rowid ;
2017-03-07 23:01:13 +00:00
-- users
2017-03-28 04:12:12 +00:00
create table arsse_users (
2017-03-07 23:01:13 +00:00
id TEXT primary key not null , -- user id
password TEXT , -- password, salted and hashed; if using external authentication this would be blank
name TEXT , -- display name
avatar_url TEXT , -- external URL to avatar
avatar_type TEXT , -- internal avatar image's MIME content type
avatar_data BLOB , -- internal avatar image's binary data
rights integer not null default 0 -- any administrative rights the user may have
2017-03-09 15:15:28 +00:00
) without rowid ;
2017-03-07 23:01:13 +00:00
2016-10-18 15:42:21 +00:00
-- newsfeeds, deduplicated
2017-03-28 04:12:12 +00:00
create table arsse_feeds (
2017-04-14 02:17:53 +00:00
id integer primary key , -- sequence number
2017-02-16 20:29:42 +00:00
url TEXT not null , -- URL of feed
title TEXT , -- default title of feed
favicon TEXT , -- URL of favicon
source TEXT , -- URL of site to which the feed belongs
updated datetime , -- time at which the feed was last fetched
modified datetime , -- time at which the feed last actually changed
2017-04-16 02:07:22 +00:00
next_fetch datetime , -- time at which the feed should next be fetched
2017-04-14 02:17:53 +00:00
etag TEXT not null default ' ' , -- HTTP ETag hash used for cache validation, changes each time the content changes
2017-02-16 20:29:42 +00:00
err_count integer not null default 0 , -- count of successive times update resulted in error since last successful update
err_msg TEXT , -- last error message
username TEXT not null default ' ' , -- HTTP authentication username
password TEXT not null default ' ' , -- HTTP authentication password (this is stored in plain text)
unique ( url , username , password ) -- a URL with particular credentials should only appear once
2016-10-18 15:42:21 +00:00
) ;
2017-03-07 23:01:13 +00:00
-- users' subscriptions to newsfeeds, with settings
2017-03-28 04:12:12 +00:00
create table arsse_subscriptions (
2017-04-14 02:17:53 +00:00
id integer primary key , -- sequence number
2017-03-31 19:27:59 +00:00
owner TEXT not null references arsse_users ( id ) on delete cascade on update cascade , -- owner of subscription
feed integer not null references arsse_feeds ( id ) on delete cascade , -- feed for the subscription
2017-03-07 23:01:13 +00:00
added datetime not null default CURRENT_TIMESTAMP , -- time at which feed was added
modified datetime not null default CURRENT_TIMESTAMP , -- date at which subscription properties were last modified
title TEXT , -- user-supplied title
2017-03-18 16:01:23 +00:00
order_type int not null default 0 , -- NextCloud sort order
2017-03-07 23:01:13 +00:00
pinned boolean not null default 0 , -- whether feed is pinned (always sorts at top)
2017-03-31 19:27:59 +00:00
folder integer references arsse_folders ( id ) on delete cascade , -- TT-RSS category (nestable); the first-level category (which acts as NextCloud folder) is joined in when needed
2017-03-07 23:01:13 +00:00
unique ( owner , feed ) -- a given feed should only appear once for a given owner
) ;
2017-03-18 16:01:23 +00:00
-- TT-RSS categories and NextCloud folders
2017-03-28 04:12:12 +00:00
create table arsse_folders (
2017-04-14 02:17:53 +00:00
id integer primary key , -- sequence number
2017-03-31 19:27:59 +00:00
owner TEXT not null references arsse_users ( id ) on delete cascade on update cascade , -- owner of folder
2017-04-01 14:27:26 +00:00
parent integer references arsse_folders ( id ) on delete cascade , -- parent folder id
2017-03-07 23:01:13 +00:00
name TEXT not null , -- folder name
modified datetime not null default CURRENT_TIMESTAMP , --
unique ( owner , name , parent ) -- cannot have multiple folders with the same name under the same parent for the same owner
) ;
2016-10-18 15:42:21 +00:00
-- entries in newsfeeds
2017-03-28 04:12:12 +00:00
create table arsse_articles (
2017-04-14 02:17:53 +00:00
id integer primary key , -- sequence number
2017-03-31 19:27:59 +00:00
feed integer not null references arsse_feeds ( id ) on delete cascade , -- feed for the subscription
2017-02-16 20:29:42 +00:00
url TEXT not null , -- URL of article
title TEXT , -- article title
author TEXT , -- author's name
published datetime , -- time of original publication
edited datetime , -- time of last edit
2017-03-26 20:16:15 +00:00
modified datetime not null default CURRENT_TIMESTAMP , -- date when article properties were last modified
2017-02-16 20:29:42 +00:00
guid TEXT , -- GUID
content TEXT , -- content, as (X)HTML
2017-03-18 16:01:23 +00:00
url_title_hash varchar ( 64 ) , -- hash of URL + title; used when checking for updates and for identification if there is no guid.
url_content_hash varchar ( 64 ) , -- hash of URL + content, enclosure URL, & content type; used when checking for updates and for identification if there is no guid.
2017-03-26 20:16:15 +00:00
title_content_hash varchar ( 64 ) -- hash of title + content, enclosure URL, & content type; used when checking for updates and for identification if there is no guid.
2016-10-18 15:42:21 +00:00
) ;
-- enclosures associated with articles
2017-03-28 04:12:12 +00:00
create table arsse_enclosures (
article integer not null references arsse_articles ( id ) on delete cascade ,
2017-02-16 20:29:42 +00:00
url TEXT ,
type varchar ( 255 )
2016-10-18 15:42:21 +00:00
) ;
-- users' actions on newsfeed entries
2017-03-28 04:12:12 +00:00
create table arsse_subscription_articles (
2017-04-14 02:17:53 +00:00
id integer primary key ,
2017-03-28 04:12:12 +00:00
article integer not null references arsse_articles ( id ) on delete cascade ,
2017-04-14 02:17:53 +00:00
owner TEXT not null references arsse_users ( id ) on delete cascade on update cascade ,
2017-02-16 20:29:42 +00:00
read boolean not null default 0 ,
starred boolean not null default 0 ,
modified datetime not null default CURRENT_TIMESTAMP
2016-10-18 15:42:21 +00:00
) ;
2017-04-14 02:17:53 +00:00
-- IDs for specific editions of articles (required for at least NextCloud News)
create table arsse_editions (
id integer primary key ,
article integer not null references arsse_articles ( id ) on delete cascade
) ;
2016-10-18 15:42:21 +00:00
-- user labels associated with newsfeed entries
2017-03-28 04:12:12 +00:00
create table arsse_labels (
2017-04-14 02:17:53 +00:00
sub_article integer not null references arsse_subscription_articles ( id ) on delete cascade ,
2017-02-16 20:29:42 +00:00
name TEXT
2016-10-18 15:42:21 +00:00
) ;
2017-03-28 04:12:12 +00:00
create index arsse_label_names on arsse_labels ( name ) ;
2016-10-18 15:42:21 +00:00
2017-03-30 14:42:37 +00:00
-- author categories associated with newsfeed entries
create table arsse_categories (
2017-03-28 04:12:12 +00:00
article integer not null references arsse_articles ( id ) on delete cascade ,
2017-03-07 23:01:13 +00:00
name TEXT
) ;
2016-10-18 15:42:21 +00:00
-- set version marker
pragma user_version = 1 ;
2017-03-28 04:12:12 +00:00
insert into arsse_settings values ( ' schema_version ' , 1 , ' int ' ) ;